-
Notifications
You must be signed in to change notification settings - Fork 1.2k
core: Reject zero-size bindings in createBindGroup #8734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
wgpu-core/src/device/global.rs
Outdated
| fid.assign(Fallible::Invalid(Arc::new(label.to_string()))); | ||
| } | ||
|
|
||
| pub fn create_bind_group_error( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
cwfitzgerald
left a comment
There was a problem hiding this 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.
5c357cb to
f4022fa
Compare
cwfitzgerald
left a comment
There was a problem hiding this 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)
Fixes a CTS failure caused by mapping
Some(0)toNonewhen converting toOption<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 allowSome(0)and then reject it with an error. wgpu API remains the same.Testing
Enables the relevant CTS test.
Squash or Rebase? Squash