yum-mirror/slang

Making it easier to work with shaders

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

Julius IkkalaAdd defer statement (#6619)1b82501dd

master
801 B34 linesraw
1//TEST(compute):COMPARE_COMPUTE: -shaderobj
2//TEST(compute):COMPARE_COMPUTE: -vk -shaderobj
3//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj
4
5//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0], stride=4):out,name=outputBuffer
6RWStructuredBuffer<int> outputBuffer;
7
8void testFunc(int i, int param)
9{
10    defer outputBuffer[i++] = param*3+2;
11    switch(param)
12    {
13    case 0:
14        defer outputBuffer[i++] = 1;
15        outputBuffer[i++] = 0;
16        break;
17    case 1:
18        defer outputBuffer[i++] = 4;
19        outputBuffer[i++] = 3;
20        break;
21    default:
22        defer outputBuffer[i++] = 7;
23        outputBuffer[i++] = 6;
24        break;
25    };
26}
27
28[numthreads(1, 1, 1)]
29void computeMain(int3 dispatchThreadID: SV_DispatchThreadID)
30{
31    testFunc(0, 0);
32    testFunc(3, 1);
33    testFunc(6, 2);
34}