diff --git a/wgpu/src/backend/webgpu.rs b/wgpu/src/backend/webgpu.rs index 2fc6167a6..742e33cfb 100644 --- a/wgpu/src/backend/webgpu.rs +++ b/wgpu/src/backend/webgpu.rs @@ -3424,14 +3424,10 @@ impl dispatch::ComputePassInterface for WebComputePassEncoder { self.inner .dispatch_workgroups_indirect_with_f64(&indirect_buffer.inner, indirect_offset as f64); } - - fn end(&mut self) { - self.inner.end(); - } } impl Drop for WebComputePassEncoder { fn drop(&mut self) { - dispatch::ComputePassInterface::end(self); + self.inner.end(); } } @@ -3724,14 +3720,10 @@ impl dispatch::RenderPassInterface for WebRenderPassEncoder { .collect::(); self.inner.execute_bundles(&mapped); } - - fn end(&mut self) { - self.inner.end(); - } } impl Drop for WebRenderPassEncoder { fn drop(&mut self) { - dispatch::RenderPassInterface::end(self); + self.inner.end(); } } diff --git a/wgpu/src/backend/wgpu_core.rs b/wgpu/src/backend/wgpu_core.rs index 17ae5ba9a..662e6e208 100644 --- a/wgpu/src/backend/wgpu_core.rs +++ b/wgpu/src/backend/wgpu_core.rs @@ -3078,8 +3078,10 @@ impl dispatch::ComputePassInterface for CoreComputePass { ); } } +} - fn end(&mut self) { +impl Drop for CoreComputePass { + fn drop(&mut self) { if let Err(cause) = self.context.0.compute_pass_end(&mut self.pass) { self.context.handle_error( &self.error_sink, @@ -3091,12 +3093,6 @@ impl dispatch::ComputePassInterface for CoreComputePass { } } -impl Drop for CoreComputePass { - fn drop(&mut self) { - dispatch::ComputePassInterface::end(self); - } -} - impl dispatch::RenderPassInterface for CoreRenderPass { fn set_pipeline(&mut self, pipeline: &dispatch::DispatchRenderPipeline) { let pipeline = pipeline.as_core(); @@ -3693,8 +3689,10 @@ impl dispatch::RenderPassInterface for CoreRenderPass { ); } } +} - fn end(&mut self) { +impl Drop for CoreRenderPass { + fn drop(&mut self) { if let Err(cause) = self.context.0.render_pass_end(&mut self.pass) { self.context.handle_error( &self.error_sink, @@ -3706,12 +3704,6 @@ impl dispatch::RenderPassInterface for CoreRenderPass { } } -impl Drop for CoreRenderPass { - fn drop(&mut self) { - dispatch::RenderPassInterface::end(self); - } -} - impl dispatch::RenderBundleEncoderInterface for CoreRenderBundleEncoder { fn set_pipeline(&mut self, pipeline: &dispatch::DispatchRenderPipeline) { let pipeline = pipeline.as_core(); diff --git a/wgpu/src/dispatch.rs b/wgpu/src/dispatch.rs index 21f30d010..bd5a97cce 100644 --- a/wgpu/src/dispatch.rs +++ b/wgpu/src/dispatch.rs @@ -372,7 +372,7 @@ pub trait CommandEncoderInterface: CommonTraits { texture_transitions: &mut dyn Iterator>, ); } -pub trait ComputePassInterface: CommonTraits { +pub trait ComputePassInterface: CommonTraits + Drop { fn set_pipeline(&mut self, pipeline: &DispatchComputePipeline); fn set_bind_group( &mut self, @@ -396,9 +396,8 @@ pub trait ComputePassInterface: CommonTraits { indirect_buffer: &DispatchBuffer, indirect_offset: crate::BufferAddress, ); - fn end(&mut self); } -pub trait RenderPassInterface: CommonTraits { +pub trait RenderPassInterface: CommonTraits + Drop { fn set_pipeline(&mut self, pipeline: &DispatchRenderPipeline); fn set_bind_group( &mut self, @@ -507,8 +506,6 @@ pub trait RenderPassInterface: CommonTraits { fn end_pipeline_statistics_query(&mut self); fn execute_bundles(&mut self, render_bundles: &mut dyn Iterator); - - fn end(&mut self); } pub trait RenderBundleEncoderInterface: CommonTraits {