Remove entries from error_command_buffers on drop

This commit is contained in:
Kunal Mohan 2020-08-08 20:20:07 +05:30
parent 33a4bca74d
commit 8ff00f0e9c
2 changed files with 19 additions and 1 deletions

View file

@ -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