diff options
| author | ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> | 2024-06-14 01:29:35 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-13 22:29:35 -0700 |
| commit | 2cc96907e4152291e0b6bca78a0bfbc69ddb8839 (patch) | |
| tree | c5ebf1cc6afc99d2058c673e79b1fef2d60f5f46 /tests/metal/thread_position_in_threadgroup.slang | |
| parent | a6b8348f69a4cd1ab1edbc1ccf1133c807b81b5b (diff) | |
Implement for metal `SV_GroupIndex` (#4385)
* Implement for metal `SV_GroupIndex`
1. If we don't have `sv_GroupThreadId` available we create one using `SV_GroupIndex`s location data.
2. We emit code emulating `sv_GroupThreadId` from the same logic that CUDA/CPP uses.
* address most review comments
Addressed all but two: [1](https://github.com/shader-slang/slang/pull/4385#discussion_r1639058473) and [2](https://github.com/shader-slang/slang/pull/4385#issuecomment-2166934855)
I want to enable tests and be sure there is no bugs using CI before I redesign the code so I have a working fallback.
* address comment, enable tests
enable now functioning tests due to `SV_GroupIndex` working with metal
* syntax error with groupThreadID search
did `= param` instead of `= i.param`
* add `sv_groupid` for test + test fixes
* disable test that won't work regardless
Diffstat (limited to 'tests/metal/thread_position_in_threadgroup.slang')
| -rw-r--r-- | tests/metal/thread_position_in_threadgroup.slang | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/metal/thread_position_in_threadgroup.slang b/tests/metal/thread_position_in_threadgroup.slang new file mode 100644 index 000000000..a20fe2ec7 --- /dev/null +++ b/tests/metal/thread_position_in_threadgroup.slang @@ -0,0 +1,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); +}
\ No newline at end of file |
