Skip to content

Commit

Permalink
Adds BuiltIn::NumSubgroups, BuiltIn::SubgroupId.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Oct 14, 2023
1 parent f806246 commit 7008d27
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/back/glsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4205,6 +4205,7 @@ const fn glsl_built_in(
Bi::WorkGroupSize => "gl_WorkGroupSize",
Bi::NumWorkGroups => "gl_NumWorkGroups",
// subgroup
Bi::NumSubgroups | Bi::SubgroupId => todo!(),
Bi::SubgroupInvocationId => "gl_SubgroupInvocationID",
Bi::SubgroupSize => "gl_SubgroupSize",
}
Expand Down
1 change: 1 addition & 0 deletions src/back/hlsl/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ impl crate::BuiltIn {
// in `Writer::write_expr`.
Self::NumWorkGroups => "SV_GroupID",

Self::NumSubgroups | Self::SubgroupId => todo!(),
Self::SubgroupInvocationId
| Self::SubgroupSize
| Self::BaseInstance
Expand Down
1 change: 1 addition & 0 deletions src/back/msl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ impl ResolvedBinding {
Bi::WorkGroupSize => "dispatch_threads_per_threadgroup",
Bi::NumWorkGroups => "threadgroups_per_grid",
// subgroup
Bi::NumSubgroups | Bi::SubgroupId => todo!(),
Bi::SubgroupInvocationId => "simdgroup_index_in_threadgroup",
Bi::SubgroupSize => "simdgroups_per_threadgroup",
Bi::CullDistance | Bi::ViewIndex => {
Expand Down
1 change: 1 addition & 0 deletions src/back/spv/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1594,6 +1594,7 @@ impl Writer {
Bi::WorkGroupSize => BuiltIn::WorkgroupSize,
Bi::NumWorkGroups => BuiltIn::NumWorkgroups,
// Subgroup
Bi::NumSubgroups | Bi::SubgroupId => todo!(),
Bi::SubgroupInvocationId => {
self.require_any(
"`subgroup_invocation_id` built-in",
Expand Down
1 change: 1 addition & 0 deletions src/back/wgsl/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1794,6 +1794,7 @@ fn builtin_str(built_in: crate::BuiltIn) -> Result<&'static str, Error> {
Bi::SampleMask => "sample_mask",
Bi::PrimitiveIndex => "primitive_index",
Bi::ViewIndex => "view_index",
Bi::NumSubgroups | Bi::SubgroupId => todo!(),
Bi::SubgroupInvocationId => "subgroup_invocation_id",
Bi::SubgroupSize => "subgroup_size",
Bi::BaseInstance
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,8 @@ pub enum BuiltIn {
WorkGroupSize,
NumWorkGroups,
// subgroup
NumSubgroups,
SubgroupId,
SubgroupSize,
SubgroupInvocationId,
}
Expand Down
4 changes: 2 additions & 2 deletions src/valid/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,15 @@ impl VaryingContext<'_> {
width,
},
),
Bi::SubgroupInvocationId => (
Bi::NumSubgroups | Bi::SubgroupId => (
self.stage == St::Compute && !self.output,
*ty_inner
== Ti::Scalar {
kind: Sk::Uint,
width,
},
),
Bi::SubgroupSize => (
Bi::SubgroupSize | Bi::SubgroupInvocationId => (
match self.stage {
St::Compute | St::Fragment => !self.output,
St::Vertex => false,
Expand Down

0 comments on commit 7008d27

Please sign in to comment.