yum-mirror/slang

Making it easier to work with shaders

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

Tim FoleyIntroduce an IR-level type system (#481)baf194e74

master
1.1 KiB43 linesraw
1//TEST_DISABLED:SIMPLE:-dump-ir -profile cs_5_0 -entry main
2
3// Note: disabling this test for now because
4// the actual IR that gets dumped is not very
5// stable with code generation changes going on,
6// and we already have more significant tests
7// that stress the IR functionality.
8//
9// We should consider removing this test, or
10// else work to ensure that "canonical" IR
11// output is more consistent.
12
13#define GROUP_THREAD_COUNT 64
14
15StructuredBuffer<float4> input;
16RWStructuredBuffer<float4> output;
17
18groupshared float4 s[GROUP_THREAD_COUNT];
19
20[numthreads(GROUP_THREAD_COUNT, 1, 1)]
21void main(
22    uint dispatchThreadID   : SV_DispatchThreadID,
23    uint groupThreadID      : SV_GroupThreadID,
24    uint groupID            : SV_GroupIndex )
25{
26    // the actual algorithm being done here is bogus
27
28    // load shared memory
29    s[groupThreadID] = input[dispatchThreadID];
30
31    // do some sum passes
32    for(uint stride = 1; stride < GROUP_THREAD_COUNT; stride <<= 1)
33    {
34        GroupMemoryBarrierWithGroupSync();
35
36        s[groupThreadID] += s[groupThreadID - stride];
37    }
38
39    GroupMemoryBarrierWithGroupSync();
40
41    output[dispatchThreadID] = s[0];
42}
43