-
Notifications
You must be signed in to change notification settings - Fork 983
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
The Fate and Purpose of BufferSlice
#6974
Comments
I’ll try to have some thoughts about what would be an “actually actively-good version of BufferSlice”, but I don't have them right now. Some comments:
Note that it's easier in JavaScript to create an ad-hoc object, copy or inherit properties, etc., so it may be easier to deal with not having useful predefined struct types there.
This could be fixed by making |
Note no rush, this isn't a ticking timebomb, we'll let the discussion take its course. |
It would be useful to list what |
Thanks for the prompt, @nical. Here's where
It seems to me that the current direct value of The indirect value of If I could design everything however I liked, we would:
Happy to write a PR for all that :) |
Thanks for the writeup! It would be great if (some of) I see the value in having some syntactic sugar for some use cases. When I look at my own usage of wgpu, slice is only used as a temporary when passing parameters to various API calls and I end up with the same information passed as if we were following the standard, but in a slightly non-standard way. The WebGPU specification is a great source of documentation for wgpu, except for anything involving Example: // Version 1:
buffer.slice(..).map_async(mode, callback); Versus // version 2:
buffer.map_async(mode, .., callback); Some folks might find version 1 more aesthetically pleasing, but anyone who uses the WebGPU specification for documentation will expect something close to version 2 to work. I admit to a double-standard here: I'm happy to have rust ranges instead of offset+size parameters, and the callback being a parameter instead of a promise returned. On the other hand the That's not a huge issue of course, but version 1 does not (in my opinion) provide value over version 2 for this type of usage, or at least not enough to warrant straying away from WebGPU. For that reason, I find the usage in mapping more problematic than, say, the usage in command encoding, even if I would prefer I'd be much happier with at least
It sounds like this would be simple to add on top of wgpu using a struct that contains a buffer and a range, without having
If I may extend this analogy a bit further, it wouldn't be great if you could only interact with a vector via a slice. Most of what you can do with the slice you can do on the vector directly. After having written all of this My feeling is that there is a better compromise where perhaps |
This makes lots of sense. But how about we fix that by adding a
I see this perspective, but I also think that Proposal: I will send PRs to:
And after those have been out for a while, we can revisit whether Any objections? |
Sounds great! |
Yeah getting map_async, get_mapped_range(_mut) on Buffer, and making |
There's been a bit of discussion in the community about the difficulties in the current
BufferSlice
api. As such, we have been thinking about removing it entirely. However there was some discussion about potential use cases of it in #6309, so we figured we should make an issue to discuss what the api ofBufferSlice
should be, if it is to exist at all.cc @kpreid
Some Arguments Against the Current Api:
BufferSlice
implies that you can access the data inside the buffer.BufferSlice
around, but because of the strict lifetime, you can't keep it for more than a short period.The text was updated successfully, but these errors were encountered: