Skip to content

Conversation

@ErichDonGubler
Copy link
Member

@ErichDonGubler ErichDonGubler commented Dec 3, 2025

Description

Some JS runtimes (like Firefox) want to control ID assignment for resources, unconditionally assigning them even when validation rules that has to happen in layers above wgpu-core determine that resources are invalid before even talking to wgpu-core. For these cases, we make wgpu_core::Global::create_*_error APIs, keeping wgpu-core the source of truth for the presence and validity of objects.

The motivating example for this PR is bind group layout entries. In WebGPU's WebIDL, such entries must have one and only one optional discriminant member specified, indicating which resource type is being used. In Rust, we would just use an enum, and make invalid states unrepresentable. However, we must (and currently do not) afford JS runtimes using wgpu-core the ability to register invalid bind group layouts to handle this case.

TODO: link to spec.

Add wgpu_core::Global::create_bind_group_layout_error, which fixes this flaw.

Testing

I don't see other create_*_error APIs tested, and this is consistent with that. This is probably because this sort of API is not something that anything in-tree needs. I've been testing it in Firefox builds, and I believe it works well enough.

Checklist

  • If this contains user-facing changes, add a CHANGELOG.md entry.

@ErichDonGubler
Copy link
Member Author

Most of this PR is ready for review, and I don't think review effort would be wasted before I (1) fix up the rustdoc issues firing in CI and (2) update the PR description with spec. link(s).

just don't actually merge it yet plz 🙏🏻

@ErichDonGubler ErichDonGubler added area: validation Issues related to validation, diagnostics, and error handling area: api Issues related to API surface area: ecosystem Help the connected projects grow and prosper area: correctness We're behaving incorrectly labels Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: api Issues related to API surface area: correctness We're behaving incorrectly area: ecosystem Help the connected projects grow and prosper area: validation Issues related to validation, diagnostics, and error handling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants