mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-21 06:50:59 +01:00
Merge #872
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:
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