-
Notifications
You must be signed in to change notification settings - Fork 304
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
Make GPUBufferBinding size optional #331
Comments
Vulkan has VK_WHOLE_SIZE for this, so default makes sense... |
Makes sense to me, I think we talked about this once before too. My only concern is that we should try to avoid making a distinction between |
Having a size of I would go with the IDL below. dictionary GPUBufferBinding {
required GPUBuffer buffer;
u64 offset = 0;
- required u64 size;
+ u64? size;
}; If size is not defined, use the whole size of the buffer. |
Are there examples of Web APIs making a distinction between If we want to avoid distinguishing undefined and 0, could have a special value like in Vulkan: enum GPUBufferBindingSize { "whole-size" };
dictionary GPUBufferBinding {
required GPUBuffer buffer;
u64 offset = 0;
(GPUBufferBindingSize | u64) size = "whole-size";
}; |
This I made a mistake though. We should remove the dictionary GPUBufferBinding {
required GPUBuffer buffer;
u64 offset = 0;
- required u64 size;
+ // If size is undefined, use the whole size of the buffer.
+ u64 size;
}; If size is undefined, use the whole size of the buffer. |
You're right that my suggestion still distinguishes 0 and undefined. Good point. Your last suggestion looks good to me. Would you open a PR for it? |
@kainino0x Here's the PR: #346 |
Following WebGPU spec change at gpuweb/gpuweb#331, bind groups should now use the whole size of the buffer if undefined. Bug: 877147 Change-Id: I62c942c7607ce119398ab6967070c3f104443410 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1700051 Reviewed-by: François Beaufort <beaufort.francois@gmail.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: François Beaufort <beaufort.francois@gmail.com> Cr-Commit-Position: refs/heads/master@{#677285}
How about making GPUBufferBinding
size
optional? If not specified, it would be the same as the buffer size passed in the bindingresource
ofdevice.createBindGroup()
?I believe this would make code easier to read and digest for newcomers.
const gpuBufferSize = 4; const gpuBuffer = device.createBuffer({ size: gpuBufferSize, usage: GPUBufferUsage.STORAGE }); const bindGroup = device.createBindGroup({ layout: bindGroupLayout, bindings: [ { binding: 0, resource: { buffer: myGpuBuffer, - size: gpuBufferSize } } ] });
The text was updated successfully, but these errors were encountered: