yum-mirror/slang

Making it easier to work with shaders

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

amidescent[SPIR-V] Emit control flags for `branch/flatten` decorations (#8134)fc6aea374

master
613 B26 linesraw
1//TEST:SIMPLE(filecheck=HLSL): -target hlsl -profile cs_5_0 -entry computeMain
2//TEST:SIMPLE(filecheck=SPIRV): -target spirv -O0
3
4//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
5RWStructuredBuffer<int> outputBuffer;
6
7// HLSL: [branch]
8// SPIRV: OpSelectionMerge {{.*}} DontFlatten
9
10[numthreads(4, 1, 1)]
11void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
12{
13    int idx = dispatchThreadID.x;
14    
15    int v = idx;
16   
17   [branch]
18    switch (idx)
19    {
20        case 0: v ++; break;
21        case 2: v -= 7; break;
22        default: v--;
23    }
24
25	outputBuffer[dispatchThreadID.x] = v;
26}