yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
7dabfa76c
master
1// default-initializer.slang 2 3// Confirm that a type with a default initializer gets 4// default-initialized where appropriate. 5 6//TEST(compute):COMPARE_COMPUTE: -shaderobj 7//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj 8 9struct Stuff 10{ 11 int value; 12 13 __init() 14 { 15 value = 16; 16 } 17} 18 19int test(int value) 20{ 21 Stuff s; 22 return value * s.value + value; 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}