Skip to content

Commit 665c075

Browse files
Remove TextureInner::Surface::has_work. (#5200)
When no work is submitted for a frame, presenting the surface results in a timeout due to no work having been submitted. Fixes #3189. This flag was added in #1892 with a note that it was going to be temporary until #1688 landed.
1 parent 245d2da commit 665c075

File tree

4 files changed

+6
-31
lines changed

4 files changed

+6
-31
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ Bottom level categories:
110110
- Device lost callbacks are invoked when replaced and when global is dropped. By @bradwerth in [#5168](https://github.com/gfx-rs/wgpu/pull/5168)
111111
- Fix panic when creating a surface while no backend is available. By @wumpf [#5166](https://github.com/gfx-rs/wgpu/pull/5166)
112112
- Correctly compute minimum buffer size for array-typed `storage` and `uniform` vars. By @jimblandy [#5222](https://github.com/gfx-rs/wgpu/pull/5222)
113+
- Fix timeout when presenting a surface where no work has been done. By @waywardmonkeys in [#5200](https://github.com/gfx-rs/wgpu/pull/5200)
113114

114115
#### WGL
115116

wgpu-core/src/device/queue.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,13 +1222,7 @@ impl Global {
12221222
return Err(QueueSubmitError::DestroyedTexture(id));
12231223
}
12241224
Some(TextureInner::Native { .. }) => false,
1225-
Some(TextureInner::Surface {
1226-
ref has_work,
1227-
ref raw,
1228-
..
1229-
}) => {
1230-
has_work.store(true, Ordering::Relaxed);
1231-
1225+
Some(TextureInner::Surface { ref raw, .. }) => {
12321226
if raw.is_some() {
12331227
submit_surface_textures_owned.push(texture.clone());
12341228
}
@@ -1423,13 +1417,7 @@ impl Global {
14231417
return Err(QueueSubmitError::DestroyedTexture(id));
14241418
}
14251419
Some(TextureInner::Native { .. }) => {}
1426-
Some(TextureInner::Surface {
1427-
ref has_work,
1428-
ref raw,
1429-
..
1430-
}) => {
1431-
has_work.store(true, Ordering::Relaxed);
1432-
1420+
Some(TextureInner::Surface { ref raw, .. }) => {
14331421
if raw.is_some() {
14341422
submit_surface_textures_owned.push(texture.clone());
14351423
}

wgpu-core/src/present.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ When this texture is presented, we remove it from the device tracker as well as
99
extract it from the hub.
1010
!*/
1111

12-
use std::{
13-
borrow::Borrow,
14-
sync::atomic::{AtomicBool, Ordering},
15-
};
12+
use std::borrow::Borrow;
1613

1714
#[cfg(feature = "trace")]
1815
use crate::device::trace::Action;
@@ -213,7 +210,6 @@ impl Global {
213210
inner: Snatchable::new(resource::TextureInner::Surface {
214211
raw: Some(ast.texture),
215212
parent_id: surface_id,
216-
has_work: AtomicBool::new(false),
217213
}),
218214
device: device.clone(),
219215
desc: texture_desc,
@@ -331,15 +327,10 @@ impl Global {
331327
resource::TextureInner::Surface {
332328
ref mut raw,
333329
ref parent_id,
334-
ref has_work,
335330
} => {
336331
if surface_id != *parent_id {
337332
log::error!("Presented frame is from a different surface");
338333
Err(hal::SurfaceError::Lost)
339-
} else if !has_work.load(Ordering::Relaxed) {
340-
log::error!("No work has been submitted for this frame");
341-
unsafe { suf.unwrap().discard_texture(raw.take().unwrap()) };
342-
Err(hal::SurfaceError::Outdated)
343334
} else {
344335
unsafe {
345336
queue
@@ -420,11 +411,7 @@ impl Global {
420411
let suf = A::get_surface(&surface);
421412
let exclusive_snatch_guard = device.snatchable_lock.write();
422413
match texture.inner.snatch(exclusive_snatch_guard).unwrap() {
423-
resource::TextureInner::Surface {
424-
mut raw,
425-
parent_id,
426-
has_work: _,
427-
} => {
414+
resource::TextureInner::Surface { mut raw, parent_id } => {
428415
if surface_id == parent_id {
429416
unsafe { suf.unwrap().discard_texture(raw.take().unwrap()) };
430417
} else {

wgpu-core/src/resource.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use std::{
3131
ops::Range,
3232
ptr::NonNull,
3333
sync::{
34-
atomic::{AtomicBool, AtomicUsize, Ordering},
34+
atomic::{AtomicUsize, Ordering},
3535
Arc, Weak,
3636
},
3737
};
@@ -717,7 +717,6 @@ pub(crate) enum TextureInner<A: HalApi> {
717717
Surface {
718718
raw: Option<A::SurfaceTexture>,
719719
parent_id: SurfaceId,
720-
has_work: AtomicBool,
721720
},
722721
}
723722

0 commit comments

Comments
 (0)