PersistentGpuBufferable probably shouldn't be an unsafe trait #12727
Labels
A-Rendering
Drawing game state to the screen
P-Unsound
A bug that results in undefined compiler behavior
Milestone
A good example of an unsafe trait is
TrustedLen
orWorldQuery
, where the correct implementation of the trait is required to satisfy the safety invariants in its application, and currently PersistentGpuBufferable is not used in such a way. It is not used in any unsafe context CPU-side, and as far as I know, wgpu's validation should prevent any improperly uploading invalid inputs to the GPU.Of the two implementations of the trait, the
Arc<[u8]>
implementation does not actually satisfy the safety invariants requiring proper alignment of the contents (it's min alignment is 1 and wgpu::COPY_BUFFER_ALGINMENT is currently 4 and this is not enforced in it's implementation), and both implementations do not document how they're satisfying the safety invariants.Potential solutions here:
unsafe
.Arc<[u8]>
implementation or enforce its safety invariants.The text was updated successfully, but these errors were encountered: