Fix initializing buffer with unaligned data

In wgpu 0.7, this was a valid operation, the zero padding was done by hand. 
However in #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.
This commit is contained in:
Pâris DOUADY authored and Dzmitry Malyshau committed 2021-05-07 10:31:42 -04:00
1 parent c5443c7f55
commit fb442bfa26
1 file changed
+1 -3
+1 -3
View File
@@ -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();