yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
712ce653d
master
1//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type 2 3// Confirm that a SideEffectFree mutable method does not get DCE'd when 4// it is called from within a loop. 5 6struct C 7{ 8 int a; 9 [mutating] 10 int add() 11 { 12 a++; 13 return a; 14 } 15 [mutating] 16 void init() 17 { 18 a = 0; 19 } 20} 21int doSomething(C d_in) 22{ 23 C d = d_in; 24 int rs = 0; 25 for (int i = 0; i < 10; i++) 26 rs = d.add(); 27 return rs; 28} 29 30//TEST_INPUT:ubuffer(data=[0], stride=4):out, name outputBuffer 31RWStructuredBuffer<int> outputBuffer; 32 33[numthreads(1, 1, 1)] 34void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) 35{ 36 int tid = dispatchThreadID.x; 37 C c; 38 c.init(); 39 outputBuffer[tid] = doSomething(c); 40}