Skip to content

Commit a05c70c

Browse files
inner-daemonsjimblandyErichDonGublercwfitzgerald
authored
WGSL parsing for mesh shaders (#8370)
Co-authored-by: Jim Blandy <jimb@red-bean.com> Co-authored-by: Erich Gubler <erichdongubler@gmail.com> Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com> Co-authored-by: SupaMaggie70Incorporated <85136135+SupaMaggie70Incorporated@users.noreply.github.com>
1 parent dda99c9 commit a05c70c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+6023
-612
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ By @SupaMaggie70Incorporated in [#8206](https://github.com/gfx-rs/wgpu/pull/8206
142142
- The texture subresources used by the color attachments of a render pass are no longer allowed to overlap when accessed via different texture views. By @andyleiserson in [#8402](https://github.com/gfx-rs/wgpu/pull/8402).
143143
- The `STORAGE_READ_ONLY` texture usage is now permitted to coexist with other read-only usages. By @andyleiserson in [#8490](https://github.com/gfx-rs/wgpu/pull/8490).
144144
- Validate that buffers are unmapped in `write_buffer` calls. By @ErichDonGubler in [#8454](https://github.com/gfx-rs/wgpu/pull/8454).
145+
- Add WGSL parsing for mesh shaders. By @inner-daemons in [#8370](https://github.com/gfx-rs/wgpu/pull/8370).
145146

146147
#### DX12
147148

docs/api-specs/mesh_shading.md

Lines changed: 77 additions & 75 deletions
Large diffs are not rendered by default.

naga/src/back/dot/mod.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -307,25 +307,6 @@ impl StatementGraph {
307307
crate::RayQueryFunction::Terminate => "RayQueryTerminate",
308308
}
309309
}
310-
S::MeshFunction(crate::MeshFunction::SetMeshOutputs {
311-
vertex_count,
312-
primitive_count,
313-
}) => {
314-
self.dependencies.push((id, vertex_count, "vertex_count"));
315-
self.dependencies
316-
.push((id, primitive_count, "primitive_count"));
317-
"SetMeshOutputs"
318-
}
319-
S::MeshFunction(crate::MeshFunction::SetVertex { index, value }) => {
320-
self.dependencies.push((id, index, "index"));
321-
self.dependencies.push((id, value, "value"));
322-
"SetVertex"
323-
}
324-
S::MeshFunction(crate::MeshFunction::SetPrimitive { index, value }) => {
325-
self.dependencies.push((id, index, "index"));
326-
self.dependencies.push((id, value, "value"));
327-
"SetPrimitive"
328-
}
329310
S::SubgroupBallot { result, predicate } => {
330311
if let Some(predicate) = predicate {
331312
self.dependencies.push((id, predicate, "predicate"));

naga/src/back/glsl/mod.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2675,11 +2675,6 @@ impl<'a, W: Write> Writer<'a, W> {
26752675
self.write_image_atomic(ctx, image, coordinate, array_index, fun, value)?
26762676
}
26772677
Statement::RayQuery { .. } => unreachable!(),
2678-
Statement::MeshFunction(
2679-
crate::MeshFunction::SetMeshOutputs { .. }
2680-
| crate::MeshFunction::SetVertex { .. }
2681-
| crate::MeshFunction::SetPrimitive { .. },
2682-
) => unreachable!(),
26832678
Statement::SubgroupBallot { result, predicate } => {
26842679
write!(self.out, "{level}")?;
26852680
let res_name = Baked(result).to_string();
@@ -5270,7 +5265,11 @@ const fn glsl_built_in(built_in: crate::BuiltIn, options: VaryingOptions) -> &'s
52705265
| Bi::PointIndex
52715266
| Bi::LineIndices
52725267
| Bi::TriangleIndices
5273-
| Bi::MeshTaskSize => {
5268+
| Bi::MeshTaskSize
5269+
| Bi::VertexCount
5270+
| Bi::PrimitiveCount
5271+
| Bi::Vertices
5272+
| Bi::Primitives => {
52745273
unimplemented!()
52755274
}
52765275
}

naga/src/back/hlsl/conv.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,11 @@ impl crate::BuiltIn {
187187
}
188188
Self::CullPrimitive => "SV_CullPrimitive",
189189
Self::PointIndex | Self::LineIndices | Self::TriangleIndices => unimplemented!(),
190-
Self::MeshTaskSize => unreachable!(),
190+
Self::MeshTaskSize
191+
| Self::VertexCount
192+
| Self::PrimitiveCount
193+
| Self::Vertices
194+
| Self::Primitives => unreachable!(),
191195
})
192196
}
193197
}

naga/src/back/hlsl/writer.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2608,19 +2608,6 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
26082608
writeln!(self.out, ".Abort();")?;
26092609
}
26102610
},
2611-
Statement::MeshFunction(crate::MeshFunction::SetMeshOutputs {
2612-
vertex_count,
2613-
primitive_count,
2614-
}) => {
2615-
write!(self.out, "{level}SetMeshOutputCounts(")?;
2616-
self.write_expr(module, vertex_count, func_ctx)?;
2617-
write!(self.out, ", ")?;
2618-
self.write_expr(module, primitive_count, func_ctx)?;
2619-
write!(self.out, ");")?;
2620-
}
2621-
Statement::MeshFunction(
2622-
crate::MeshFunction::SetVertex { .. } | crate::MeshFunction::SetPrimitive { .. },
2623-
) => unimplemented!(),
26242611
Statement::SubgroupBallot { result, predicate } => {
26252612
write!(self.out, "{level}")?;
26262613
let name = Baked(result).to_string();

naga/src/back/msl/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,11 @@ impl ResolvedBinding {
714714
Bi::CullPrimitive => "primitive_culled",
715715
// TODO: figure out how to make this written as a function call
716716
Bi::PointIndex | Bi::LineIndices | Bi::TriangleIndices => unimplemented!(),
717-
Bi::MeshTaskSize => unreachable!(),
717+
Bi::MeshTaskSize
718+
| Bi::VertexCount
719+
| Bi::PrimitiveCount
720+
| Bi::Vertices
721+
| Bi::Primitives => unreachable!(),
718722
};
719723
write!(out, "{name}")?;
720724
}

naga/src/back/msl/writer.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4063,14 +4063,6 @@ impl<W: Write> Writer<W> {
40634063
}
40644064
}
40654065
}
4066-
// TODO: write emitters for these
4067-
crate::Statement::MeshFunction(crate::MeshFunction::SetMeshOutputs { .. }) => {
4068-
unimplemented!()
4069-
}
4070-
crate::Statement::MeshFunction(
4071-
crate::MeshFunction::SetVertex { .. }
4072-
| crate::MeshFunction::SetPrimitive { .. },
4073-
) => unimplemented!(),
40744066
crate::Statement::SubgroupBallot { result, predicate } => {
40754067
write!(self.out, "{level}")?;
40764068
let name = self.namer.call("");

naga/src/back/pipeline_constants.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -860,26 +860,6 @@ fn adjust_stmt(new_pos: &HandleVec<Expression, Handle<Expression>>, stmt: &mut S
860860
crate::RayQueryFunction::Terminate => {}
861861
}
862862
}
863-
Statement::MeshFunction(crate::MeshFunction::SetMeshOutputs {
864-
ref mut vertex_count,
865-
ref mut primitive_count,
866-
}) => {
867-
adjust(vertex_count);
868-
adjust(primitive_count);
869-
}
870-
Statement::MeshFunction(
871-
crate::MeshFunction::SetVertex {
872-
ref mut index,
873-
ref mut value,
874-
}
875-
| crate::MeshFunction::SetPrimitive {
876-
ref mut index,
877-
ref mut value,
878-
},
879-
) => {
880-
adjust(index);
881-
adjust(value);
882-
}
883863
Statement::Break
884864
| Statement::Continue
885865
| Statement::Kill

naga/src/back/spv/block.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3655,7 +3655,6 @@ impl BlockContext<'_> {
36553655
} => {
36563656
self.write_subgroup_gather(mode, argument, result, &mut block)?;
36573657
}
3658-
Statement::MeshFunction(_) => unreachable!(),
36593658
}
36603659
}
36613660

0 commit comments

Comments
 (0)