yum-mirror/slang

Making it easier to work with shaders

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

ArielG-NVMove SPIRV global variables into a context variable (#4741)04e7327a2

master
984 B30 linesraw
1//TEST:SIMPLE(filecheck=CHECK): -target spirv -emit-spirv-directly -stage compute -entry computeMain -enable-experimental-passes
2
3// Check to ensure builtin is not moved into a kernelContext (part of entry-point). Ensure builtin is referenced directly.
4
5// CHECK: OpEntryPoint{{.*}} %val
6// CHECK: %[[GROUP_SHARED_VAR:(.*)]] = OpVariable{{.*}} Workgroup
7
8// CHECK: OpControlBarrier
9// CHECK: OpControlBarrier
10// CHECK-DAG: %[[GROUP_SHARED_VAL:(.*)]] = OpLoad{{.*}} %[[GROUP_SHARED_VAR]]
11// CHECK-DAG: %[[OUTPUT_BUFFER_LOC:(.*)]] = OpAccessChain{{.*}} %outputBuffer
12// CHECK: OpStore %[[OUTPUT_BUFFER_LOC]] %[[GROUP_SHARED_VAL]]
13
14groupshared uint val;
15RWStructuredBuffer<uint> outputBuffer;
16
17void nestedCall(uint index)
18{
19    val += 1;
20    GroupMemoryBarrierWithGroupSync();
21    outputBuffer[index] = val;
22}
23
24[numthreads(4, 1, 1)]
25void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
26{
27    val = 0;
28    GroupMemoryBarrierWithGroupSync();
29    nestedCall(dispatchThreadID.x);
30}