summaryrefslogtreecommitdiff
path: root/tests/metal/thread_position_in_threadgroup.slang
blob: a20fe2ec729c7edc3e1e56d0a59bc589780f0758 (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
//TEST:SIMPLE(filecheck=CHECK): -entry computeMain -stage compute -target metal -D GROUPID
//TEST:SIMPLE(filecheck=CHECK): -entry computeMain -stage compute -target metal

//CHECK: computeMain

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

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
{
    dst[GI + THREAD_COUNT] = GI;
    indirection(GI);
}