1 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -ast-dump -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-mesh -x hlsl -ast-dump -o - %s | FileCheck %s
3 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-amplification -x hlsl -ast-dump -o - %s | FileCheck %s
4 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -o - %s | FileCheck %s
5 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-pixel -x hlsl -ast-dump -o - %s -verify
6 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-vertex -x hlsl -ast-dump -o - %s -verify
7 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-hull -x hlsl -ast-dump -o - %s -verify
8 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-domain -x hlsl -ast-dump -o - %s -verify
9 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -ast-dump -o - %s -DFAIL -verify
10 // RUN: %clang_cc1 -triple dxil-pc-shadermodel5.0-compute -x hlsl -ast-dump -o - %s -DFAIL -verify
11 // RUN: %clang_cc1 -triple dxil-pc-shadermodel4.0-compute -x hlsl -ast-dump -o - %s -DFAIL -verify
13 #if __SHADER_TARGET_STAGE == __SHADER_STAGE_COMPUTE || __SHADER_TARGET_STAGE == __SHADER_STAGE_MESH || __SHADER_TARGET_STAGE == __SHADER_STAGE_AMPLIFICATION || __SHADER_TARGET_STAGE == __SHADER_STAGE_LIBRARY
16 // expected-warning@+1 {{'numthreads' attribute only applies to global functions}}
19 // expected-warning@+1 {{'numthreads' attribute only applies to global functions}}
23 // expected-warning@+1 {{'numthreads' attribute only applies to global functions}}
28 // expected-warning@+1 {{'numthreads' attribute only applies to global functions}}
33 // expected-warning@+1 {{'numthreads' attribute only applies to global functions}}
38 // expected-error@+1 {{'numthreads' attribute parameters do not match the previous declaration}}
40 // expected-note@+1 {{conflicting attribute is here}}
46 // expected-note@+1 {{conflicting attribute is here}}
50 // expected-error@+1 {{'numthreads' attribute parameters do not match the previous declaration}}
56 #if __SHADER_TARGET_MAJOR == 6
57 // expected-error@+1 {{'numthreads' attribute requires exactly 3 arguments}}
59 // expected-error@+1 {{'numthreads' attribute requires exactly 3 arguments}}
61 // expected-error@+1 {{'numthreads' attribute requires exactly 3 arguments}}
63 // expected-error@+1 {{'numthreads' attribute requires an integer constant}}
65 // expected-error@+1 {{argument 'X' to numthreads attribute cannot exceed 1024}}
67 // expected-error@+1 {{argument 'Y' to numthreads attribute cannot exceed 1024}}
69 // expected-error@+1 {{argument 'Z' to numthreads attribute cannot exceed 1024}}
71 // expected-error@+1 {{total number of threads cannot exceed 1024}}
72 [numthreads(1024,1024,1024)]
73 #elif __SHADER_TARGET_MAJOR == 5
74 // expected-error@+1 {{argument 'Z' to numthreads attribute cannot exceed 64}}
77 // expected-error@+1 {{argument 'Z' to numthreads attribute cannot exceed 1}}
79 // expected-error@+1 {{total number of threads cannot exceed 768}}
80 [numthreads(1024,1,1)]
81 #endif // __SHADER_TARGET_MAJOR
83 // CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}} <line:{{[0-9]+}}:2, col:18> 1 2 1
89 // Because these two attributes match, they should both appear in the AST
91 // CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}} <line:90:2, col:18> 2 2 1
95 // CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}} <line:94:2, col:18> 2 2 1
101 // CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}} <line:100:2, col:18> 4 2 1
102 int onlyOnForwardDecl();
104 // CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}} <line:100:2, col:18> Inherited 4 2 1
105 int onlyOnForwardDecl() {
109 #else // Vertex and Pixel only beyond here
110 // expected-error-re@+1 {{attribute 'numthreads' is unsupported in '{{[A-Za-z]+}}' shaders, requires one of the following: compute, amplification, mesh}}