From fb442bfa26c8338053fc71979c03a2374527b2c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A2ris=20DOUADY?= Date: Fri, 7 May 2021 13:50:49 +0200 Subject: [PATCH] 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. --- src/util/device.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/util/device.rs b/src/util/device.rs index fd9f3c77d..605c512cb 100644 --- a/src/util/device.rs +++ b/src/util/device.rs @@ -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();