yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
afb8146e1
master
1//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): 2 3// Failure to pass compile-time-constant data 4// where it is expected. 5// 6// In this case, the place where compile-time-constant 7// data is expected is the texel offset parameter to 8// the `Texture2D.Sample` operation. 9 10Texture2D t; 11SamplerState s; 12 13cbuffer U 14{ 15 float2 uv; 16 uint2 offset; 17}; 18 19float4 main() : SV_Target 20{ 21 float4 result = 0.0f; 22 23 // Okay, immediate constant 24 result += t.Sample(s, uv, int2(0,0)); 25 26 // Error: data passed through cbuffer isn't compile-time constant 27 // CHECK: ([[# @LINE+1]]): error 40012: 28 result += t.Sample(s, uv, offset); 29 30 // Error: data computed via conditional isn't compile-time cosntant 31 uint ii = 0; 32 if(uv.x > 0.0f) 33 { 34 ii = 1; 35 } 36 // CHECK: ([[# @LINE+1]]): error 40012: 37 result += t.Sample(s, uv, int2(ii)); 38 39 // Error: data computed in loop isn't compile-time constant 40 // (and loop isn't unroll-able) 41 // CHECK: ([[# @LINE+1]]): error 40012: 42 for(uint jj = 0; jj < uv.y; jj++) 43 { 44 result += t.Sample(s, uv, int2(jj)); 45 } 46 47 48 49 50 return result; 51}