summaryrefslogtreecommitdiffstats
path: root/tests/metal/thread_position_in_threadgroup.slang
blob: c8494c4ed4e4c6783f2c96a504754ce36bc604e5 (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
31
32
33
34
35
36
37
//TEST:SIMPLE(filecheck=METAL): -entry computeMain -stage compute -target metal -D GROUPID
//TEST:SIMPLE(filecheck=METAL): -entry computeMain -stage compute -target metal
//DISABLE_TEST(compute, metal):COMPARE_COMPUTE(filecheck-buffer=BUF):-metal -compute -entry computeMain -output-using-type
//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -output-using-type

// Compute test disabled; Buffer isn't handled by the test infrastructure
// TODO: github issue #8456

//METAL: computeMain

// ensure we compute the SV_GroupIndex from SV_GroupThreadID and `numthreads`
// METAL: thread_position_in_threadgroup
// METAL-DAG: *{{.*}}2

//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):out,name dst
RWBuffer<uint> dst;

void indirection(uint groupIndex)
{
    dst[groupIndex] = groupIndex;
}

#define THREAD_COUNT 2
[numthreads(THREAD_COUNT, 1, 1)]
#ifdef GROUPID
void computeMain(uint GI : SV_GroupIndex, uint GTID : SV_GroupThreadID)
#else
void computeMain(uint GI : SV_GroupIndex)
#endif
{
    // BUF: 0
    // BUF: 1
    dst[GI + THREAD_COUNT] = GI;
    // BUF: 0
    // BUF: 1
    indirection(GI);
}