brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.7 KiB · 073f9bc Raw
125 lines · plain
1// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -ast-dump -o - %s | FileCheck %s2// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-mesh -x hlsl -ast-dump -o - %s | FileCheck %s3// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-amplification -x hlsl -ast-dump -o - %s | FileCheck %s4// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -o - %s | FileCheck %s5// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-pixel -x hlsl -ast-dump -o - %s -verify6// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-vertex -x hlsl -ast-dump -o - %s -verify7// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-hull -x hlsl -ast-dump -o - %s -verify8// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-domain -x hlsl -ast-dump -o - %s -verify9// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -ast-dump -o - %s -DFAIL -verify10// RUN: %clang_cc1 -triple dxil-pc-shadermodel5.0-compute -x hlsl -ast-dump -o - %s -DFAIL -verify11// RUN: %clang_cc1 -triple dxil-pc-shadermodel4.0-compute -x hlsl -ast-dump -o - %s -DFAIL -verify12 13// RUN: %clang_cc1 -triple spirv-pc-vulkan1.3-compute -x hlsl -ast-dump -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-SPIRV14 15#if __SHADER_TARGET_STAGE == __SHADER_STAGE_COMPUTE || __SHADER_TARGET_STAGE == __SHADER_STAGE_MESH || __SHADER_TARGET_STAGE == __SHADER_STAGE_AMPLIFICATION || __SHADER_TARGET_STAGE == __SHADER_STAGE_LIBRARY16#ifdef FAIL17 18// expected-warning@+1 {{'numthreads' attribute only applies to global functions}}19[numthreads(1,1,1)]20struct Fido {21  // expected-warning@+1 {{'numthreads' attribute only applies to global functions}}22  [numthreads(1,1,1)]23  void wag() {}24 25  // expected-warning@+1 {{'numthreads' attribute only applies to global functions}}26  [numthreads(1,1,1)]27  static void oops() {}28};29 30// expected-warning@+1 {{'numthreads' attribute only applies to global functions}}31[numthreads(1,1,1)]32static void oops() {}33 34namespace spec {35// expected-warning@+1 {{'numthreads' attribute only applies to global functions}}36[numthreads(1,1,1)]37static void oops() {}38}39 40// expected-error@+1 {{'numthreads' attribute parameters do not match the previous declaration}}41[numthreads(1,1,1)]42// expected-note@+1 {{conflicting attribute is here}}43[numthreads(2,2,1)]44int doubledUp() {45  return 1;46}47 48// expected-note@+1 {{conflicting attribute is here}}49[numthreads(1,1,1)]50int forwardDecl();51 52// expected-error@+1 {{'numthreads' attribute parameters do not match the previous declaration}}53[numthreads(2,2,1)]54int forwardDecl() {55  return 1;56}57 58#if __SHADER_TARGET_MAJOR == 659// expected-error@+1 {{'numthreads' attribute requires exactly 3 arguments}}60[numthreads]61// expected-error@+1 {{'numthreads' attribute requires exactly 3 arguments}}62[numthreads()]63// expected-error@+1 {{'numthreads' attribute requires exactly 3 arguments}}64[numthreads(1,2,3,4)]65// expected-error@+1 {{'numthreads' attribute requires an integer constant}}66[numthreads("1",2,3)]67// expected-error@+1 {{argument 'X' to numthreads attribute cannot exceed 1024}}68[numthreads(-1,2,3)]69// expected-error@+1 {{argument 'Y' to numthreads attribute cannot exceed 1024}}70[numthreads(1,-2,3)]71// expected-error@+1 {{argument 'Z' to numthreads attribute cannot exceed 1024}}72[numthreads(1,2,-3)]73// expected-error@+1 {{total number of threads cannot exceed 1024}}74[numthreads(1024,1024,1024)]75#elif __SHADER_TARGET_MAJOR == 576// expected-error@+1 {{argument 'Z' to numthreads attribute cannot exceed 64}}77[numthreads(1,2,68)]78#else79// expected-error@+1 {{argument 'Z' to numthreads attribute cannot exceed 1}}80[numthreads(1,2,2)]81// expected-error@+1 {{total number of threads cannot exceed 768}}82[numthreads(1024,1,1)]83#endif // __SHADER_TARGET_MAJOR84#endif // FAIL85// CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}} <line:{{[0-9]+}}:2, col:18> 1 2 186[numthreads(1,2,1)]87int entry() {88 return 1;89}90 91// Because these two attributes match, they should both appear in the AST92[numthreads(2,2,1)]93// CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}} <line:{{[0-9]+}}:2, col:18> 2 2 194int secondFn();95 96[numthreads(2,2,1)]97// CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}} <line:{{[0-9]+}}:2, col:18> 2 2 198int secondFn() {99  return 1;100}101 102[numthreads(4,2,1)]103// CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}} <line:{{[0-9]+}}:2, col:18> 4 2 1104int onlyOnForwardDecl();105 106// CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}} <line:{{[0-9]+}}:2, col:18> Inherited 4 2 1107int onlyOnForwardDecl() {108  return 1;109}110 111#ifdef __spirv__ 112[numthreads(4,2,128)]113// CHECK-SPIRV: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}} <line:{{[0-9]+}}:2, col:20> 4 2 128114int largeZ();115#endif 116 117#else // Vertex and Pixel only beyond here118// expected-error-re@+1 {{attribute 'numthreads' is unsupported in '{{[A-Za-z]+}}' shaders, requires one of the following: compute, amplification, mesh}}119[numthreads(1,1,1)]120int main() : A {121 return 1;122}123 124#endif125