Skip to content

Commit

Permalink
Fix initializing buffer with unaligned data
Browse files Browse the repository at this point in the history
In wgpu 0.7, this was a valid operation, the zero padding was done by hand. 
However in gfx-rs#872 this was removed as an optimization since buffers are zero padded, however the slice end was taken from buffer.slice which has to be aligned when mapped.
  • Loading branch information
Uriopass authored and kvark committed May 7, 2021
1 parent c5443c7 commit fb442bf
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 fb442bf

Please sign in to comment.