Skip to content
This repository has been archived by the owner on Jun 18, 2021. It is now read-only.

Commit

Permalink
Merge #900
Browse files Browse the repository at this point in the history
900: Fix initializing buffer with unaligned data r=grovesNL a=Uriopass

In wgpu 0.7, this was a valid operation, the zero padding was done by hand. 
In #872 this logic was removed as an optimization since buffers are already zero initialized, however the slice end was taken from buffer.slice which has to be aligned when mapped.

This is causing issues when trying to update imgui-wgpu-rs (Yatekii/imgui-wgpu-rs#54) to  wgpu 0.8 since they  use U16 index buffers with odd lengths.

Co-authored-by: Pâris DOUADY <[email protected]>
  • Loading branch information
bors[bot] and Uriopass authored May 7, 2021
2 parents 69be1ff + ecbb598 commit e1f5f9a
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/util/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ impl DeviceExt for crate::Device {

let buffer = self.create_buffer(&wgt_descriptor);

buffer
.slice(..unpadded_size)
.get_mapped_range_mut()
buffer.slice(..).get_mapped_range_mut()[..unpadded_size as usize]
.copy_from_slice(descriptor.contents);
buffer.unmap();

Expand Down

0 comments on commit e1f5f9a

Please sign in to comment.