Remove zero padding from create_buffer_init

The buffer should already be zeroed so zeroing shouldn't be necessary
This commit is contained in:
grovesNL committed 2021-04-21 23:03:40 -02:30
1 parent 394ecc51fd
commit 2acc010ab7
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
}