aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKunal Mohan <kunalmohan99@gmail.com>2020-08-08 20:20:07 +0530
committerKunal Mohan <kunalmohan99@gmail.com>2020-08-08 20:20:07 +0530
commit8ff00f0e9c5c7eb232401407c4e5d455423a68d8 (patch)
tree54ff03ff835439c777f1e19be2af0c9ca0e87880
parent33a4bca74d1075b4bbb1a161b757427e34f94ad2 (diff)
downloadservo-8ff00f0e9c5c7eb232401407c4e5d455423a68d8.tar.gz
servo-8ff00f0e9c5c7eb232401407c4e5d455423a68d8.zip
Remove entries from error_command_buffers on drop
-rw-r--r--components/script/dom/gpucommandbuffer.rs16
-rw-r--r--components/webgpu/lib.rs4
2 files changed, 19 insertions, 1 deletions
diff --git a/components/script/dom/gpucommandbuffer.rs b/components/script/dom/gpucommandbuffer.rs
index 6e1eb8446f0..eb6ede84c26 100644
--- a/components/script/dom/gpucommandbuffer.rs
+++ b/components/script/dom/gpucommandbuffer.rs
@@ -13,7 +13,7 @@ use crate::dom::gpubuffer::GPUBuffer;
use dom_struct::dom_struct;
use std::collections::HashSet;
use std::hash::{Hash, Hasher};
-use webgpu::{WebGPU, WebGPUCommandBuffer};
+use webgpu::{WebGPU, WebGPUCommandBuffer, WebGPURequest};
impl Eq for DomRoot<GPUBuffer> {}
impl Hash for DomRoot<GPUBuffer> {
@@ -67,6 +67,20 @@ impl GPUCommandBuffer {
}
}
+impl Drop for GPUCommandBuffer {
+ fn drop(&mut self) {
+ if let Err(e) = self.channel.0.send((
+ None,
+ WebGPURequest::FreeCommandBuffer(self.command_buffer.0),
+ )) {
+ warn!(
+ "Failed to send FreeCommandBuffer({:?}) ({})",
+ self.command_buffer.0, e
+ );
+ }
+ }
+}
+
impl GPUCommandBuffer {
pub fn id(&self) -> WebGPUCommandBuffer {
self.command_buffer
diff --git a/components/webgpu/lib.rs b/components/webgpu/lib.rs
index 944edcfa461..cbfe4cd161e 100644
--- a/components/webgpu/lib.rs
+++ b/components/webgpu/lib.rs
@@ -185,6 +185,7 @@ pub enum WebGPURequest {
},
DestroyTexture(id::TextureId),
Exit(IpcSender<()>),
+ FreeCommandBuffer(id::CommandBufferId),
FreeDevice(id::DeviceId),
RenderBundleEncoderFinish {
render_bundle_encoder: RenderBundleEncoder,
@@ -856,6 +857,9 @@ impl<'a> WGPU<'a> {
}
return;
},
+ WebGPURequest::FreeCommandBuffer(command_buffer_id) => {
+ self.error_command_buffers.remove(&command_buffer_id);
+ },
WebGPURequest::FreeDevice(device_id) => {
let device = WebGPUDevice(device_id);
let pipeline_id = self.devices.remove(&device).unwrap();