summaryrefslogtreecommitdiff
path: root/tests/language-feature/defer/multiple-return.slang
blob: a364c288e9aeba99e6b6db7d9bb4c9bf63c89825 (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
//TEST(compute):COMPARE_COMPUTE: -shaderobj
//TEST(compute):COMPARE_COMPUTE: -vk -shaderobj
//DISABLE_TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj
// ^ Due to DeviceMemoryBarrier() missing.

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

void testFunc(int index1, int index2, int condition)
{
    outputBuffer[index1] = 128;
    defer outputBuffer[index1] = 0;

    outputBuffer[index2] = 3;
    DeviceMemoryBarrier();

    if (condition == 0)
    {
        outputBuffer[index2] = 1;
        return;
    }

    if (condition == 1)
    {
        outputBuffer[index2] = 2;
        return;
    }
}

[numthreads(1, 1, 1)]
void computeMain(int3 dispatchThreadID: SV_DispatchThreadID)
{
    for (int i = 0; i < 3; ++i)
        testFunc(2*i, 2*i+1, i);
}