-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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 doc for DynamicStorageBuffer
doesn't really explain the difference with StorageBuffer
#15052
Comments
DynamicStorageBuffer
dlesn't really explain the difference with StorageBuffer
DynamicStorageBuffer
doesn't really explain the difference with StorageBuffer
I don't know that DynamicStorageBuffer really makes sense tbh, I've thought that we should remove it. Typically you don't need dynamic offsets if you're binding a storage buffer anyways. |
Ok I didn't realize the "dynamic" was for the dynamic bind offset. From there I'm guessing that this buffer was added for the same (niche) reason I added mine in Hanabi, which is to be able to bind both the entire buffer but also individual elements. If that's the case this should be documented because this implies all elements are individually aligned, which has the potential for a lot of wasted padding, so should be carefully considered. |
(individual elements or any other subset view if the array, the binding doesn't need to be a single element in size, what's important is the start of the bound view) |
Ping @JMS55 before this gets into limbo, can you please clarify? I'm not asking about whether it makes sense or not, just that we at least document what this is (and at the very least on this issue, so someone can pick up the work to write the doc PR). Thanks! |
Yes, DynamicStorageBuffer is just a StorageBuffer, but also allows you to set dynamic offsets. Tbh I don't actually know how dynamic offsets work with storage buffers (what's the point even? You have the whole buffer bound at once anyways, no need to slice it up per binding...). I've never used it. |
The point is say you have a buffer that stores an array of struct. This is especially common if you batch several items. In one compute pass you bind it as a whole and work on the entire array. But in other passes you bind just one element, or a chunk (= view = sub-array) of it. In Hanabi this is "work on all particles" vs. "work on a single group" (which is stored alongside all the other groups for the effect, inside the same buffer). Why is that helpful compared to binding the whole buffer? Because your compute pass doesn't need to know how to address the chunk; it's implicit by the binding, so saves on extra data to pass. Now, I believe the key aspect here is not about the usage of dynamic offsets, but the fact that if you want to bind a sub-array, then the first element of that sub-array needs to be aligned according to Is |
Sounds right to me, but idk for sure. |
Ok thanks, I'll dig into the code if I have time, or if someone else knows... |
Ok that's actually just a wrapper around |
https://docs.rs/bevy/latest/bevy/render/render_resource/struct.DynamicStorageBuffer.html
Compared with https://docs.rs/bevy/latest/bevy/render/render_resource/struct.StorageBuffer.html#method.write_buffer
Those sound like the same thing phrased in two different ways. The type
T
also has the sameShadeType
bound, so there's no telling from that what a difference might be.A table explaining the differences and pros/cons of all buffers, probably under the module's page, would be quite useful.
The text was updated successfully, but these errors were encountered: