Skip to content

Validate mesh draws in render bundles against the multiview mask - #10496

Merged
mergify[bot] merged 2 commits into
gfx-rs:trunkfrom
apollo-2006:bundle-mesh-multiview
Oct 14, 2026
Merged

mergify[bot] merged 2 commits into
gfx-rs:trunkfrom
apollo-2006:bundle-mesh-multiview

Conversation

@apollo-2006

Copy link
Copy Markdown
Contributor

Connections

Fixes #9872.

Description

Render passes check mesh draws against the multiview mask with validate_mesh_draw_multiview, but render bundles don't, because the function took the render-pass State, and bundles use a different State struct (#8051). The first commit moves it to draw.rs so it takes the device and the mask, and calls it from passes and from bundles (draw_mesh_tasks, and multi_draw_indirect for the mesh family). Bundles can't record mesh draws yet, and the player doesn't replay traced bundles, so this part is groundwork without a test of its own.

While testing I found an off-by-one: the check compared the zero-based index of the highest view against max_mesh_multiview_view_count with >, so with a limit of 2, the mask 0b111 (views 0 to 2) was accepted. The second commit switches to >=, which matches VUID-VkGraphicsPipelineCreateInfo-renderPass-12325/12326 and the attachment check wgpu already has in render.rs. It also fixes the error message, which said <= and named max_multiview_view_count.

Happy to adjust the helper's signature or move the tests if you'd prefer a different shape.

Testing

New validation tests in tests/wgpu-validation/api/mesh_shader.rs, on the noop device:

  • mesh draw in a multiview pass without EXPERIMENTAL_MESH_SHADER_MULTIVIEW: rejected
  • views 0-1 with a limit of 2: accepted
  • views 0-2 with a limit of 2: rejected (accepted before the second commit)
  • only view 2 (selective multiview) with a limit of 2: rejected (accepted before the second commit)

cargo test -p wgpu-test --test wgpu-validation passes at each commit (106, then 108), and clippy is clean. cargo xtask test mesh passes 45/45 on an RX 9070 XT (RADV).

The full cargo xtask test also passes on the same machine (RADV and radeonsi GL), except clear_texture_uncompressed on GL, which is marked as expected to fail there but passes on this driver. Happy to open an issue for that if it's useful.

Squash or Rebase?

Rebase: the two commits are separate changes, and each one passes on its own.

LLM Use?

Claude was used to review a final pass over the code and the PR body.

Checklist

  • I self-reviewed and fully understand this PR.
  • CHANGELOG.md entries for the user-facing effects of this change are present.
  • The PR is minimal, and doesn't make sense to land as multiple PRs.
  • Commits are logically scoped and individually reviewable.
  • The PR description has enough context to understand the motivation and solution implemented.
  • (If applicable) WebGPU implementations built with wgpu may be affected behaviorally.
  • (If applicable) Validation and feature gates are in place to confine behavioral changes.
  • (If applicable) Tests demonstrate the validation and altered logic works.

@github-project-automation github-project-automation Bot moved this to To triage in Triage Sep 29, 2026
@inner-daemons inner-daemons self-assigned this Sep 30, 2026
@inner-daemons
inner-daemons self-requested a review September 30, 2026 14:40
@inner-daemons

Copy link
Copy Markdown
Collaborator

Can you clarify whether you wrote the code in the PR, wrote the description, gave the code a cursory glance, etc?

@apollo-2006

Copy link
Copy Markdown
Contributor Author

Yep, the code and description are mine. I used Claude Code to sanity-check edge cases and tighten the writeup. Happy to walk through any part of the diff :)

@inner-daemons

Copy link
Copy Markdown
Collaborator

Do you also use Claude to write your GitHub comments?

@apollo-2006

Copy link
Copy Markdown
Contributor Author

Yeah, fair question. I use it to draft a lot of my comments and to review the ones I write myself, including some here. The debugging and testing are mine, though, and I'm happy to go through any part of the diff so you can see where I'm at. If you'd prefer I write comments myself on this repo, I can do that.

@inner-daemons

Copy link
Copy Markdown
Collaborator

@apollo-2006 I feel like you would appear a lot more respectful and be received a lot better if you wrote your comments yourself. In open source we are currently being flooded with low effort contributions. If you submit code that could be seen as likely AI generated, and don't even go to the effort to write your own comments or github descriptions, there just isn't any indication that a human has put in any effort which feels crappy. I could pull up claude myself if thats what I wanted.

@apollo-2006

Copy link
Copy Markdown
Contributor Author

That's honestly a fair point, and I agree. Will keep note of that going forward, appreciate you showing me that perspective.

@inner-daemons inner-daemons left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM as far as being an improvement. I haven't checked that all necessary multiview validation logic is being run on render bundles.

Render passes check mesh draws against the pass's multiview mask with
validate_mesh_draw_multiview, but render bundles had no equivalent,
since the function took the render pass State.

Move the check to draw.rs, taking the device and the multiview mask,
and call it from both render passes and render bundles.

Fixes gfx-rs#9872
validate_mesh_draw_multiview compared the index of the highest view in
the multiview mask against max_mesh_multiview_view_count with `>`:

    highest_bit > device.limits.max_mesh_multiview_view_count

The index is zero-based and the limit is a count, so a mask whose
highest view is equal to the limit (one view too many) was accepted.
Vulkan requires the highest bit to be less than
maxMeshMultiviewViewCount, and render pass creation already compares
the multiview mask against the attachment layer count with `>=`.

Use `>=`, and name the right limit in the error message.
@teoxoy
teoxoy force-pushed the bundle-mesh-multiview branch from 023c639 to 5af5cc5 Compare October 14, 2026 15:48
@teoxoy

teoxoy commented Oct 14, 2026

Copy link
Copy Markdown
Member

@Mergifyio queue

@mergify mergify Bot added the queue: queued Set by Mergify while the PR is in the merge queue label Oct 14, 2026
@mergify
mergify Bot merged commit 14328f4 into gfx-rs:trunk Oct 14, 2026
70 checks passed
@github-project-automation github-project-automation Bot moved this from Small to Done in Triage Oct 14, 2026
@mergify mergify Bot removed the queue: queued Set by Mergify while the PR is in the merge queue label Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Render bundles are missing validate_mesh_draw_multiview

3 participants