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 motivation for this PR is that we are missing this for bind group layouts, specifically because of their entries. In WebGPU's WebIDL representation, such entries must have one and only one optional discriminant member specified, indicating which resource type is being used (link). In Rust, we use an enum, and make invalid states unrepresentable. However, for JS, we must (and currently do not) afford wgpu-core users the ability to register invalid bind group layouts for this case, like we do for other APIs (see also the validation listed for GPUDevice.createBindGroupLayout).

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
@ErichDonGubler ErichDonGubler force-pushed the invalid-js-bgl-entries branch 3 times, most recently from f83735e to de9294e Compare December 10, 2025 20:02
@ErichDonGubler ErichDonGubler enabled auto-merge (squash) December 11, 2025 19:44
@ErichDonGubler ErichDonGubler merged commit a35e5a2 into gfx-rs:trunk Dec 11, 2025
42 checks passed
@ErichDonGubler ErichDonGubler deleted the invalid-js-bgl-entries branch December 11, 2025 19:56
@ErichDonGubler ErichDonGubler added the type: enhancement New feature or request label Dec 11, 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 type: enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants