Skip to content

Add STRICT_WEBGPU_COMPLIANCE instance flag#9586

Open
teoxoy wants to merge 7 commits into
gfx-rs:trunkfrom
teoxoy:STRICT_WEBGPU_COMPLIANCE
Open

Add STRICT_WEBGPU_COMPLIANCE instance flag#9586
teoxoy wants to merge 7 commits into
gfx-rs:trunkfrom
teoxoy:STRICT_WEBGPU_COMPLIANCE

Conversation

@teoxoy
Copy link
Copy Markdown
Member

@teoxoy teoxoy commented May 25, 2026

Connections
Fixes #3274.
Fixes #9436.
Fixes #3365.

Description
Adds the STRICT_WEBGPU_COMPLIANCE flag, intended to be used by wgpu-core users that want to strictly limit the behavior of wgpu-core to the one defined by the WebGPU spec.

Testing
Added some more tests.

Squash or Rebase?
Rebase.

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.

@teoxoy teoxoy force-pushed the STRICT_WEBGPU_COMPLIANCE branch 2 times, most recently from b9aeac7 to b58c67f Compare May 25, 2026 13:54
@teoxoy teoxoy changed the title Add STRICT_WEBGPU_COMPLIANCE instance flags Add STRICT_WEBGPU_COMPLIANCE instance flag May 25, 2026
@teoxoy teoxoy force-pushed the STRICT_WEBGPU_COMPLIANCE branch from b58c67f to 3bafe78 Compare May 25, 2026 13:59
@teoxoy teoxoy force-pushed the STRICT_WEBGPU_COMPLIANCE branch from 3bafe78 to 2afbe99 Compare May 26, 2026 15:32
@teoxoy teoxoy force-pushed the STRICT_WEBGPU_COMPLIANCE branch from 2afbe99 to 1c2bb32 Compare May 26, 2026 15:50
@andyleiserson andyleiserson self-assigned this May 27, 2026
Copy link
Copy Markdown
Contributor

@andyleiserson andyleiserson left a comment

Choose a reason for hiding this comment

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

Nice!

There is another instance flag ALLOW_UNDERLYING_NONCOMPLIANT_ADAPTER, which says it "mainly applies to a Vulkan driver's compliance version" (and that is in fact the only place it applies). It might be worth updating the docs for that flag to clarify the difference from STRICT_WEBGPU_COMPLIANCE.

It might be worth a few unit tests (maybe for adapter_allowed) capturing conditions where we don't want to return an adapter. We won't otherwise have much coverage of this logic. An expectation that adapter_allowed exists as a function, is not unused, and has certain properties, provides some protection against breakage.

Comment thread wgpu-core/src/instance.rs
/// `adjust_raw_limits` fn. So we only check the remaining properties here.
/// See <https://gpuweb.github.io/gpuweb/#adapter-capability-guarantees>.
fn adapter_allowed(&self, raw: &hal::DynExposedAdapter) -> bool {
// Check "All alignment-class limits must be powers of 2."
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All alignment-class limits must be powers of 2 is a WebGPU requirement, but this section of the function is applied whether or not the user has asked for strict WebGPU compliance. It would be utter insanity for these not to be a power of two, so it seems fine to reject such devices, but it might be clearer to say something like "Even if the application has not requested strict WebGPU compliance, non-power-of-two alignment limits are nonsensical, so don't attempt to use such a device."

(Side nit: there is a typo in a comment at

saying the value is 254 rather than 256.)

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

Labels

None yet

Projects

None yet

2 participants