diff --git a/wgpu-bindings/wgpu.h b/wgpu-bindings/wgpu.h index ac330f4de..01c6eefed 100644 --- a/wgpu-bindings/wgpu.h +++ b/wgpu-bindings/wgpu.h @@ -558,11 +558,28 @@ WGPUComputePassId wgpu_command_buffer_begin_compute_pass(WGPUCommandBufferId com WGPURenderPassId wgpu_command_buffer_begin_render_pass(WGPUCommandBufferId command_buffer_id, WGPURenderPassDescriptor desc); +void wgpu_command_buffer_copy_buffer_to_buffer(WGPUCommandBufferId command_buffer_id, + WGPUBufferId src, + uint32_t src_offset, + WGPUBufferId dst, + uint32_t dst_offset, + uint32_t size); + void wgpu_command_buffer_copy_buffer_to_texture(WGPUCommandBufferId command_buffer_id, const WGPUBufferCopyView *source, const WGPUTextureCopyView *destination, WGPUExtent3d copy_size); +void wgpu_command_buffer_copy_texture_to_buffer(WGPUCommandBufferId command_buffer_id, + const WGPUTextureCopyView *source, + const WGPUBufferCopyView *destination, + WGPUExtent3d copy_size); + +void wgpu_command_buffer_copy_texture_to_texture(WGPUCommandBufferId command_buffer_id, + const WGPUTextureCopyView *source, + const WGPUTextureCopyView *destination, + WGPUExtent3d copy_size); + void wgpu_compute_pass_dispatch(WGPUComputePassId pass_id, uint32_t x, uint32_t y, uint32_t z); WGPUCommandBufferId wgpu_compute_pass_end_pass(WGPUComputePassId pass_id); diff --git a/wgpu-native/src/command/transfer.rs b/wgpu-native/src/command/transfer.rs index b43e8e9b8..a9e96e384 100644 --- a/wgpu-native/src/command/transfer.rs +++ b/wgpu-native/src/command/transfer.rs @@ -160,7 +160,7 @@ pub extern "C" fn wgpu_command_buffer_copy_buffer_to_texture( image_extent: conv::map_extent(copy_size), }; let cmb_raw = cmb.raw.last_mut().unwrap(); - let stages = all_image_stages() | all_image_stages(); + let stages = all_buffer_stages() | all_image_stages(); unsafe { cmb_raw.pipeline_barrier( stages .. stages, @@ -236,7 +236,7 @@ pub extern "C" fn wgpu_command_buffer_copy_texture_to_buffer( image_extent: conv::map_extent(copy_size), }; let cmb_raw = cmb.raw.last_mut().unwrap(); - let stages = all_image_stages() | all_image_stages(); + let stages = all_buffer_stages() | all_image_stages(); unsafe { cmb_raw.pipeline_barrier( stages .. stages, diff --git a/wgpu-rs/src/lib.rs b/wgpu-rs/src/lib.rs index 4b222569a..9905bf8e6 100644 --- a/wgpu-rs/src/lib.rs +++ b/wgpu-rs/src/lib.rs @@ -496,6 +496,24 @@ impl CommandBuffer { } } + pub fn copy_buffer_tobuffer( + &mut self, + source: &Buffer, + source_offset: u32, + destination: &Buffer, + destination_offset: u32, + copy_size: u32, + ) { + wgn::wgpu_command_buffer_copy_buffer_to_buffer( + self.id, + source.id, + source_offset, + destination.id, + destination_offset, + copy_size, + ); + } + pub fn copy_buffer_to_texture( &mut self, source: BufferCopyView, @@ -509,6 +527,34 @@ impl CommandBuffer { copy_size, ); } + + pub fn copy_texture_to_buffer( + &mut self, + source: TextureCopyView, + destination: BufferCopyView, + copy_size: Extent3d, + ) { + wgn::wgpu_command_buffer_copy_texture_to_buffer( + self.id, + &source.into_native(), + &destination.into_native(), + copy_size, + ); + } + + pub fn copy_texture_to_texture( + &mut self, + source: TextureCopyView, + destination: TextureCopyView, + copy_size: Extent3d, + ) { + wgn::wgpu_command_buffer_copy_texture_to_texture( + self.id, + &source.into_native(), + &destination.into_native(), + copy_size, + ); + } } impl<'a> RenderPass<'a> {