yum-mirror/slang

Making it easier to work with shaders

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

Yong HeFix IntVal unification logic to insert type casts + buffer element lowering regression. (#5508)989847f6a

master
1.3 KiB54 linesraw
1//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF): -shaderobj -output-using-type
2//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF): -vk -shaderobj -output-using-type
3//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF): -vk -emit-spirv-directly -shaderobj -output-using-type
4//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF):-slang -shaderobj -mtl
5
6//TEST_INPUT:ubuffer(data=[0 0], stride=4):out,name outputBuffer
7RWStructuredBuffer<uint> outputBuffer;
8
9static groupshared uint g_values[2];
10static uint g_altValues[2] = { 2, 3 };
11
12static groupshared uint g_valuesReturned[2];
13static uint g_altValuesReturned[2];
14
15uint[2] maybeGroupSharedReturn(uint id)
16{
17    if (id == 0)
18    {
19        return g_values;
20    }
21    else
22    {
23        return g_altValues;
24    }
25}
26
27[numthreads(2, 1, 1)]
28void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
29{
30    g_values = { 1, 0 };
31    AllMemoryBarrierWithGroupSync();
32    uint tid = dispatchThreadID.x;
33    if (tid == 0)
34    {
35        g_valuesReturned[tid] = maybeGroupSharedReturn(tid)[tid];
36    }
37    else
38    {
39        g_altValuesReturned[tid] = maybeGroupSharedReturn(tid)[tid];
40    }
41
42    AllMemoryBarrierWithGroupSync();
43    if (tid == 0)
44    {
45        outputBuffer[tid] = g_valuesReturned[tid];
46    }
47    else
48    {
49        outputBuffer[tid] = g_altValuesReturned[tid];
50    }
51
52    // BUF: 1
53    // BUF: 3
54}