Skip to content

Mesh shader HLSL writer#8752

Open
inner-daemons wants to merge 138 commits intogfx-rs:trunkfrom
inner-daemons:mesh-shading/hlsl-write-id
Open

Mesh shader HLSL writer#8752
inner-daemons wants to merge 138 commits intogfx-rs:trunkfrom
inner-daemons:mesh-shading/hlsl-write-id

Conversation

@inner-daemons
Copy link
Collaborator

@inner-daemons inner-daemons commented Dec 17, 2025

Connections
Part of #7197
Closes #7219
Related to #8739
Depends on #8756

Description
Adds support for mesh shaders to HLSL writer. There still exist some things to do:

  • Possibly disable some mesh outputs that are unused in the fragment shader

Testing
Existing tests, snapshots

Squash or Rebase?
Squash

Checklist

  • Run cargo fmt.
  • Run taplo format.
  • Run cargo clippy --tests. If applicable, add:
    • --target wasm32-unknown-unknown
  • Run cargo xtask test to run tests.
  • If this contains user-facing changes, add a CHANGELOG.md entry.

cwfitzgerald pushed a commit that referenced this pull request Feb 12, 2026
* Initial commit adding miscellaneous changes from msl-write and hlsl-write

* Same as previous commit

* Fixed divergence issue

* Removed some unnecessary barriers

* Zero init workgroup memory

* Added limits validation

* Added changelog

* Handled overflow, removed todo

* Lets see if this fixes llvmpipe

* Also this commit fixes llvmpipe maybe

* Unfortunate but not too unexpected at this point

* Updated feature to say to use ShaderRuntimeChecks::unchecked()

* Updated snapshots and took some changes from the hlsl writer

* Snapshots

* 2 quick tweaks

* Updated framework with suggestions by Connor in #8752

* Moved the task runtime limits into naga::back

* Fixed soem stuff

* Fixed checks: >= into >

* Cant believe I forgot this

* Removed code using u64 to check stuff

* Removed thing with limiting it to 2<<21

* Some more work

* Fixed compiles

* Added new field to spv options

* Updated some stuff to pass around the task runtime limits in more ways

* New PR started

* Did another quick fix

* Another quick fix

* Added changelog entry

* Added some explanation docs

* Fixed a warning

* Fixed shader

* Fixed some things & added docs

* Reverted dxc thing

* Fixed thing

* Refactored to TaskDispatchLimits

* Fixed compile error
@Wumpf Wumpf self-requested a review February 21, 2026 20:09
Copy link
Member

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still needs some final touches!

@inner-daemons
Copy link
Collaborator Author

inner-daemons commented Feb 22, 2026

@Wumpf Ok I'll address these soon-ish, plus I'll fix up the MSL writer PR which probably has many of the same problems. Thanks for the quick review!

@inner-daemons
Copy link
Collaborator Author

@Wumpf Comments addressed

@inner-daemons inner-daemons requested a review from Wumpf February 22, 2026 19:04
@inner-daemons
Copy link
Collaborator Author

inner-daemons commented Feb 22, 2026

@Wumpf I believe this will expose an issue that will impact Firefox significantly, so don't merge it until that's fixed. Same goes for the MSL PR (though I'm not sure its as singificant in MSL).

@inner-daemons
Copy link
Collaborator Author

Alright lets block this on #9099

Copy link
Member

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, thanks for addressing all these

Comment on lines 91 to +102
> **NOTE**: More limits will be added when support is added to `naga`.

* `Limits::max_task_workgroup_total_count` - the maximum total number of workgroups from a `draw_mesh_tasks` command or similar. The dimensions passed must be less than or equal to this limit when multiplied together.
* `Limits::max_task_workgroups_per_dimension` - the maximum for each of the 3 workgroup dimensions in a `draw_mesh_tasks` command. Each dimension passed must be less than or equal to this limit.
* `max_mesh_multiview_count` - The maximum number of views used when multiview rendering with a mesh shader pipeline.
* `Limits::max_task_mesh_workgroup_total_count` - the maximum total number of workgroups from a `draw_mesh_tasks` command or similar. The dimensions passed must be less than or equal to this limit when multiplied together.
* `Limits::max_task_mesh_workgroups_per_dimension` - the maximum for each of the 3 workgroup dimensions in a `draw_mesh_tasks` command. Each dimension passed must be less than or equal to this limit.
* `max_task_invocations_per_workgroup` - The maximum total number of threads in a task shader workgroup, given by `workgroupSize.x * workgroupSize.y * workgroupSize.z`.
* `max_task_invocations_per_dimension` the maximum value for each of `workgroupSize.x`, `workgroupSize.y` and `workgroupSize.z` in task shader workgroups.
* `max_mesh_invocations_per_workgroup` - The maximum total number of threads in a mesh shader workgroup, given by `workgroupSize.x * workgroupSize.y * workgroupSize.z`.
* `max_mesh_invocations_per_dimension` the maximum value for each of `workgroupSize.x`, `workgroupSize.y` and `workgroupSize.z` in mesh shader workgroups.
* `max_task_payload_size` - the size of an `var<task_payload>` variable, in bytes.
* `max_mesh_output_vertices` - the maximum number of vertices that a single mesh shader workgroup may output.
* `max_mesh_output_primitives` - the maximum number of primitives that a single mesh shader workgroup may output.
* `max_mesh_multiview_count` - the maximum number of views used when multiview rendering with a mesh shader pipeline.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! But I suppose the "more limits will be added" bit is obsolete now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the MSL writer PR adds 1 more limit, once we get this merged and I handle the changes from this in the MSL PR then we can remove that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mesh Shading for DirectX 12

3 participants