Enforce `ShaderSize` on `UniformBuffer` and `DynamicUniformBuffer` at compile time.
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## How can Bevy's documentation be improved?
Both:
https://docs.rs/bevy/latest/bevy/render/render_resource/struct.UniformBuffer.html
https://docs.rs/bevy/latest/bevy/render/render_resource/struct.DynamicUniformBuffer.html
Constrain `T : ShaderType`. However, this is overly broad, as uniform buffers only support fixed-size arrays.
`encase` has a trait `ShaderSize` that is automatically implemented by the `ShaderType` derive, if the type has no dynamically sized arrays.
We should constrain `UniformBuffer` and `DynamicUniformBuffer` to `ShaderSize` instead of `ShaderType` to catch these errors at compile time. Currently, using a variable length array will result in a panic from an assertion within `encase` at runtime.
Contributor guide
Assessment
This issue has not been assessed yet.