Skip to content

Commit 07bd6b7

Browse files
committed
update test and glsl support
1 parent dd7e4f9 commit 07bd6b7

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

source/slang/glsl.meta.slang

+5-3
Original file line numberDiff line numberDiff line change
@@ -6334,7 +6334,7 @@ void requireGLSLExtForSubgroupBasicBuiltin() {
63346334
}
63356335
}
63366336

6337-
[require(cpp_cuda_glsl_hlsl_spirv_wgsl, subgroup_basic)]
6337+
[require(cpp_cuda_glsl_hlsl_metal_spirv_wgsl, subgroup_basic)]
63386338
void setupExtForSubgroupBasicBuiltIn() {
63396339
__target_switch
63406340
{
@@ -6409,7 +6409,8 @@ public property uint gl_SubgroupID
64096409

64106410
public property uint gl_SubgroupSize
64116411
{
6412-
[require(cpp_cuda_glsl_hlsl_spirv_wgsl, subgroup_basic)]
6412+
[ForceInline]
6413+
[require(cpp_cuda_glsl_hlsl_metal_spirv_wgsl, subgroup_basic)]
64136414
get {
64146415
setupExtForSubgroupBasicBuiltIn();
64156416
return WaveGetLaneCount();
@@ -6418,7 +6419,8 @@ public property uint gl_SubgroupSize
64186419

64196420
public property uint gl_SubgroupInvocationID
64206421
{
6421-
[require(cpp_cuda_glsl_hlsl_spirv_wgsl, subgroup_basic)]
6422+
[ForceInline]
6423+
[require(cpp_cuda_glsl_hlsl_metal_spirv_wgsl, subgroup_basic)]
64226424
get {
64236425
setupExtForSubgroupBasicBuiltIn();
64246426
return WaveGetLaneIndex();

tests/glsl-intrinsic/shader-subgroup/shader-subgroup-builtin-variables.slang

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//TEST:SIMPLE(filecheck=CHECK_GLSL): -allow-glsl -stage compute -entry computeMain -target glsl
2-
//TEST:SIMPLE(filecheck=CHECK_SPV): -allow-glsl -stage compute -entry computeMain -target spirv -emit-spirv-directly
1+
//TEST:SIMPLE(filecheck=CHECK_GLSL): -allow-glsl -stage compute -entry computeMain -target glsl -DTARGET_VK
2+
//TEST:SIMPLE(filecheck=CHECK_SPV): -allow-glsl -stage compute -entry computeMain -target spirv -emit-spirv-directly -DTARGET_VK
33

44
// missing implementation of most builtin values due to non trivial translation
55
//DISABLE_TEST:SIMPLE(filecheck=CHECK_HLSL): -allow-glsl -stage compute -entry computeMain -target hlsl -DTARGET_HLSL
@@ -8,8 +8,11 @@
88
//missing implementation of system (varying?) values
99
//DISABLE_TEST:SIMPLE(filecheck=CHECK_CPP): -allow-glsl -stage compute -entry computeMain -target cpp -DTARGET_CPP
1010

11-
//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl
12-
//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -emit-spirv-directly
11+
//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -xslang -DTARGET_VK
12+
//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -emit-spirv-directly -xslang -DTARGET_VK
13+
//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-wgpu -compute -entry computeMain -allow-glsl
14+
//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-metal -compute -entry computeMain -allow-glsl
15+
1316
#version 430
1417

1518
//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer
@@ -24,15 +27,17 @@ void computeMain()
2427
{
2528
if (gl_GlobalInvocationID.x == 3) {
2629
outputBuffer.data[0] = true
27-
&& gl_NumSubgroups == 1
28-
&& gl_SubgroupID == 0 //1 subgroup, 0 based indexing
2930
&& gl_SubgroupSize == 32
3031
&& gl_SubgroupInvocationID == 3
32+
#if defined(TARGET_VK)
33+
&& gl_SubgroupID == 0 //1 subgroup, 0 based indexing
34+
&& gl_NumSubgroups == 1
3135
&& gl_SubgroupEqMask == uvec4(0b1000,0,0,0)
3236
&& gl_SubgroupGeMask == uvec4(0xFFFFFFF8,0,0,0)
3337
&& gl_SubgroupGtMask == uvec4(0xFFFFFFF0,0,0,0)
3438
&& gl_SubgroupLeMask == uvec4(0b1111,0,0,0)
3539
&& gl_SubgroupLtMask == uvec4(0b111,0,0,0)
40+
#endif
3641
;
3742
}
3843
// CHECK_GLSL: void main(

tests/hlsl-intrinsic/quad-control/quad-control-comp-functionality.slang

-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ RWStructuredBuffer<uint> outputBuffer;
88
[numthreads(16, 1, 1)]
99
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
1010
{
11-
#if !defined(METAL)
1211
uint index = WaveGetLaneIndex();
13-
#else
14-
uint index = dispatchThreadID.x;
15-
#endif
1612

1713
if (index < 4)
1814
{

tests/hlsl-intrinsic/wave-get-lane-index.slang

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
//TEST:COMPARE_COMPUTE_EX:-slang -compute -dx12 -use-dxil -profile cs_6_0 -shaderobj
55
//TEST(vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
66
//TEST:COMPARE_COMPUTE_EX:-cuda -compute -shaderobj
7+
//TEST:COMPARE_COMPUTE_EX:-wgpu -compute -shaderobj
8+
//TEST:COMPARE_COMPUTE_EX:-metal -compute -shaderobj
79

810
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
911
RWStructuredBuffer<int> outputBuffer;
@@ -17,4 +19,4 @@ void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
1719
// For now we'll just check it's not 0.
1820
uint laneCount = WaveGetLaneCount();
1921
outputBuffer[idx] = int(((laneCount > 0) ? 0x100 : 0) + laneId);
20-
}
22+
}

0 commit comments

Comments
 (0)