yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
4ae6e9d8b
master
1// derived-struct-init-list.slang 2 3//TEST(compute):COMPARE_COMPUTE: 4//TEST(compute):COMPARE_COMPUTE: -vk -shaderobj 5 6// Test that use of an initializer list (especially 7// an empty initializer list) is still possible 8// when using `struct` inheritance. 9 10#pragma warning(disable:30816) 11 12struct Base 13{ 14 int a = 1; 15} 16 17struct Derived : Base 18{ 19 int b = 2; 20 21 void write(inout int val) { val = val*0x100 + a*0x10 + b; } 22} 23 24int test(int val) 25{ 26 Derived x = {}; 27 Derived y = { val, val+1 }; 28 29 int result = 1; 30 x.write(result); 31 y.write(result); 32 return result; 33} 34 35//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 36RWStructuredBuffer<int> outputBuffer; 37 38[numthreads(4, 1, 1)] 39void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) 40{ 41 int tid = dispatchThreadID.x; 42 int inVal = tid; 43 int outVal = test(inVal); 44 outputBuffer[tid] = outVal; 45}