Buffer types + arrayLength() issues
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## Bevy version
acbed6040eeae99199657e44a9668772738ac344
## 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.
Contributor guide
Assessment
This issue has not been assessed yet.