diff options
Diffstat (limited to 'third_party/rust/wgpu-core/src/present.rs')
-rw-r--r-- | third_party/rust/wgpu-core/src/present.rs | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/third_party/rust/wgpu-core/src/present.rs b/third_party/rust/wgpu-core/src/present.rs index 4d8e1df73e..cb4e17798f 100644 --- a/third_party/rust/wgpu-core/src/present.rs +++ b/third_party/rust/wgpu-core/src/present.rs @@ -9,10 +9,7 @@ When this texture is presented, we remove it from the device tracker as well as extract it from the hub. !*/ -use std::{ - borrow::Borrow, - sync::atomic::{AtomicBool, Ordering}, -}; +use std::borrow::Borrow; #[cfg(feature = "trace")] use crate::device::trace::Action; @@ -73,7 +70,7 @@ pub enum ConfigureSurfaceError { PreviousOutputExists, #[error("Both `Surface` width and height must be non-zero. Wait to recreate the `Surface` until the window has non-zero area.")] ZeroArea, - #[error("`Surface` width and height must be within the maximum supported texture size. Requested was ({width}, {height}), maximum extent is {max_texture_dimension_2d}.")] + #[error("`Surface` width and height must be within the maximum supported texture size. Requested was ({width}, {height}), maximum extent for either dimension is {max_texture_dimension_2d}.")] TooLarge { width: u32, height: u32, @@ -213,7 +210,6 @@ impl Global { inner: Snatchable::new(resource::TextureInner::Surface { raw: Some(ast.texture), parent_id: surface_id, - has_work: AtomicBool::new(false), }), device: device.clone(), desc: texture_desc, @@ -224,7 +220,10 @@ impl Global { layers: 0..1, mips: 0..1, }, - info: ResourceInfo::new("<Surface>"), + info: ResourceInfo::new( + "<Surface Texture>", + Some(device.tracker_indices.textures.clone()), + ), clear_mode: RwLock::new(resource::TextureClearMode::Surface { clear_view: Some(clear_view), }), @@ -240,7 +239,7 @@ impl Global { let mut trackers = device.trackers.lock(); trackers .textures - .insert_single(id, resource, hal::TextureUses::UNINITIALIZED); + .insert_single(resource, hal::TextureUses::UNINITIALIZED); } if present.acquired_texture.is_some() { @@ -298,8 +297,7 @@ impl Global { if !device.is_valid() { return Err(DeviceError::Lost.into()); } - let queue_id = device.queue_id.read().unwrap(); - let queue = hub.queues.get(queue_id).unwrap(); + let queue = device.get_queue().unwrap(); #[cfg(feature = "trace")] if let Some(ref mut trace) = *device.trace.lock() { @@ -318,10 +316,13 @@ impl Global { "Removing swapchain texture {:?} from the device tracker", texture_id ); - device.trackers.lock().textures.remove(texture_id); - let texture = hub.textures.unregister(texture_id); if let Some(texture) = texture { + device + .trackers + .lock() + .textures + .remove(texture.info.tracker_index()); let mut exclusive_snatch_guard = device.snatchable_lock.write(); let suf = A::get_surface(&surface); let mut inner = texture.inner_mut(&mut exclusive_snatch_guard); @@ -331,15 +332,10 @@ impl Global { resource::TextureInner::Surface { ref mut raw, ref parent_id, - ref has_work, } => { if surface_id != *parent_id { log::error!("Presented frame is from a different surface"); Err(hal::SurfaceError::Lost) - } else if !has_work.load(Ordering::Relaxed) { - log::error!("No work has been submitted for this frame"); - unsafe { suf.unwrap().discard_texture(raw.take().unwrap()) }; - Err(hal::SurfaceError::Outdated) } else { unsafe { queue @@ -413,18 +409,19 @@ impl Global { "Removing swapchain texture {:?} from the device tracker", texture_id ); - device.trackers.lock().textures.remove(texture_id); let texture = hub.textures.unregister(texture_id); + if let Some(texture) = texture { + device + .trackers + .lock() + .textures + .remove(texture.info.tracker_index()); let suf = A::get_surface(&surface); let exclusive_snatch_guard = device.snatchable_lock.write(); match texture.inner.snatch(exclusive_snatch_guard).unwrap() { - resource::TextureInner::Surface { - mut raw, - parent_id, - has_work: _, - } => { + resource::TextureInner::Surface { mut raw, parent_id } => { if surface_id == parent_id { unsafe { suf.unwrap().discard_texture(raw.take().unwrap()) }; } else { |