diff --git a/CHANGELOG.md b/CHANGELOG.md index 18d184933e..f3cae9dbb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -110,6 +110,7 @@ Bottom level categories: - Device lost callbacks are invoked when replaced and when global is dropped. By @bradwerth in [#5168](https://github.com/gfx-rs/wgpu/pull/5168) - Fix panic when creating a surface while no backend is available. By @wumpf [#5166](https://github.com/gfx-rs/wgpu/pull/5166) - Correctly compute minimum buffer size for array-typed `storage` and `uniform` vars. By @jimblandy [#5222](https://github.com/gfx-rs/wgpu/pull/5222) +- Fix timeout when presenting a surface where no work has been done. By @waywardmonkeys in [#5200](https://github.com/gfx-rs/wgpu/pull/5200) #### WGL diff --git a/wgpu-core/src/device/queue.rs b/wgpu-core/src/device/queue.rs index 08c5b767b6..b88fd9b906 100644 --- a/wgpu-core/src/device/queue.rs +++ b/wgpu-core/src/device/queue.rs @@ -1222,13 +1222,7 @@ impl Global { return Err(QueueSubmitError::DestroyedTexture(id)); } Some(TextureInner::Native { .. }) => false, - Some(TextureInner::Surface { - ref has_work, - ref raw, - .. - }) => { - has_work.store(true, Ordering::Relaxed); - + Some(TextureInner::Surface { ref raw, .. }) => { if raw.is_some() { submit_surface_textures_owned.push(texture.clone()); } @@ -1423,13 +1417,7 @@ impl Global { return Err(QueueSubmitError::DestroyedTexture(id)); } Some(TextureInner::Native { .. }) => {} - Some(TextureInner::Surface { - ref has_work, - ref raw, - .. - }) => { - has_work.store(true, Ordering::Relaxed); - + Some(TextureInner::Surface { ref raw, .. }) => { if raw.is_some() { submit_surface_textures_owned.push(texture.clone()); } diff --git a/wgpu-core/src/present.rs b/wgpu-core/src/present.rs index 4d8e1df73e..ed1810a653 100644 --- a/wgpu-core/src/present.rs +++ b/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; @@ -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, @@ -331,15 +327,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 @@ -420,11 +411,7 @@ impl Global { 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 { diff --git a/wgpu-core/src/resource.rs b/wgpu-core/src/resource.rs index de5d1868a3..5108328f2b 100644 --- a/wgpu-core/src/resource.rs +++ b/wgpu-core/src/resource.rs @@ -31,7 +31,7 @@ use std::{ ops::Range, ptr::NonNull, sync::{ - atomic::{AtomicBool, AtomicUsize, Ordering}, + atomic::{AtomicUsize, Ordering}, Arc, Weak, }, }; @@ -717,7 +717,6 @@ pub(crate) enum TextureInner { Surface { raw: Option, parent_id: SurfaceId, - has_work: AtomicBool, }, }