summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/defer/switch.slang
blob: 704e6e8842f85c1052cd0040c9c1a8415eafb8ea (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
//TEST(compute):COMPARE_COMPUTE: -shaderobj
//TEST(compute):COMPARE_COMPUTE: -vk -shaderobj
//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj

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

void testFunc(int i, int param)
{
    defer outputBuffer[i++] = param*3+2;
    switch(param)
    {
    case 0:
        defer outputBuffer[i++] = 1;
        outputBuffer[i++] = 0;
        break;
    case 1:
        defer outputBuffer[i++] = 4;
        outputBuffer[i++] = 3;
        break;
    default:
        defer outputBuffer[i++] = 7;
        outputBuffer[i++] = 6;
        break;
    };
}

[numthreads(1, 1, 1)]
void computeMain(int3 dispatchThreadID: SV_DispatchThreadID)
{
    testFunc(0, 0);
    testFunc(3, 1);
    testFunc(6, 2);
}