-
Notifications
You must be signed in to change notification settings - Fork 978
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
Create a BufferBinding
from a BufferSlice
#6309
Comments
You're right, they're pretty much the same, the semantics are just a little bit different of what they represent. One is just a buffer ref + slice, the other is a descriptor to build up bindings.
Whereas I'd suggest:
@DCNick3 What do you think, would that make things sufficiently nicer for you? |
Yep, this would work for me |
Honestly haven't ever thought about this api :) |
I think the best solution here is just removing the buffer slice api all together |
I’d like to speak up for another use case for keeping Besides the specific use case, continuing to have (and expand on) a convenient way to express “this part of this buffer” may encourage users to use sub-allocation instead of multiple buffers when it’s applicable, which can improve efficiency. |
P.S. I was specifically planning to add getters to |
Interesting! I thought it was pretty universally hated - sounds like we need to have a discussion about it. Will file issue tomorrow. |
TL;DR: I pass a
BufferSlice
in a bunch of places, but I can't use it to bind a buffer, sinceBufferBinding
needs aBuffer
reference.Is your feature request related to a problem? Please describe.
While implementing a more opinionated graphics API wrapper around
wgpu
for my game engine, I've started using wgpu'sBufferSlice
to pass different buffers without giving up the ownership in a generic way.It works fine for passing vertex and index buffers, but a problem occurred when I tried to use it to pass uniform buffers: AFAIU,
the only way to bind a uniform buffer is to construct a
BufferBinding
struct and pass it to the bind group descriptor.BufferBinding
, however, wants a reference to aBuffer
, notBufferSlice
. WithBufferSlice
not providing an API to get to its internally stored buffer reference, offset and size (the exact three thingsBufferBinding
wants!), I have no good option to do it this way.Implementation-wise they seem to be exactly the same: they store a reference to a buffer, start offset and an optional size. They just provide different APIs to use them with.
Describe the solution you'd like
I'd like any solution allowing me use
BufferSlice
to bind a uniform buffer without me having to refer back to theBuffer
it originated from.The easiest & non-backcompat breaking solution would be to expose the innards of the
BufferSlice
, allowing to construct aBufferBinding
from them. Not sure it the best design, though.An IMO better solution is replacing the usage of
BufferBinding
withBufferSlice
. This would be a breaking change, but the expressiveness of API wouldn't be changed (instead of providing the offset and size directly, you would have to slice the buffer before passing it to the descriptor). IfBufferBinding
is to be removed, there will be no rust equivalent to WebGPU'sGPUBufferBinding
, so not sure if it will work for you.Describe alternatives you've considered
Implementing a
BufferSlice
myself and adding conversion operations to wgpuBufferSlice
andBufferBinding
where needed.The text was updated successfully, but these errors were encountered: