-
Notifications
You must be signed in to change notification settings - Fork 1.1k
WGSL parsing for mesh shaders #8370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
WGSL parsing for mesh shaders #8370
Conversation
…paction, made clippy happy
|
@cwfitzgerald This PR still needs some cleanup, in terms of making the code easier to read and updating the spec, but I think this represents what I imagine the approach to mesh shaders & WGSL would look like (see |
|
No promises before the 12th ofc but I should be able to get to it before then |
jimblandy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm encouraged by the way this concentrates almost all the validation work in valid/interface.rs, the other valid submodules have lots of delicious deletions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds WGSL parsing support for mesh shaders to Naga, implementing a new approach where mesh shader outputs are written to workgroup variables rather than through function calls. The changes enable parsing of @task and @mesh entry points, new builtins (@builtin(vertices), @builtin(primitives), etc.), the task_payload address space, and the @per_primitive attribute.
Key changes:
- New mesh shader builtins (VertexCount, Vertices, PrimitiveCount, Primitives) for workgroup variable fields
- New TaskPayload address space for inter-stage communication
- Removal of
MeshFunctionstatement type in favor of direct workgroup variable access - Updated validation to analyze mesh output variable structure
- Frontend support for
@task,@mesh, and@payloadattributes
Reviewed Changes
Copilot reviewed 31 out of 39 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| naga/src/ir/mod.rs | Adds new BuiltIn variants and modifies MeshStageInfo to include output_variable field |
| naga/src/valid/interface.rs | Adds validation for mesh output variables and capability checks for new builtins |
| naga/src/proc/mod.rs | Adds analyze_mesh_shader_info function to extract mesh info from workgroup variables |
| naga/src/front/wgsl/parse/mod.rs | Adds parsing for @task, @mesh, @payload attributes and @per_primitive decorator |
| naga/src/front/wgsl/parse/directive/enable_extension.rs | Adds MeshShader enable extension |
| naga/src/valid/analyzer.rs | Removes FunctionMeshShaderInfo and related mesh function analysis |
| naga/tests/in/wgsl/mesh-shader.wgsl | Adds test input for mesh shader parsing |
| docs/api-specs/mesh_shading.md | Updates specification to reflect workgroup variable-based approach |
| Multiple backend files | Updates to handle new builtins with unreachable!() for unsupported cases |
Comments suppressed due to low confidence (1)
naga/src/ir/mod.rs:2587
- Corrected spelling: 'renderedas' should be 'rendered as' in the doc comment.
Lines,
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Connections
#7197
Description
Adds WGSL parsing for mesh shaders to naga.
This PR is quite a bit smaller than it looks, just a few hundred lines. The rest of the "changes" come from snapshots.
Testing
There are mesh shader tests (that don't actually write to any backend)
Also, #8456 proves that this is enough information to write proper SPIR-V shaders
Squash or Rebase?
Squash
Checklist
cargo fmt.taplo format.cargo clippy --tests. If applicable, add:--target wasm32-unknown-unknowncargo xtask testto run tests.CHANGELOG.mdentry.