192 lines · plain
1// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library \2// RUN: -fhlsl-strict-availability -fsyntax-only -verify %s3 4__attribute__((availability(shadermodel, introduced = 6.5)))5float fx(float); // #fx6 7__attribute__((availability(shadermodel, introduced = 6.6)))8half fx(half); // #fx_half9 10__attribute__((availability(shadermodel, introduced = 5.0, environment = pixel)))11__attribute__((availability(shadermodel, introduced = 6.5, environment = compute)))12float fy(float); // #fy13 14__attribute__((availability(shadermodel, introduced = 5.0, environment = pixel)))15__attribute__((availability(shadermodel, introduced = 6.5, environment = mesh)))16float fz(float); // #fz17 18// FIXME: all diagnostics marked as FUTURE will come alive when HLSL default19// diagnostic mode is implemented in a future PR which will verify calls in20// all functions that are reachable from the shader library entry points21 22float also_alive(float f) {23 // expected-error@#also_alive_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}24 // 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}}25 float A = fx(f); // #also_alive_fx_call26 27 // expected-error@#also_alive_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}28 // 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}}29 float B = fy(f); // #also_alive_fy_call30 31 // expected-error@#also_alive_fz_call {{'fz' is unavailable}}32 // 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}}33 float C = fz(f); // #also_alive_fz_call34 35 return 0;36}37 38float alive(float f) {39 // expected-error@#alive_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}40 // 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}}41 float A = fx(f); // #alive_fx_call42 43 // expected-error@#alive_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}44 // 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}}45 float B = fy(f); // #alive_fy_call46 47 // expected-error@#alive_fz_call {{'fz' is unavailable}}48 // 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}}49 float C = fz(f); // #alive_fz_call50 51 return also_alive(f);52}53 54float also_dead(float f) {55 // expected-error@#also_dead_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}56 // 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}}57 float A = fx(f); // #also_dead_fx_call58 59 // Call to environment-specific function from an unreachable function 60 // in a shader library - no diagnostic expected.61 float B = fy(f); // #also_dead_fy_call62 63 // Call to environment-specific function from an unreachable function 64 // in a shader library - no diagnostic expected.65 float C = fz(f); // #also_dead_fz_call66 return 0;67}68 69float dead(float f) {70 // expected-error@#dead_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}71 // 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}}72 float A = fx(f); // #dead_fx_call73 74 // Call to environment-specific function from an unreachable function 75 // in a shader library - no diagnostic expected.76 float B = fy(f); // #dead_fy_call77 78 // Call to environment-specific function from an unreachable function 79 // in a shader library - no diagnostic expected.80 float C = fz(f); // #dead_fz_call81 82 return also_dead(f);83}84 85template<typename T>86T aliveTemp(T f) {87 // expected-error@#aliveTemp_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}88 // expected-note@#aliveTemp_inst {{in instantiation of function template specialization 'aliveTemp<float>' requested here}}89 // 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}}90 float A = fx(f); // #aliveTemp_fx_call91 // expected-error@#aliveTemp_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}92 // 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}}93 float B = fy(f); // #aliveTemp_fy_call94 // expected-error@#aliveTemp_fz_call {{'fz' is unavailable}}95 // 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}}96 float C = fz(f); // #aliveTemp_fz_call97 return 0;98}99 100template<typename T> T aliveTemp2(T f) {101 // expected-error@#aliveTemp2_fx_call {{'fx' is only available on Shader Model 6.6 or newer}}102 // 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}}103 // expected-error@#aliveTemp2_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}104 // 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}}105 return fx(f); // #aliveTemp2_fx_call106}107 108half test(half x) {109 return aliveTemp2(x); // expected-note {{in instantiation of function template specialization 'aliveTemp2<half>' requested here}}110}111 112float test(float x) {113 return aliveTemp2(x); // expected-note {{in instantiation of function template specialization 'aliveTemp2<float>' requested here}}114}115 116class MyClass117{118 float F;119 float makeF() {120 // expected-error@#MyClass_makeF_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}121 // 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}}122 float A = fx(F); // #MyClass_makeF_fx_call123 // expected-error@#MyClass_makeF_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}124 // 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}}125 float B = fy(F); // #MyClass_makeF_fy_call126 // expected-error@#MyClass_makeF_fz_call {{'fz' is unavailable}}127 // 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}}128 float C = fz(F); // #MyClass_makeF_fz_call129 }130};131 132// Exported function without body, not used133export void exportedFunctionUnused(float f);134 135// Exported function with body, without export, not used136void exportedFunctionUnused(float f) {137 // expected-error@#exportedFunctionUnused_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}138 // 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}}139 float A = fx(f); // #exportedFunctionUnused_fx_call140 141 // API with shader-stage-specific availability in unused exported library function142 // - no errors expected because the actual shader stage this function143 // will be used in not known at this time144 float B = fy(f);145 float C = fz(f);146}147 148// Exported function with body - called from main() which is a compute shader entry point149export void exportedFunctionUsed(float f) {150 // expected-error@#exportedFunctionUsed_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}151 // 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}}152 float A = fx(f); // #exportedFunctionUsed_fx_call153 154 // expected-error@#exportedFunctionUsed_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}155 // 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}}156 float B = fy(f); // #exportedFunctionUsed_fy_call157 158 // expected-error@#exportedFunctionUsed_fz_call {{'fz' is unavailable}}159 // 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}}160 float C = fz(f); // #exportedFunctionUsed_fz_call161}162 163namespace A {164 namespace B {165 export {166 void exportedFunctionInNS(float x) {167 // expected-error@#exportedFunctionInNS_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}168 // 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}}169 float A = fx(x); // #exportedFunctionInNS_fx_call170 171 // API with shader-stage-specific availability in exported library function172 // - no errors expected because the actual shader stage this function173 // will be used in not known at this time174 float B = fy(x);175 float C = fz(x);176 }177 }178 }179}180 181[shader("compute")]182[numthreads(4,1,1)]183void main() {184 float f = 3;185 MyClass C = { 1.0f };186 float a = alive(f);float b = aliveTemp<float>(f); // #aliveTemp_inst187 float c = C.makeF();188 float d = test((float)1.0);189 float e = test((half)1.0);190 exportedFunctionUsed(1.0f);191}192