yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
7758625d3
master
1// pointer-self-reference.slang 2 3// We are disabling this test because '&' is intentionally not supported. 4// Design for pointers in Slang are not yet finalized. 5//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type -shaderobj 6 7//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 8RWStructuredBuffer<int> outputBuffer; 9 10struct Thing 11{ 12 int value; 13 Ptr<Thing> next; 14}; 15 16[numthreads(4, 1, 1)] 17void computeMain(int3 dispatchThreadID: SV_DispatchThreadID) 18{ 19 int idx = dispatchThreadID.x; 20 21 Thing things[2]; 22 23 things[0].next = __getAddress(things[1]); 24 things[0].value = 27; 25 26 things[1].next = __getAddress(things[0]); 27 things[1].value = idx * idx; 28 29 Ptr<Thing> cur = __getAddress(things[0]); 30 31 for (int i = 0; cur && i < idx; ++i) 32 { 33 cur = cur.next; 34 } 35 36 int v = cur.value; 37 38 outputBuffer[idx] = v; 39}