forked from shader-slang/slang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshader-subgroup-builtin-variables-2.slang
36 lines (28 loc) · 1.34 KB
/
shader-subgroup-builtin-variables-2.slang
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
28
29
30
31
32
33
34
35
36
//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl
//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -emit-spirv-directly
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-wgpu -compute -entry computeMain -allow-glsl
// TODO: There are some issues with the Metal backend when using glsl-style syntax, test is disabled for now.
//DISABLE_TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-metal -compute -entry computeMain -allow-glsl
#version 430
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
buffer MyBlockName2
{
int data[];
} outputBuffer;
layout(local_size_x = 4) in;
void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
{
// There may be some issues with structure padding for global context containing
// global builtin variables.
// int idx = gl_GlobalInvocationID.x;
int idx = dispatchThreadID.x;
uint laneId = gl_SubgroupInvocationID;
// The laneCount will be dependent on target hardware. It seems a count of 1 is valid in spec.
// For now we'll just check it's not 0.
uint laneCount = gl_SubgroupSize;
outputBuffer.data[idx] = int(((laneCount > 0) ? 0x100 : 0) + laneId);
// BUF: 100
// BUF-NEXT: 101
// BUF-NEXT: 102
// BUF-NEXT: 103
}