Skip to content
This repository has been archived by the owner on Jun 18, 2021. It is now read-only.

Remove zero padding from create_buffer_init #872

Merged
merged 1 commit into from
Apr 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/hello-compute/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 4 additions & 8 deletions src/util/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down