Skip to content

Validate pipeline layout immediate_size and fix its calculation when there are multiple immediate variables#9711

Open
beicause wants to merge 5 commits into
gfx-rs:trunkfrom
beicause:validate-and-fix-layout-immediate-size
Open

Validate pipeline layout immediate_size and fix its calculation when there are multiple immediate variables#9711
beicause wants to merge 5 commits into
gfx-rs:trunkfrom
beicause:validate-and-fix-layout-immediate-size

Conversation

@beicause

@beicause beicause commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Connections
#8556

Description

Current size_for_module is incorrect, which doesn't consider multiple immediate variables. We should check the immediate size used by entry points.

pub fn size_for_module(module: &crate::Module) -> u32 {

Also the validation is missing. Per spec https://gpuweb.github.io/gpuweb/#abstract-opdef-validating-gpuprogrammablestage

  1. If there is an immediate data variable that is statically used by entryPoint (assert there is at most one):

Let T be the store type of the immediate data variable.

Let requiredSize be SizeOf(T).

layout.[[immediateSize]] must be ≥ requiredSize.

Testing
I updated naga snapshots and added a new test in wgpu-validation/immediates.rs, which fails on trunk branch but it is fixed in this PR: cargo nextest run --test wgpu-validation render_multi_immediates_with_all_immediates_set_succeeds

Squash or Rebase?
Squash

Checklist

  • I self-reviewed and fully understand this PR.
  • WebGPU implementations built with wgpu may be affected behaviorally.
  • Validation and feature gates are in place to confine behavioral changes.
  • Tests demonstrate the validation and altered logic works.
  • 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.

@beicause beicause changed the title Validate and fix layout immediate size Validate pipeline layout immediate_size and fix its calculation when there are multiple immediate variables Jun 19, 2026
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.

2 participants