summaryrefslogtreecommitdiffstats
path: root/tests/bugs/branch-switch-attribute.slang
blob: 5fe82b7e4d4b53f379dc0ee2e9fe07b36ce540e1 (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
//TEST:SIMPLE(filecheck=HLSL): -target hlsl -profile cs_5_0 -entry computeMain
//TEST:SIMPLE(filecheck=SPIRV): -target spirv -O0

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

// HLSL: [branch]
// SPIRV: OpSelectionMerge {{.*}} DontFlatten

[numthreads(4, 1, 1)]
void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
{
    int idx = dispatchThreadID.x;
    
    int v = idx;
   
   [branch]
    switch (idx)
    {
        case 0: v ++; break;
        case 2: v -= 7; break;
        default: v--;
    }

	outputBuffer[dispatchThreadID.x] = v;
}