mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-21 15:00:57 +01:00
Remove zero padding from create_buffer_init
The buffer should already be zeroed so zeroing shouldn't be necessary
This commit is contained in:
1 parent
394ecc51fd
commit
2acc010ab7
2 files changed
+5
-9
No files matched your search
@@ -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
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user