Skip to content
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

Support zero-length vertex/index buffers #3170

Open
jimblandy opened this issue Nov 3, 2022 · 1 comment
Open

Support zero-length vertex/index buffers #3170

jimblandy opened this issue Nov 3, 2022 · 1 comment
Labels
area: api Issues related to API surface

Comments

@jimblandy
Copy link
Member

The WebGPU specification says that setVertexBuffer and setIndexBuffer may be passed a size of zero, but wgpu doesn't support this: the set_index_buffer and set_vertex_buffer methods take BufferSlice values, which are not allowed to be empty.

(Show-stopping, I know.)

@jimblandy jimblandy added the area: api Issues related to API surface label Nov 3, 2022
jimblandy added a commit to jimblandy/wgpu that referenced this issue Nov 3, 2022
`RenderBundleEncoder::set_index_buffer` and `set_vertex_buffer`
interpret a `size` of `None` to mean "from the given offset to the end
of the buffer", but `std::num::NonZeroU64::new` produces `None` when
its argument is zero, which is quite different. Fix this similarly to
the way it's handled in `op_webgpu_render_pass_set_index_buffer`.

The WebGPU spec says this should work; filed as gfx-rs#3170.
jimblandy added a commit to jimblandy/wgpu that referenced this issue Nov 3, 2022
`RenderBundleEncoder::set_index_buffer` and `set_vertex_buffer`
interpret a `size` of `None` to mean "from the given offset to the end
of the buffer", but `std::num::NonZeroU64::new` produces `None` when
its argument is zero, which is quite different. Fix this similarly to
the way it's handled in `op_webgpu_render_pass_set_index_buffer`.

The WebGPU spec says this should work; filed as gfx-rs#3170.
jimblandy added a commit that referenced this issue Nov 3, 2022
`RenderBundleEncoder::set_index_buffer` and `set_vertex_buffer`
interpret a `size` of `None` to mean "from the given offset to the end
of the buffer", but `std::num::NonZeroU64::new` produces `None` when
its argument is zero, which is quite different. Fix this similarly to
the way it's handled in `op_webgpu_render_pass_set_index_buffer`.

The WebGPU spec says this should work; filed as #3170.
@teoxoy teoxoy added this to the WebGPU Specification V1 milestone Dec 5, 2022
@teoxoy teoxoy changed the title Deno bindings don't support zero-length vertex/index buffers Support zero-length vertex/index buffers Dec 15, 2023
@CryptArchy
Copy link

After upgrading from v0.20 to v22.0 I'm running into a new bug around this. Where previously I had slices being passed into set_vertex_buffer without problem, now those same calls are failing due to slice offset 0 is out of range for buffer of size 0. The slice operation fails when copying the full range (.slice(..)) of an empty buffer.

I'm not even sure why the buffers are empty, perhaps an edge condition on startup, but I know it was working before so either something changed to cause the buffers to be empty or something changed to make empty slices fail.

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
Projects
Status: No status
Development

No branches or pull requests

3 participants