| 1 |
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library \ |
| 2 |
// RUN: -fsyntax-only -verify %s |
| 3 |
|
| 4 |
__attribute__((availability(shadermodel, introduced = 6.5))) |
| 5 |
float fx(float); // #fx |
| 6 |
|
| 7 |
__attribute__((availability(shadermodel, introduced = 6.6))) |
| 8 |
half fx(half); // #fx_half |
| 9 |
|
| 10 |
__attribute__((availability(shadermodel, introduced = 5.0, environment = pixel))) |
| 11 |
__attribute__((availability(shadermodel, introduced = 6.5, environment = compute))) |
| 12 |
float fy(float); // #fy |
| 13 |
|
| 14 |
__attribute__((availability(shadermodel, introduced = 5.0, environment = pixel))) |
| 15 |
__attribute__((availability(shadermodel, introduced = 6.5, environment = mesh))) |
| 16 |
float fz(float); // #fz |
| 17 |
|
| 18 |
float also_alive(float f) { |
| 19 |
// expected-error@#also_alive_fx_call {{'fx' is only available on Shader Model 6.5 or newer}} |
| 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}} |
| 21 |
float A = fx(f); // #also_alive_fx_call |
| 22 |
|
| 23 |
// expected-error@#also_alive_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}} |
| 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}} |
| 25 |
float B = fy(f); // #also_alive_fy_call |
| 26 |
|
| 27 |
// expected-error@#also_alive_fz_call {{'fz' is unavailable}} |
| 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}} |
| 29 |
float C = fz(f); // #also_alive_fz_call |
| 30 |
|
| 31 |
return 0; |
| 32 |
} |
| 33 |
|
| 34 |
float alive(float f) { |
| 35 |
// expected-error@#alive_fx_call {{'fx' is only available on Shader Model 6.5 or newer}} |
| 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}} |
| 37 |
float A = fx(f); // #alive_fx_call |
| 38 |
|
| 39 |
// expected-error@#alive_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}} |
| 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}} |
| 41 |
float B = fy(f); // #alive_fy_call |
| 42 |
|
| 43 |
// expected-error@#alive_fz_call {{'fz' is unavailable}} |
| 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}} |
| 45 |
float C = fz(f); // #alive_fz_call |
| 46 |
|
| 47 |
return also_alive(f); |
| 48 |
} |
| 49 |
|
| 50 |
float also_dead(float f) { |
| 51 |
// unreachable code - no errors expected |
| 52 |
float A = fx(f); |
| 53 |
float B = fy(f); |
| 54 |
float C = fz(f); |
| 55 |
return 0; |
| 56 |
} |
| 57 |
|
| 58 |
float dead(float f) { |
| 59 |
// unreachable code - no errors expected |
| 60 |
float A = fx(f); |
| 61 |
float B = fy(f); |
| 62 |
float C = fz(f); |
| 63 |
return also_dead(f); |
| 64 |
} |
| 65 |
|
| 66 |
template<typename T> |
| 67 |
T aliveTemp(T f) { |
| 68 |
// expected-error@#aliveTemp_fx_call {{'fx' is only available on Shader Model 6.5 or newer}} |
| 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}} |
| 70 |
float A = fx(f); // #aliveTemp_fx_call |
| 71 |
// expected-error@#aliveTemp_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}} |
| 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}} |
| 73 |
float B = fy(f); // #aliveTemp_fy_call |
| 74 |
// expected-error@#aliveTemp_fz_call {{'fz' is unavailable}} |
| 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}} |
| 76 |
float C = fz(f); // #aliveTemp_fz_call |
| 77 |
return 0; |
| 78 |
} |
| 79 |
|
| 80 |
template<typename T> T aliveTemp2(T f) { |
| 81 |
// expected-error@#aliveTemp2_fx_call {{'fx' is only available on Shader Model 6.6 or newer}} |
| 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}} |
| 83 |
// expected-error@#aliveTemp2_fx_call {{'fx' is only available on Shader Model 6.5 or newer}} |
| 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}} |
| 85 |
return fx(f); // #aliveTemp2_fx_call |
| 86 |
} |
| 87 |
|
| 88 |
half test(half x) { |
| 89 |
return aliveTemp2(x); |
| 90 |
} |
| 91 |
|
| 92 |
float test(float x) { |
| 93 |
return aliveTemp2(x); |
| 94 |
} |
| 95 |
|
| 96 |
class MyClass |
| 97 |
{ |
| 98 |
float F; |
| 99 |
float makeF() { |
| 100 |
// expected-error@#MyClass_makeF_fx_call {{'fx' is only available on Shader Model 6.5 or newer}} |
| 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}} |
| 102 |
float A = fx(F); // #MyClass_makeF_fx_call |
| 103 |
// expected-error@#MyClass_makeF_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}} |
| 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}} |
| 105 |
float B = fy(F); // #MyClass_makeF_fy_call |
| 106 |
// expected-error@#MyClass_makeF_fz_call {{'fz' is unavailable}} |
| 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}} |
| 108 |
float C = fz(F); // #MyClass_makeF_fz_call |
| 109 |
return 0; |
| 110 |
} |
| 111 |
}; |
| 112 |
|
| 113 |
// Exported function without body, not used |
| 114 |
export void exportedFunctionUnused(float f); |
| 115 |
|
| 116 |
// Exported function with body, without export, not used |
| 117 |
void exportedFunctionUnused(float f) { |
| 118 |
// expected-error@#exportedFunctionUnused_fx_call {{'fx' is only available on Shader Model 6.5 or newer}} |
| 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}} |
| 120 |
float A = fx(f); // #exportedFunctionUnused_fx_call |
| 121 |
|
| 122 |
// API with shader-stage-specific availability in unused exported library function |
| 123 |
// - no errors expected because the actual shader stage this function |
| 124 |
// will be used in not known at this time |
| 125 |
float B = fy(f); |
| 126 |
float C = fz(f); |
| 127 |
} |
| 128 |
|
| 129 |
// Exported function with body - called from main() which is a compute shader entry point |
| 130 |
export void exportedFunctionUsed(float f) { |
| 131 |
// expected-error@#exportedFunctionUsed_fx_call {{'fx' is only available on Shader Model 6.5 or newer}} |
| 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}} |
| 133 |
float A = fx(f); // #exportedFunctionUsed_fx_call |
| 134 |
|
| 135 |
// expected-error@#exportedFunctionUsed_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}} |
| 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}} |
| 137 |
float B = fy(f); // #exportedFunctionUsed_fy_call |
| 138 |
|
| 139 |
// expected-error@#exportedFunctionUsed_fz_call {{'fz' is unavailable}} |
| 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}} |
| 141 |
float C = fz(f); // #exportedFunctionUsed_fz_call |
| 142 |
} |
| 143 |
|
| 144 |
namespace A { |
| 145 |
namespace B { |
| 146 |
export { |
| 147 |
void exportedFunctionInNS(float x) { |
| 148 |
// expected-error@#exportedFunctionInNS_fx_call {{'fx' is only available on Shader Model 6.5 or newer}} |
| 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}} |
| 150 |
float A = fx(x); // #exportedFunctionInNS_fx_call |
| 151 |
|
| 152 |
// API with shader-stage-specific availability in exported library function |
| 153 |
// - no errors expected because the actual shader stage this function |
| 154 |
// will be used in not known at this time |
| 155 |
float B = fy(x); |
| 156 |
float C = fz(x); |
| 157 |
} |
| 158 |
} |
| 159 |
} |
| 160 |
} |
| 161 |
|
| 162 |
// Shader entry point without body |
| 163 |
[shader("compute")] |
| 164 |
[numthreads(4,1,1)] |
| 165 |
void main(); |
| 166 |
|
| 167 |
// Shader entry point with body |
| 168 |
[shader("compute")] |
| 169 |
[numthreads(4,1,1)] |
| 170 |
void main() { |
| 171 |
float f = 3; |
| 172 |
MyClass C = { 1.0f }; |
| 173 |
float a = alive(f); |
| 174 |
float b = aliveTemp<float>(f); // #aliveTemp_inst |
| 175 |
float c = C.makeF(); |
| 176 |
float d = test((float)1.0); |
| 177 |
float e = test((half)1.0); |
| 178 |
exportedFunctionUsed(1.0f); |
| 179 |
} |