yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
712ce653d
master
1// cast-zero-to-struct.slang 2 3// Test that HLSL legacy syntax for casting from literal zero 4// to a `struct` type works. 5 6//TEST(compute):COMPARE_COMPUTE: -shaderobj 7//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj 8 9struct S 10{ 11 int2 a; 12 int2 b; 13 int2 c; 14} 15 16int test(int val) 17{ 18 S s = (S) 0; 19 20 s.a.x = val; 21 s.b.y = val; 22 s.c.x = val; 23 24 int2 t = s.a + s.b*256 + s.c*65536; 25 return t.x + t.y*16; 26} 27 28//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer 29RWStructuredBuffer<int> gOutputBuffer; 30 31[numthreads(4, 1, 1)] 32void computeMain(int3 tid : SV_DispatchThreadID) 33{ 34 int inVal = tid.x; 35 int outVal = test(inVal); 36 gOutputBuffer[tid.x] = outVal; 37}