yum-mirror/slang

Making it easier to work with shaders

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

Darren WihandiFix compilation of global builtin variables inside generics (#6701)1fa4e486f

master
1.2 KiB41 linesraw
1//TEST:SIMPLE(filecheck=CHECK_SPIRV): -entry main -stage compute -target spirv -allow-glsl
2//TEST:SIMPLE(filecheck=CHECK_GLSL): -entry main -stage compute -target glsl -allow-glsl
3//TEST:SIMPLE(filecheck=CHECK_HLSL): -entry main -stage compute -target hlsl -allow-glsl
4//TEST:SIMPLE(filecheck=CHECK_METAL): -entry main -stage compute -target metal -allow-glsl
5//TEST:SIMPLE(filecheck=CHECK_WGSL): -entry main -stage compute -target wgsl -allow-glsl
6
7RWStructuredBuffer<uint> outputBuffer;
8
9T getGlobalInvocationID<T: IInteger>(T value)
10{
11    return T(gl_GlobalInvocationID.x) + value;
12}
13
14T getWaveLaneIndex<T: IInteger>(T value)
15{
16    return T(WaveGetLaneIndex()) + value;
17}
18
19// CHECK_SPIRV: GlobalInvocationId
20// CHECK_SPIRV: SubgroupLocalInvocationId
21
22// CHECK_GLSL: gl_GlobalInvocationID
23// CHECK_GLSL: gl_SubgroupInvocationID
24
25// CHECK_HLSL: WaveGetLaneIndex()
26// CHECK_HLSL: SV_DispatchThreadID
27
28// CHECK_METAL: thread_position_in_grid
29// CHECK_METAL: thread_index_in_simdgroup
30
31// CHECK_WGSL: global_invocation_id
32// CHECK_WGSL: subgroup_invocation_id
33
34[shader("compute")]
35void main()
36{
37    outputBuffer[0U] = getGlobalInvocationID(0U);
38    outputBuffer[1U] = getWaveLaneIndex(0U);
39}
40
41