872: Remove zero padding from `create_buffer_init` r=kvark a=grovesNL

Follow-up to #870 (https://github.com/gfx-rs/wgpu-rs/pull/870#issuecomment-824333926)

Co-authored-by: grovesNL <josh@joshgroves.com>
This commit is contained in:
bors[bot]andgrovesNL authored and GitHub committed 2021-04-22 02:20:05 +00:00
commit e26c6b146b
2 files changed
+5 -9

No files matched your search

+1 -1
View File
@@ -101,7 +101,7 @@ async fn execute_gpu(numbers: Vec<u32>) -> Vec<u32> {
// It is to WebGPU what a descriptor set is to Vulkan.
// `binding` here refers to the `binding` of a buffer in the shader (`layout(set = 0, binding = 0) buffer`).
// A pipeline specifices the operation of a shader
// A pipeline specifies the operation of a shader
// Instantiates the pipeline.
let compute_pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor {
+4 -8
View File
@@ -53,14 +53,10 @@ impl DeviceExt for crate::Device {
};
let buffer = self.create_buffer(&wgt_descriptor);
{
let mut slice = buffer.slice(..).get_mapped_range_mut();
slice[0..unpadded_size as usize].copy_from_slice(descriptor.contents);
for i in unpadded_size..padded_size {
slice[i as usize] = 0;
}
}
buffer
.slice(..unpadded_size)
.get_mapped_range_mut()
.copy_from_slice(descriptor.contents);
buffer.unmap();
buffer
}