Open
Description
Bevy version
Problem
StorageBuffer/UniformBuffer/etc will reuse its GPU buffer if it's big enough.
Say one frame you want a buffer of size N*2, and the next, N.
Because StorageBuffer/etc use as_entire_buffer_binding(), on the second frame, you'll end up with a buffer of size N*2, and not N.
If the buffer stores an unsized array, any shaders using arrayLength() in the shader will return N*2, but again we'd be expecting N here as that's how many items we wrote this frame.
Affected shaders
- mesh_preprocess.wgsl
- get_visibility_range_dither_level()
- Some meshlet stuff (I fixed this on a branch)
Solution
The buffer types should probably not use as_entire_buffer_binding(), and instead should bind only the section of the buffer actually written to in the last write_buffer() call.