diff --git a/crates/ec-hw/src/dec/mod.rs b/crates/ec-hw/src/dec/mod.rs
index 8f776ac0..35d522df 100644
--- a/crates/ec-hw/src/dec/mod.rs
+++ b/crates/ec-hw/src/dec/mod.rs
@@ -19,7 +19,6 @@
use std::collections::VecDeque;
use std::rc::Rc;
-use std::sync::atomic::Ordering;
use std::time::{Duration, Instant};
use ec_va::caps::{Entrypoint, Profile};
@@ -264,12 +263,12 @@ pub(crate) struct Session {
born_epoch: u64,
/// The last submitted picture, waited for after the next one is submitted
/// (depth-1 pipelining; see [`Session::submit`]).
- pending: std::sync::Mutex>,
+ pending: std::cell::RefCell >,
/// Set once a picture hung or lost the GPU context. Every submission after
/// that is refused: on Mesa, submitting to a context the kernel has reset
/// aborts the whole process from the driver's own thread, which no
/// `catch_unwind` can stop.
- pub(crate) poisoned: std::sync::atomic::AtomicBool,
+ pub(crate) poisoned: std::cell::Cell,
pub(crate) context: Rc,
display: Rc,
/// The readback image every frame of this stream reuses.
@@ -363,8 +362,8 @@ impl Session {
}
Ok(Session {
born_epoch,
- pending: std::sync::Mutex::new(None),
- poisoned: std::sync::atomic::AtomicBool::new(false),
+ pending: std::cell::RefCell::new(None),
+ poisoned: std::cell::Cell::new(false),
context,
display: Rc::clone(display),
pool,
@@ -416,7 +415,8 @@ impl Session {
// An old pending picture is waited for first: its wait is instant when
// it is done, and an error condemns the session before we submit.
let stale = self
- .pending_slot()
+ .pending
+ .borrow()
.as_ref()
.filter(|p| p.since.elapsed() > IDLE_SETTLE)
.map(|p| Rc::clone(&p.surface));
@@ -443,7 +443,7 @@ impl Session {
}
return Err(e.into());
}
- let previous = self.pending_slot().replace(Pending {
+ let previous = self.pending.borrow_mut().replace(Pending {
surface: Rc::clone(target),
since: Instant::now(),
});
@@ -453,27 +453,20 @@ impl Session {
Ok(())
}
- fn pending_slot(&self) -> std::sync::MutexGuard<'_, Option> {
- match self.pending.lock() {
- Ok(slot) => slot,
- Err(poisoned) => poisoned.into_inner(),
- }
- }
-
fn check_alive(&self) -> Result<()> {
if crate::reset::gpu_reset_epoch() != self.born_epoch {
return Err(Error::hw_reset(
"the GPU was reset after this session was created; its context is lost",
));
}
- if self.poisoned.load(Ordering::Acquire) {
+ if self.poisoned.get() {
return Err(Error::poisoned("an earlier picture failed on the GPU"));
}
Ok(())
}
fn poison(&self) {
- if !self.poisoned.swap(true, Ordering::AcqRel) {
+ if !self.poisoned.replace(true) {
crate::reset::report_gpu_reset();
}
}