yum-mirror/slang

Making it easier to work with shaders

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

Yong HeEliminate `continue` to allow unrolling any loops. (#2645)977eb925b

master
600 B23 linesraw
1//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
2//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
3
4//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
5RWStructuredBuffer<uint> outputBuffer;
6
7[numthreads(1, 1, 1)]
8void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID)
9{
10    int sum = 0;
11    [ForceUnroll]
12    for (int i = 0; i < 2; i++)
13    {
14        [ForceUnroll(2)]
15        for (int j = 1; j < 3; j++)
16        {
17            if (i == 1 && j == 1)
18                continue;
19            sum += (i+j);
20        }
21    }
22    outputBuffer[0] = sum;
23}