1 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library \
\r
2 // RUN: -fsyntax-only -verify %s
\r
4 __attribute__((availability(shadermodel, introduced = 6.5)))
\r
5 float fx(float); // #fx
\r
7 __attribute__((availability(shadermodel, introduced = 6.6)))
\r
8 half fx(half); // #fx_half
\r
10 __attribute__((availability(shadermodel, introduced = 5.0, environment = pixel)))
\r
11 __attribute__((availability(shadermodel, introduced = 6.5, environment = compute)))
\r
12 float fy(float); // #fy
\r
14 __attribute__((availability(shadermodel, introduced = 5.0, environment = pixel)))
\r
15 __attribute__((availability(shadermodel, introduced = 6.5, environment = mesh)))
\r
16 float fz(float); // #fz
\r
18 float also_alive(float f) {
\r
19 // expected-error@#also_alive_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
\r
20 // expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
\r
21 float A = fx(f); // #also_alive_fx_call
\r
23 // expected-error@#also_alive_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
\r
24 // expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
\r
25 float B = fy(f); // #also_alive_fy_call
\r
27 // expected-error@#also_alive_fz_call {{'fz' is unavailable}}
\r
28 // expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
\r
29 float C = fz(f); // #also_alive_fz_call
\r
34 float alive(float f) {
\r
35 // expected-error@#alive_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
\r
36 // expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
\r
37 float A = fx(f); // #alive_fx_call
\r
39 // expected-error@#alive_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
\r
40 // expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
\r
41 float B = fy(f); // #alive_fy_call
\r
43 // expected-error@#alive_fz_call {{'fz' is unavailable}}
\r
44 // expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
\r
45 float C = fz(f); // #alive_fz_call
\r
47 return also_alive(f);
\r
50 float also_dead(float f) {
\r
51 // unreachable code - no errors expected
\r
58 float dead(float f) {
\r
59 // unreachable code - no errors expected
\r
63 return also_dead(f);
\r
66 template<typename T>
\r
68 // expected-error@#aliveTemp_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
\r
69 // expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
\r
70 float A = fx(f); // #aliveTemp_fx_call
\r
71 // expected-error@#aliveTemp_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
\r
72 // expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
\r
73 float B = fy(f); // #aliveTemp_fy_call
\r
74 // expected-error@#aliveTemp_fz_call {{'fz' is unavailable}}
\r
75 // expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
\r
76 float C = fz(f); // #aliveTemp_fz_call
\r
80 template<typename T> T aliveTemp2(T f) {
\r
81 // expected-error@#aliveTemp2_fx_call {{'fx' is only available on Shader Model 6.6 or newer}}
\r
82 // expected-note@#fx_half {{'fx' has been marked as being introduced in Shader Model 6.6 here, but the deployment target is Shader Model 6.0}}
\r
83 // expected-error@#aliveTemp2_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
\r
84 // expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
\r
85 return fx(f); // #aliveTemp2_fx_call
\r
89 return aliveTemp2(x);
\r
92 float test(float x) {
\r
93 return aliveTemp2(x);
\r
100 // expected-error@#MyClass_makeF_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
\r
101 // expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
\r
102 float A = fx(F); // #MyClass_makeF_fx_call
\r
103 // expected-error@#MyClass_makeF_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
\r
104 // expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
\r
105 float B = fy(F); // #MyClass_makeF_fy_call
\r
106 // expected-error@#MyClass_makeF_fz_call {{'fz' is unavailable}}
\r
107 // expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
\r
108 float C = fz(F); // #MyClass_makeF_fz_call
\r
113 // Exported function without body, not used
\r
114 export void exportedFunctionUnused(float f);
\r
116 // Exported function with body, without export, not used
\r
117 void exportedFunctionUnused(float f) {
\r
118 // expected-error@#exportedFunctionUnused_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
\r
119 // expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
\r
120 float A = fx(f); // #exportedFunctionUnused_fx_call
\r
122 // API with shader-stage-specific availability in unused exported library function
\r
123 // - no errors expected because the actual shader stage this function
\r
124 // will be used in not known at this time
\r
129 // Exported function with body - called from main() which is a compute shader entry point
\r
130 export void exportedFunctionUsed(float f) {
\r
131 // expected-error@#exportedFunctionUsed_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
\r
132 // expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
\r
133 float A = fx(f); // #exportedFunctionUsed_fx_call
\r
135 // expected-error@#exportedFunctionUsed_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
\r
136 // expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
\r
137 float B = fy(f); // #exportedFunctionUsed_fy_call
\r
139 // expected-error@#exportedFunctionUsed_fz_call {{'fz' is unavailable}}
\r
140 // expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
\r
141 float C = fz(f); // #exportedFunctionUsed_fz_call
\r
147 void exportedFunctionInNS(float x) {
\r
148 // expected-error@#exportedFunctionInNS_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
\r
149 // expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
\r
150 float A = fx(x); // #exportedFunctionInNS_fx_call
\r
152 // API with shader-stage-specific availability in exported library function
\r
153 // - no errors expected because the actual shader stage this function
\r
154 // will be used in not known at this time
\r
162 // Shader entry point without body
\r
163 [shader("compute")]
\r
164 [numthreads(4,1,1)]
\r
167 // Shader entry point with body
\r
168 [shader("compute")]
\r
169 [numthreads(4,1,1)]
\r
172 MyClass C = { 1.0f };
\r
173 float a = alive(f);
\r
174 float b = aliveTemp<float>(f); // #aliveTemp_inst
\r
175 float c = C.makeF();
\r
176 float d = test((float)1.0);
\r
177 float e = test((half)1.0);
\r
178 exportedFunctionUsed(1.0f);
\r