yum-mirror/slang

Making it easier to work with shaders

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

Tim FoleyRemove old code paths from render-test (#1760)6e5d85efb

master
1.0 KiB35 linesraw
1//DISABLE_TEST:CPU_REFLECTION: -profile cs_5_0 -entry computeMain -target cpp 
2//DISABLED_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute
3
4struct IntAoa { RWStructuredBuffer<int> array[]; }
5
6//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer
7RWStructuredBuffer<int> outputBuffer;
8
9//TEST_INPUT:array(size=2):name g_aoa.array
10ParameterBlock<IntAoa> g_aoa;
11
12//TEST_INPUT:ubuffer(data=[1 2 3 4], stride=4):name=g_aoa.array[0]
13//TEST_INPUT:ubuffer(data=[8 17 34], stride=4):name=g_aoa.array[1]
14
15[numthreads(8, 1, 1)]
16void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
17{
18    int index = int(dispatchThreadID.x);
19    
20    int baseIndex = index >> 2;
21    int innerIndex = index & 3;
22
23    RWStructuredBuffer<int> buffer = g_aoa.array[NonUniformResourceIndex(baseIndex)];
24
25    // Get the size 
26    uint bufferCount, bufferStride;
27    buffer.GetDimensions(bufferCount, bufferStride);
28
29    if (innerIndex >= bufferCount)
30    {
31        innerIndex = bufferCount - 1;
32    }
33
34	outputBuffer[index] = buffer[innerIndex]; 
35}