yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
9ed7b5264
master
1// comma-operator.slang 2 3//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj -xslang -Wno-41024 4//TEST(compute):COMPARE_COMPUTE: -shaderobj -xslang -Wno-41024 5 6// Test that the "comma operator" behaves as expected 7 8// We will also include a cross-compilation test just to 9// confirm that the generated SPIR-V (and by extension DXIL/DXBC) 10// doesn't include a subroutine defintion/call for `operator,` 11 12//TEST:CROSS_COMPILE:-target spirv-assembly -entry computeMain -stage compute -Wno-41024 13 14int test(int inVal) 15{ 16 int a = inVal; 17 18 // We expect the left operand to `operator,` to be 19 // evaluated before the right operand, and for the 20 // result to be the value of the right operand 21 // 22 return a*=2, a+1; 23} 24 25//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4):out,name=outputBuffer 26RWStructuredBuffer<int> outputBuffer; 27 28[numthreads(4, 1, 1)] 29void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 30{ 31 uint tid = dispatchThreadID.x; 32 int inVal = outputBuffer[tid]; 33 int outVal = test(inVal); 34 outputBuffer[tid] = outVal; 35}