mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Prevent redundant texture and buffer destroy calls
This commit is contained in:
parent
84185eb1da
commit
851f83c61f
4 changed files with 15 additions and 9 deletions
|
@ -184,6 +184,7 @@ impl GPUBufferMethods for GPUBuffer {
|
|||
GPUBufferState::Mapped | GPUBufferState::MappedAtCreation => {
|
||||
self.Unmap();
|
||||
},
|
||||
GPUBufferState::Destroyed => return,
|
||||
_ => {},
|
||||
};
|
||||
if let Err(e) = self
|
||||
|
|
|
@ -18,6 +18,7 @@ use crate::dom::gpudevice::{
|
|||
};
|
||||
use crate::dom::gputextureview::GPUTextureView;
|
||||
use dom_struct::dom_struct;
|
||||
use std::cell::Cell;
|
||||
use std::num::NonZeroU32;
|
||||
use std::string::String;
|
||||
use webgpu::{
|
||||
|
@ -40,6 +41,7 @@ pub struct GPUTexture {
|
|||
dimension: GPUTextureDimension,
|
||||
format: GPUTextureFormat,
|
||||
texture_usage: u32,
|
||||
destroyed: Cell<bool>,
|
||||
}
|
||||
|
||||
impl GPUTexture {
|
||||
|
@ -67,6 +69,7 @@ impl GPUTexture {
|
|||
dimension,
|
||||
format,
|
||||
texture_usage,
|
||||
destroyed: Cell::new(false),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,6 +200,9 @@ impl GPUTextureMethods for GPUTexture {
|
|||
|
||||
/// https://gpuweb.github.io/gpuweb/#dom-gputexture-destroy
|
||||
fn Destroy(&self) {
|
||||
if self.destroyed.get() {
|
||||
return;
|
||||
}
|
||||
if let Err(e) = self
|
||||
.channel
|
||||
.0
|
||||
|
@ -207,5 +213,6 @@ impl GPUTextureMethods for GPUTexture {
|
|||
self.texture.0, e
|
||||
);
|
||||
};
|
||||
self.destroyed.set(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ use servo_config::pref;
|
|||
use smallvec::SmallVec;
|
||||
use std::borrow::Cow;
|
||||
use std::cell::RefCell;
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::collections::HashMap;
|
||||
use std::num::NonZeroU64;
|
||||
use std::rc::Rc;
|
||||
|
@ -475,9 +474,7 @@ impl<'a> WGPU<'a> {
|
|||
))
|
||||
.map_err(|e| format!("{:?}", e))
|
||||
};
|
||||
if result.is_err() {
|
||||
self.encoder_record_error(command_encoder_id, result.clone());
|
||||
}
|
||||
self.encoder_record_error(command_encoder_id, result.clone());
|
||||
self.send_result(device_id, scope_id, result);
|
||||
},
|
||||
WebGPURequest::CopyBufferToBuffer {
|
||||
|
@ -1282,9 +1279,10 @@ impl<'a> WGPU<'a> {
|
|||
result: Result<U, T>,
|
||||
) {
|
||||
if let Err(e) = result {
|
||||
if let Entry::Vacant(v) = self.error_command_encoders.borrow_mut().entry(encoder_id) {
|
||||
v.insert(format!("{:?}", e));
|
||||
}
|
||||
self.error_command_encoders
|
||||
.borrow_mut()
|
||||
.entry(encoder_id)
|
||||
.or_insert_with(|| format!("{:?}", e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue