yum-mirror/slang

Making it easier to work with shaders

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

Ellie HermaszewskaCorrectly pass values from the conditional block to the loop during inversion (#3311)da9e0adb5

master
766 B32 linesraw
1//TEST:SIMPLE(filecheck=CHECK): -stage compute -entry computeMain -target hlsl
2
3// Annoyingly, the reproducer for this doesn't terminate, so just check that we
4// succeeded compilation.
5// Previously, this would fail in SCCP after loop inversion failed to account
6// for condition variables being used in the loop.
7// CHECK: computeMain
8
9//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer
10RWStructuredBuffer<float> outputBuffer;
11
12[numthreads(1, 1, 1)]
13void computeMain(uint i : SV_GroupIndex)
14{
15    float x = 0;
16    f(x);
17    outputBuffer[i] = x;
18}
19
20void f(inout float r)
21{
22    r = 0;
23    float a = 0;
24    do {
25        do {
26            a = a + 1;
27            if (a > 0)
28                break;
29        } while (true);
30        r = a;
31    } while (true);
32}