https://github.com/shader-slang/slang
Raw File
Tip revision: 926009a58315845b3a3a95e2724486a6c9e987ea authored by Tomáš Pazdiora on 10 May 2024, 01:17:38 UTC
fix typo (#4144)
Tip revision: 926009a
ssa-loop.slang
// ssa-loop.slang

// Bug related to SSA form for loops

//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj

int test(int val)
{
    int N = val;
    int x = 0;
    int y = 1;
    for(int i = 0; i < N; ++i)
    {
        int t = x;
        x = y;
        y = t;
    }
    return x*16 + y;
}

//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer
RWStructuredBuffer<int> gOutputBuffer;

[numthreads(4, 1, 1)]
void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
{
    int tid = dispatchThreadID.x;
    int inputVal = tid;
    int outputVal = test(inputVal);
    gOutputBuffer[tid] = outputVal;
}
back to top