Default alignment for DynamicStorageBuffer is incorrect.
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
I'm using a `DynamicStorageBuffer` to store a lot of `u32`s and use them in compute shader. I noticed that in `DynamicStorageBuffer::default()` we are initializing `scratch` with `DynamicStorageBufferWrapper` with default alignment that is set to 256 by default (in encase library):
```rs
pub const fn new(buffer: B) -> Self {
Self::new_with_alignment(buffer, 256) // default alignment in wrapper
}
```
I think this is not correct, since we can easily have types with smaller sizes, after I changed `scratch` initialization to `DynamicStorageBufferWrapper::new_with_alignment(Vec::new(), 4)` it seems that everything working fine now. I would create a PR but I'm not sure what is the correct number here, since it does not represent shader type alignment but something else, because it should be a power of 2.
Contributor guide
Research direction
Locate DynamicStorageBuffer::default and its scratch initialization, then inspect DynamicStorageBufferWrapper::new and new_with_alignment to determine what alignment the buffer requires. Confirm the chosen default against the compute-shader use case described, and consider how to verify that storing u32 values works with the corrected alignment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 38/100