summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/defer/complex-block.slang
blob: c2d232035a1ba94be935d19e041dc6ad4e509771 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//TEST(compute):COMPARE_COMPUTE: -shaderobj
//TEST(compute):COMPARE_COMPUTE: -vk -shaderobj
//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj

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

[numthreads(1, 1, 1)]
void computeMain(int3 dispatchThreadID: SV_DispatchThreadID)
{
    int i = 0;
    int j = 0;
    defer {
        if (j == 2)
        {
            outputBuffer[i++] = j;
        }
        else
        {
            outputBuffer[i++] = 2048;
        }
    }
    defer {
        if (j == 1)
        {
            outputBuffer[i++] = j;
        }
        else
        {
            outputBuffer[i++] = 1024;
        }
        j++;
    }
    outputBuffer[i++] = j;
    j++;
}