yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
2a5d5b323
master
1// paren-insertion-bug.slang 2 3// Confirm that precedence is correctly handled 4// for cast from scalar to vector. 5 6//TEST(compute):COMPARE_COMPUTE: -shaderobj 7 8int test(float a) 9{ 10 // This line performs a cast from a scalar result to a vector 11 float3 b = pow(a, 2.0); 12 13 // If the computation of `b` above gets folded into this 14 // line of code (and we expect it to) we need to correctly 15 // parenthesize the generated cast so that the `.xyz` swizzle 16 // applies to the result of the cast, rather than the input. 17 // 18 return int(float4(b.xyz * 2.0, 1.0).x); 19} 20 21 22//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer 23RWStructuredBuffer<uint> outputBuffer; 24 25[numthreads(4, 1, 1)] 26void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 27{ 28 uint tid = dispatchThreadID.x; 29 30 uint inVal = tid; 31 uint outVal = test(inVal); 32 33 outputBuffer[tid] = outVal; 34}