wgpu: Require Drop on *PassInterface and remove end from it (#8851)

This commit is contained in:
Sam authored and GitHub committed 2026-01-28 15:55:59 -05:00
1 parent e816bd7ed4
commit 2d2b109111
3 files changed
+10 -29

No files matched your search

+2 -10
View File
@@ -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::<js_sys::Array>();
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();
}
}
+6 -14
View File
@@ -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();
+2 -5
View File
@@ -372,7 +372,7 @@ pub trait CommandEncoderInterface: CommonTraits {
texture_transitions: &mut dyn Iterator<Item = wgt::TextureTransition<&'a DispatchTexture>>,
);
}
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<Item = &DispatchRenderBundle>);
fn end(&mut self);
}
pub trait RenderBundleEncoderInterface: CommonTraits {