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

Commit

Permalink
Merge #872
Browse files Browse the repository at this point in the history
872: Remove zero padding from `create_buffer_init` r=kvark a=grovesNL

Follow-up to #870 (#870 (comment))

Co-authored-by: grovesNL <[email protected]>
  • Loading branch information
bors[bot] and grovesNL authored Apr 22, 2021
2 parents 394ecc5 + 2acc010 commit e26c6b1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
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

0 comments on commit e26c6b1

Please sign in to comment.