summaryrefslogtreecommitdiffstats
path: root/tests/hlsl/simple/rate-param.hlsl
blob: 5a36ba30edbcc4acd5bc0c8c5e8e86424b60ac68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// rate-param.slang
//DISABLE_TEST:SIMPLE: -target hlsl -entry computeMain -stage compute 

//TEST_INPUT:ubuffer(data=[0 0 0 0 ], stride=4):out,name outputBuffer
RWStructuredBuffer<int> outputBuffer;

groupshared uint gs_values[4];

void someFunction(inout groupshared uint a[4], int index, int value)
{
    a[index] += value;
}

[shader("compute")]
[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
    int index = (int)dispatchThreadID.x;
       
    // Initialize
    gs_values[3 - index] = index;   
       
    GroupMemoryBarrierWithGroupSync();
       
    someFunction(gs_values, index, index * 2 + 1);
       
    GroupMemoryBarrierWithGroupSync();
       
    outputBuffer[index] = gs_values[index];
}