From ed5940a629ae05e9571bfe355d22f0728347dcb4 Mon Sep 17 00:00:00 2001 From: Darren Wihandi <65404740+fairywreath@users.noreply.github.com> Date: Tue, 22 Apr 2025 14:04:56 -0600 Subject: Implement shader subgroup rotate intrinsics (#6878) * Initial implementation for SPIRV, GLSL and Metal * test add bool test * Fix and improve subgroup rotate tests * Add proper GLSL extensions and proper Metal type checking * Clean up tests and add diagnostics test for subgroup type for Metal * Update wave-intrinsics docs --- docs/user-guide/a3-02-reference-capability-atoms.md | 12 ++++++++++++ docs/wave-intrinsics.md | 14 ++++++++++++++ 2 files changed, 26 insertions(+) (limited to 'docs') diff --git a/docs/user-guide/a3-02-reference-capability-atoms.md b/docs/user-guide/a3-02-reference-capability-atoms.md index 296614716..a9455761c 100644 --- a/docs/user-guide/a3-02-reference-capability-atoms.md +++ b/docs/user-guide/a3-02-reference-capability-atoms.md @@ -407,6 +407,9 @@ Extensions `SPV_NV_shader_subgroup_partitioned` > Represents the SPIR-V extension for shader subgroup partitioned. +`SPV_KHR_subgroup_rotate` +> Represents the SPIR-V extension enables rotating values across invocations within a subgroup. + `SPV_NV_ray_tracing_motion_blur` > Represents the SPIR-V extension for ray tracing motion blur. @@ -501,6 +504,9 @@ Extensions `spvGroupNonUniformPartitionedNV` > Represents the SPIR-V capability for group non-uniform partitioned operations. +`spvGroupNonUniformRotateKHR` +> Represents the SPIR-V capability for group non-uniform rotate operations. + `spvRayTracingMotionBlurNV` > Represents the SPIR-V capability for ray tracing motion blur. @@ -699,6 +705,9 @@ Extensions `GL_KHR_shader_subgroup_vote` > Represents the GL_KHR_shader_subgroup_vote extension. +`GL_KHR_shader_subgroup_rotate` +> Represents the GL_KHR_shader_subgroup_rotate extension. + `GL_NV_compute_shader_derivatives` > Represents the GL_NV_compute_shader_derivatives extension. @@ -1132,6 +1141,9 @@ Compound Capabilities `subgroup_partitioned` > Capabilities required to use GLSL-style subgroup operations 'subgroup_partitioned' +`subgroup_rotate` +> Capabilities required to use GLSL-style subgroup rotate operations 'subgroup_rotate' + `atomic_glsl_hlsl_nvapi_cuda_metal_float1` > (All implemented targets) Capabilities required to use atomic operations of GLSL tier-1 float atomics diff --git a/docs/wave-intrinsics.md b/docs/wave-intrinsics.md index aa46f72a1..7f6fb7b77 100644 --- a/docs/wave-intrinsics.md +++ b/docs/wave-intrinsics.md @@ -236,6 +236,20 @@ void GroupMemoryBarrierWithWaveSync(); Synchronizes all lanes to the same GroupMemoryBarrierWithWaveSync in program flow. Orders group shared memory accesses such that accesses after the barrier can be seen by writes before. +Wave Rotate Intrinsics +====================== + +These intrinsics are specific to Slang and were added to support the subgroup rotate functionalities provided by SPIRV (through the `GroupNonUniformRotateKHR` capability), GLSL (through the `GL_KHR_shader_subgroup_rotate +` extension), and Metal. + +``` +// Supported on SPIRV, GLSL, and Metal targets. +T WaveRotate(T value, uint delta); + +// Supported on SPIRV and GLSL targets. +T WaveClusteredRotate(T value, uint delta, constexpr uint clusterSize); +``` + Wave Mask Intrinsics ==================== -- cgit v1.2.3