summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source/slang/hlsl.meta.slang18
-rw-r--r--source/slang/slang-capabilities.capdef5
-rw-r--r--tests/hlsl-intrinsic/helper-lane.slang20
3 files changed, 43 insertions, 0 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang
index c01265369..82ef5837e 100644
--- a/source/slang/hlsl.meta.slang
+++ b/source/slang/hlsl.meta.slang
@@ -14949,6 +14949,24 @@ matrix<T,N,M> WaveMultiPrefixSum(matrix<T,N,M> value, uint4 mask)
}
}
+__glsl_extension(GL_EXT_demote_to_helper_invocation)
+[ForceInline]
+[require(glsl_hlsl_metal_spirv, helper_lane)]
+bool IsHelperLane()
+{
+ __target_switch {
+ case hlsl: __intrinsic_asm "IsHelperLane()";
+ case glsl: __intrinsic_asm "gl_HelperInvocation";
+ case metal: __intrinsic_asm "simd_is_helper_thread()";
+ case spirv:
+ return spirv_asm {
+ OpExtension "SPV_EXT_demote_to_helper_invocation";
+ OpCapability DemoteToHelperInvocationEXT;
+ result:$$bool = OpIsHelperInvocationEXT
+ };
+ }
+}
+
// `typedef`s to help with the fact that HLSL has been sorta-kinda case insensitive at various points
typedef Texture2D texture2D;
diff --git a/source/slang/slang-capabilities.capdef b/source/slang/slang-capabilities.capdef
index d003e4f41..b011021bc 100644
--- a/source/slang/slang-capabilities.capdef
+++ b/source/slang/slang-capabilities.capdef
@@ -817,6 +817,11 @@ alias atomic_glsl_hlsl_nvapi_cuda9_int64 = atomic_glsl_int64 | hlsl_nvapi + _sm_
alias atomic_glsl_hlsl_cuda = atomic_glsl | _sm_5_0 | _cuda_sm_2_0;
alias atomic_glsl_hlsl_cuda9_int64 = atomic_glsl_int64 | _sm_6_6 | _cuda_sm_9_0;
+alias helper_lane = _sm_6_0 + fragment
+ | GL_EXT_demote_to_helper_invocation + fragment
+ | metal + fragment
+ ;
+
alias breakpoint = GL_EXT_debug_printf | hlsl | _cuda_sm_8_0 | cpp;
alias raytracing_allstages = raytracing_stages + raytracing;
diff --git a/tests/hlsl-intrinsic/helper-lane.slang b/tests/hlsl-intrinsic/helper-lane.slang
new file mode 100644
index 000000000..316bda5f9
--- /dev/null
+++ b/tests/hlsl-intrinsic/helper-lane.slang
@@ -0,0 +1,20 @@
+//TEST:SIMPLE(filecheck=HLSL): -entry main -target hlsl -stage fragment
+//TEST:SIMPLE(filecheck=GLSL): -entry main -target glsl -stage fragment
+//TEST:SIMPLE(filecheck=METAL): -entry main -target metal -stage fragment
+//TEST:SIMPLE(filecheck=SPIRV): -entry main -target spirv -stage fragment
+//TEST:SIMPLE(filecheck=SPIRV): -entry main -target spirv-asm -stage fragment
+
+float4 main() : SV_Target
+{
+ //HLSL: IsHelperLane()
+
+ //GLSL: GL_EXT_demote_to_helper_invocation
+ //GLSL: gl_HelperInvocation()
+
+ //METAL: simd_is_helper_thread()
+
+ //SPIRV: DemoteToHelperInvocation
+ //SPIRV: SPV_EXT_demote_to_helper_invocation
+ //SPIRV: OpIsHelperInvocationEXT
+ return float4(IsHelperLane());
+}