-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Naga mesh shader SPIR-V writer #8456
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
Merged
cwfitzgerald
merged 42 commits into
gfx-rs:trunk
from
inner-daemons:mesh-shading/spv-write
Dec 17, 2025
Merged
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
0622940
[spv-out] Support for mesh shaders
cwfitzgerald dc69d86
Update mesh_shader.rs
inner-daemons dfd360f
Tried one thing
inner-daemons c1973fe
Updated snapshots
inner-daemons 50c2aa9
Tried another thing
inner-daemons 7749867
Removed per primitive stuff + cull primitive
inner-daemons ca3f93a
Testing new thing
inner-daemons 4fbfc60
Ahh well I think I'm done for the night
inner-daemons 7551f6a
Slight improvements
inner-daemons 3225030
Fixed another comment
inner-daemons c34c474
Added note on feature
inner-daemons 18164ee
Preparing for merge as is
inner-daemons 0b9bf09
Ok I'm tired
inner-daemons da72786
Blah blah blah
inner-daemons 8862d56
Updated loop logic
inner-daemons 0286af7
Tried something else
inner-daemons 7cc51c9
Tried another little fix
inner-daemons 3818efe
Tried something new
inner-daemons ea50cb0
Told it to skip instead of expect a failure
inner-daemons 8d9a451
Redocumented feature, made tests run on AMD
inner-daemons 3edc37c
Removed obseleted files, updated changelog, updated shaders
inner-daemons 6ffd2d5
Added task shader to the changelog entry
inner-daemons 094a5ac
Enabled debugigng
inner-daemons 6417327
Fixed typo
inner-daemons 2e863e2
Trying with better aligned task payload stuff
inner-daemons 05eada6
Made the tests actually run on LLVMPIPE
inner-daemons 6dc1fd0
Testing on LLVMPIPE if removing task payload reads does anything
inner-daemons 883a443
Undid test that didnt work
inner-daemons 3457ed5
Tried making it write a barrier
inner-daemons cad1bdf
Wrote another barrier I guess
inner-daemons 4927043
Gonna see if this one does anything
inner-daemons 19af909
Jeez im stupid
inner-daemons 3d7327f
Removed debugging files
inner-daemons c4574e7
Fixed the example shader sorta
inner-daemons ff46752
Blah blah blah
inner-daemons a5324ee
Merge remote-tracking branch 'upstream/trunk' into mesh-shading/spv-w…
inner-daemons c36f9f8
Final cleanup
inner-daemons 4c29d13
Added new mesh shader tasks
inner-daemons c08d00a
Fixed test
inner-daemons 7703aef
Fixed some test shenanigans
inner-daemons 90624c8
Seeing if this breaks anything
inner-daemons 307f908
Tried to fix one issue
inner-daemons File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| enable wgpu_mesh_shader; | ||
|
|
||
| const positions = array( | ||
| vec4(0., 1., 0., 1.), | ||
| vec4(-1., -1., 0., 1.), | ||
| vec4(1., -1., 0., 1.) | ||
| ); | ||
| const colors = array( | ||
| vec4(0., 1., 0., 1.), | ||
| vec4(0., 0., 1., 1.), | ||
| vec4(1., 0., 0., 1.) | ||
| ); | ||
|
|
||
| struct TaskPayload { | ||
| colorMask: vec4<f32>, | ||
| visible: bool, | ||
| } | ||
| struct VertexOutput { | ||
| @builtin(position) position: vec4<f32>, | ||
| @location(0) color: vec4<f32>, | ||
| } | ||
| struct PrimitiveOutput { | ||
| @builtin(triangle_indices) indices: vec3<u32>, | ||
| @builtin(cull_primitive) cull: bool, | ||
| @per_primitive @location(1) colorMask: vec4<f32>, | ||
| } | ||
| struct PrimitiveInput { | ||
| @per_primitive @location(1) colorMask: vec4<f32>, | ||
| } | ||
|
|
||
| var<task_payload> taskPayload: TaskPayload; | ||
| var<workgroup> workgroupData: f32; | ||
|
|
||
| @task | ||
| @payload(taskPayload) | ||
| @workgroup_size(1) | ||
| fn ts_main() -> @builtin(mesh_task_size) vec3<u32> { | ||
| workgroupData = 1.0; | ||
| taskPayload.colorMask = vec4(1.0, 1.0, 0.0, 1.0); | ||
| taskPayload.visible = true; | ||
| return vec3(1, 1, 1); | ||
| } | ||
|
|
||
| struct MeshOutput { | ||
| @builtin(vertices) vertices: array<VertexOutput, 3>, | ||
| @builtin(primitives) primitives: array<PrimitiveOutput, 1>, | ||
| @builtin(vertex_count) vertex_count: u32, | ||
| @builtin(primitive_count) primitive_count: u32, | ||
| } | ||
|
|
||
| var<workgroup> mesh_output: MeshOutput; | ||
|
|
||
| @mesh(mesh_output) | ||
| @payload(taskPayload) | ||
| @workgroup_size(1) | ||
| fn ms_main() { | ||
| mesh_output.vertex_count = 3; | ||
| mesh_output.primitive_count = 1; | ||
| workgroupData = 2.0; | ||
|
|
||
| mesh_output.vertices[0].position = positions[0]; | ||
| mesh_output.vertices[0].color = colors[0] * taskPayload.colorMask; | ||
|
|
||
| mesh_output.vertices[1].position = positions[1]; | ||
| mesh_output.vertices[1].color = colors[1] * taskPayload.colorMask; | ||
|
|
||
| mesh_output.vertices[2].position = positions[2]; | ||
| mesh_output.vertices[2].color = colors[2] * taskPayload.colorMask; | ||
|
|
||
| mesh_output.primitives[0].indices = vec3<u32>(0, 1, 2); | ||
| mesh_output.primitives[0].cull = !taskPayload.visible; | ||
| mesh_output.primitives[0].colorMask = vec4<f32>(1.0, 0.0, 1.0, 1.0); | ||
| } | ||
|
|
||
| @fragment | ||
| fn fs_main(vertex: VertexOutput, primitive: PrimitiveInput) -> @location(0) vec4<f32> { | ||
| return vertex.color * primitive.colorMask; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Credit yourself lmao