@@ -63,6 +63,160 @@ pub enum GroupOperation {
6363 PartitionedExclusiveScanNV = 8 ,
6464}
6565
66+ /// The number of subgroups within the local workgroup. The value of this variable is at least 1, and is uniform across
67+ /// the invocation group.
68+ ///
69+ /// * GLSL: [`gl_NumSubgroups`](https://github.com/KhronosGroup/GLSL/blob/main/extensions/khr/GL_KHR_shader_subgroup.txt)
70+ /// * WGSL: [`num_subgroups`](https://www.w3.org/TR/WGSL/#num-subgroups-builtin-value)
71+ /// * SPIR-V: [`NumSubgroups`](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#_builtin)
72+ #[ doc( alias = "gl_NumSubgroups" ) ]
73+ #[ doc( alias = "WorkgroupId" ) ]
74+ #[ inline]
75+ #[ gpu_only]
76+ pub fn num_subgroups ( ) -> u32 {
77+ crate :: load_builtin!( NumSubgroups )
78+ }
79+
80+ /// The index of the subgroup within the local workgroup. The value of this variable is in the range `0` to
81+ /// [`num_subgroups`]`-1`.
82+ ///
83+ /// * GLSL: [`gl_SubgroupID`](https://github.com/KhronosGroup/GLSL/blob/main/extensions/khr/GL_KHR_shader_subgroup.txt)
84+ /// * WGSL: [`subgroup_id`](https://www.w3.org/TR/WGSL/#subgroup-id-builtin-value)
85+ /// * SPIR-V: [`SubgroupId`](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#_builtin)
86+ #[ doc( alias = "gl_SubgroupID" ) ]
87+ #[ doc( alias = "SubgroupId" ) ]
88+ #[ inline]
89+ #[ gpu_only]
90+ pub fn subgroup_id ( ) -> u32 {
91+ crate :: load_builtin!( SubgroupId )
92+ }
93+
94+ // custom: don't mention glsl extensions
95+ /// The number of invocations within a subgroup, and its value is always a power of 2. The maximum subgroup size
96+ /// supported is 128.
97+ ///
98+ /// * GLSL: [`gl_SubgroupSize`](https://github.com/KhronosGroup/GLSL/blob/main/extensions/khr/GL_KHR_shader_subgroup.txt)
99+ /// * WGSL: [`subgroup_size`](https://www.w3.org/TR/WGSL/#subgroup-size-builtin-value)
100+ /// * SPIR-V: [`SubgroupSize`](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#_builtin)
101+ #[ doc( alias = "gl_SubgroupSize" ) ]
102+ #[ doc( alias = "SubgroupId" ) ]
103+ #[ inline]
104+ #[ gpu_only]
105+ pub fn subgroup_size ( ) -> u32 {
106+ crate :: load_builtin!( SubgroupSize )
107+ }
108+
109+ /// The index of an invocation within a subgroup. The value of this variable is in the range `0` to
110+ /// [`subgroup_size`]`-1`.
111+ ///
112+ /// There is no direct relationship between [`subgroup_invocation_id`] and [`local_invocation_id`] or
113+ /// [`local_invocation_index`]. If the pipeline or shader object was created with full subgroups applications can
114+ /// compute their own local invocation index to serve the same purpose:
115+ ///
116+ /// index = SubgroupLocalInvocationId + SubgroupId × SubgroupSize
117+ ///
118+ /// If full subgroups are not enabled, some subgroups may be dispatched with inactive invocations that do not correspond
119+ /// to a local workgroup invocation, making the value of index unreliable.
120+ ///
121+ /// * GLSL: [`gl_SubgroupInvocationID`](https://github.com/KhronosGroup/GLSL/blob/main/extensions/khr/GL_KHR_shader_subgroup.txt)
122+ /// * WGSL: [`subgroup_invocation_id`](https://www.w3.org/TR/WGSL/#subgroup-invocation-id-builtin-value)
123+ /// * SPIR-V: [`SubgroupLocalInvocationId`](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#_builtin)
124+ ///
125+ /// [`local_invocation_id`]: crate::compute::local_invocation_id
126+ /// [`local_invocation_index`]: crate::compute::local_invocation_index
127+ #[ doc( alias = "gl_SubgroupInvocationID" ) ]
128+ #[ doc( alias = "SubgroupLocalInvocationId" ) ]
129+ #[ inline]
130+ #[ gpu_only]
131+ pub fn subgroup_invocation_id ( ) -> u32 {
132+ crate :: load_builtin!( SubgroupLocalInvocationId )
133+ }
134+
135+ /// Provides a bitmask of all invocations, with one bit per invocation, where `bit index == gl_SubgroupInvocationID`.
136+ ///
137+ /// Bit 0 of the first vector component represents the first invocation, higher-order bits within a component and higher
138+ /// component numbers both represent, in order, higher invocations, and the last invocation is the highest-order bit
139+ /// needed, in the last component needed, to contiguously represent all bits of the invocations in a subgroup.
140+ ///
141+ /// * GLSL: [`gl_SubgroupEqMask`](https://github.com/KhronosGroup/GLSL/blob/main/extensions/khr/GL_KHR_shader_subgroup.txt)
142+ /// * WGSL: None
143+ /// * SPIR-V: [`SubgroupEqMask`](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#_builtin)
144+ #[ doc( alias = "gl_SubgroupEqMask" ) ]
145+ #[ doc( alias = "SubgroupEqMask" ) ]
146+ #[ inline]
147+ #[ gpu_only]
148+ pub fn subgroup_eq_mask ( ) -> SubgroupMask {
149+ crate :: load_builtin!( SubgroupEqMask )
150+ }
151+
152+ /// Provides a bitmask of all invocations, with one bit per invocation, where `bit index >= gl_SubgroupInvocationID`.
153+ ///
154+ /// Bit 0 of the first vector component represents the first invocation, higher-order bits within a component and higher
155+ /// component numbers both represent, in order, higher invocations, and the last invocation is the highest-order bit
156+ /// needed, in the last component needed, to contiguously represent all bits of the invocations in a subgroup.
157+ ///
158+ /// * GLSL: [`gl_SubgroupGeMask`](https://github.com/KhronosGroup/GLSL/blob/main/extensions/khr/GL_KHR_shader_subgroup.txt)
159+ /// * WGSL: None
160+ /// * SPIR-V: [`SubgroupEqMask`](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#_builtin)
161+ #[ doc( alias = "gl_SubgroupGeMask" ) ]
162+ #[ doc( alias = "SubgroupGeMask" ) ]
163+ #[ inline]
164+ #[ gpu_only]
165+ pub fn subgroup_ge_mask ( ) -> SubgroupMask {
166+ crate :: load_builtin!( SubgroupGeMask )
167+ }
168+
169+ /// Provides a bitmask of all invocations, with one bit per invocation, where `bit index > gl_SubgroupInvocationID`.
170+ ///
171+ /// Bit 0 of the first vector component represents the first invocation, higher-order bits within a component and higher
172+ /// component numbers both represent, in order, higher invocations, and the last invocation is the highest-order bit
173+ /// needed, in the last component needed, to contiguously represent all bits of the invocations in a subgroup.
174+ ///
175+ /// * GLSL: [`gl_SubgroupGtMask`](https://github.com/KhronosGroup/GLSL/blob/main/extensions/khr/GL_KHR_shader_subgroup.txt)
176+ /// * WGSL: None
177+ /// * SPIR-V: [`SubgroupGtMask`](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#_builtin)
178+ #[ doc( alias = "gl_SubgroupGtMask" ) ]
179+ #[ doc( alias = "SubgroupGtMask" ) ]
180+ #[ inline]
181+ #[ gpu_only]
182+ pub fn subgroup_gt_mask ( ) -> SubgroupMask {
183+ crate :: load_builtin!( SubgroupGtMask )
184+ }
185+
186+ /// Provides a bitmask of all invocations, with one bit per invocation, where `bit index <= gl_SubgroupInvocationID`.
187+ ///
188+ /// Bit 0 of the first vector component represents the first invocation, higher-order bits within a component and higher
189+ /// component numbers both represent, in order, higher invocations, and the last invocation is the highest-order bit
190+ /// needed, in the last component needed, to contiguously represent all bits of the invocations in a subgroup.
191+ ///
192+ /// * GLSL: [`gl_SubgroupLeMask`](https://github.com/KhronosGroup/GLSL/blob/main/extensions/khr/GL_KHR_shader_subgroup.txt)
193+ /// * WGSL: None
194+ /// * SPIR-V: [`SubgroupLeMask`](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#_builtin)
195+ #[ doc( alias = "gl_SubgroupLeMask" ) ]
196+ #[ doc( alias = "SubgroupLeMask" ) ]
197+ #[ inline]
198+ #[ gpu_only]
199+ pub fn subgroup_le_mask ( ) -> SubgroupMask {
200+ crate :: load_builtin!( SubgroupLeMask )
201+ }
202+
203+ /// Provides a bitmask of all invocations, with one bit per invocation, where `bit index < gl_SubgroupInvocationID`.
204+ ///
205+ /// Bit 0 of the first vector component represents the first invocation, higher-order bits within a component and higher
206+ /// component numbers both represent, in order, higher invocations, and the last invocation is the highest-order bit
207+ /// needed, in the last component needed, to contiguously represent all bits of the invocations in a subgroup.
208+ ///
209+ /// * GLSL: [`gl_SubgroupLtMask`](https://github.com/KhronosGroup/GLSL/blob/main/extensions/khr/GL_KHR_shader_subgroup.txt)
210+ /// * WGSL: None
211+ /// * SPIR-V: [`SubgroupLtMask`](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#_builtin)
212+ #[ doc( alias = "gl_SubgroupLtMask" ) ]
213+ #[ doc( alias = "SubgroupLtMask" ) ]
214+ #[ inline]
215+ #[ gpu_only]
216+ pub fn subgroup_lt_mask ( ) -> SubgroupMask {
217+ crate :: load_builtin!( SubgroupLtMask )
218+ }
219+
66220/// The function `subgroupBarrier()` enforces that all active invocations within a
67221/// subgroup must execute this function before any are allowed to continue their
68222/// execution, and the results of any memory stores performed using coherent
0 commit comments