yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

skallweitNVenable more metal tests (#4326)712ce653d

master
631 B31 linesraw
1// ssa-loop.slang
2
3// Bug related to SSA form for loops
4
5//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
6
7int test(int val)
8{
9    int N = val;
10    int x = 0;
11    int y = 1;
12    for(int i = 0; i < N; ++i)
13    {
14        int t = x;
15        x = y;
16        y = t;
17    }
18    return x*16 + y;
19}
20
21//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer
22RWStructuredBuffer<int> gOutputBuffer;
23
24[numthreads(4, 1, 1)]
25void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
26{
27    int tid = dispatchThreadID.x;
28    int inputVal = tid;
29    int outputVal = test(inputVal);
30    gOutputBuffer[tid] = outputVal;
31}