-
Notifications
You must be signed in to change notification settings - Fork 32
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
Use Encase's Layouting Independent of Uploading #16
Comments
Could you point me at some code that would use this? Is this for the sparse copy compute shader you are using (where you write the new data in a new buffer and then copying it in the proper spots in the destination buffer)? |
Yeah that's the intended use case - using sparse copies to update a buffer that is laid out like https://github.com/BVE-Reborn/rend3/blob/trunk/rend3-routine/shaders/src/structures.wgsl#L48-L51. The above struct is what I ideally would be the equivalent encase declaration. |
I am writing a particle physics simulator and this would also be very useful for me. I have several very large arrays of structs on GPU memory, and I need to write to a few elements at a time, sometimes even just a single field of a struct. It is also desirable to get the value that was stored there previously, though that would probably happen on the next frame. |
Actually, a variation of this feature should already be available. The Polishing this API would be a next step but I'd like to see how people use it first. Let me know if you come up with something (using |
The actual Metadata structs I think aren't documented in any form. The latest version on doc.rs doesn't even show the METADATA constant on the trait. I'm also interested in this as we're looking into preallocating buffer space for parallelizing buffer writes in Bevy (see bevyengine/bevy#12489) |
The metadata was meant to be internal to encase but it seems people are interested in exposing it somehow. The main question is how would the API look like? I can see it looking quite differently depending on how it will be used. It might be worth experimenting with an API outside encase (which would use the metadata) at first. |
I also had a usecase for this. In my case, I needed the "get offset of element in an array". I am calling I currently have code along the lines of let buffer_offset = (i as u64)
* Vec::<copy_patches::DrawIndexedIndirectArgs>::METADATA
.extra
.stride
.get(); // Is this actually correct?
render_pass.draw_indexed_indirect(&indirect_draw_buffers, buffer_offset); It'd be nicer if I could have written something like |
In rend3's vertex pulling rewrite I need to deal with sparse updates of buffers a lot. Because of that I'm not actually writing out the entire buffer all at once. I end up uploading individual items that changed into the byte offsets into the buffer they are supposed to be.
I would love to have a definition like this:
But because I can't upload the whole thing at once, I can't actually just use WriteInto here. What I would love is an API that would give me an offset into the structure for a given member. Maybe something like
This would let me use encase's layout even though I need my own custom weird layout system. Not at all attached to the syntax, just what it would let me accomplish.
The text was updated successfully, but these errors were encountered: