Skip to content

Conversation

@andyleiserson
Copy link
Contributor

@andyleiserson andyleiserson commented Dec 15, 2025

Fixes a CTS failure caused by mapping Some(0) to None when converting to Option<NonZeroU64> for the wgpu-core API. A zero-size binding is illegal. Omitting the size of a binding is valid and means to bind until the end of the buffer. Change the wgpu-core API to allow Some(0) and then reject it with an error. wgpu API remains the same.

Testing
Enables the relevant CTS test.

Squash or Rebase? Squash

fid.assign(Fallible::Invalid(Arc::new(label.to_string())));
}

pub fn create_bind_group_error(
Copy link
Member

Choose a reason for hiding this comment

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

One question, why is this needed when Firefox is able to do this without it? Might we worth a note on the call why we need to do this, as this method is discouraged.

Copy link
Member

Choose a reason for hiding this comment

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

I think Firefox has the same issue; wouldn't it be better to change the type to Option<u64> at least in wgpu-core? So that users of the API don't have to do this validation outside (Deno, Firefox, Servo, wgpu-native).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In my head I think I was assuming Firefox had already handled it, but it doesn't look like it has, so I agree it makes sense to have wgpu-core do this.

Copy link
Member

Choose a reason for hiding this comment

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

Even if Firefox did do the validation: if we can centralize validation here, that makes everything better for everyone.

Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

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

Approved with question

Previously they were prevented by the type system. Because JavaScript
APIs cannot do that, allow requesting a zero-size binding in the API to
wgpu-core and then reject it with an error. The `wgpu` API remains the
same.
@andyleiserson andyleiserson changed the title deno: Reject zero-size bindings in createBindGroup core: Reject zero-size bindings in createBindGroup Dec 16, 2025
Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

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

LGTM,B (Looks groovy to me, baby)

@cwfitzgerald cwfitzgerald enabled auto-merge (squash) December 16, 2025 18:17
@cwfitzgerald cwfitzgerald merged commit 6dd69b0 into gfx-rs:trunk Dec 16, 2025
47 checks passed
@andyleiserson andyleiserson deleted the push-tvppwyusplvp branch December 16, 2025 18:22
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.

4 participants