mirror of https://gitlab.freedesktop.org/mesa/mesa
Revert "rusticl/event: use Weak refs for dependencies"
I didn't like the solution and I _think_ it even introduced a potential
regressions involving releasing failed events and that causing dependents
to run and succeed regardless.
This reverts commit a45f199086
.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29190>
This commit is contained in:
parent
3bdfe0e2a3
commit
2f1f98e846
|
@ -14,7 +14,6 @@ use std::sync::Arc;
|
|||
use std::sync::Condvar;
|
||||
use std::sync::Mutex;
|
||||
use std::sync::MutexGuard;
|
||||
use std::sync::Weak;
|
||||
use std::time::Duration;
|
||||
|
||||
// we assert that those are a continous range of numbers so we won't have to use HashMaps
|
||||
|
@ -48,8 +47,7 @@ pub struct Event {
|
|||
pub context: Arc<Context>,
|
||||
pub queue: Option<Arc<Queue>>,
|
||||
pub cmd_type: cl_command_type,
|
||||
// using a Weak ref so we don't cause stack overflows in the `drop` impl
|
||||
pub deps: Vec<Weak<Event>>,
|
||||
pub deps: Vec<Arc<Event>>,
|
||||
state: Mutex<EventMutState>,
|
||||
cv: Condvar,
|
||||
}
|
||||
|
@ -63,7 +61,6 @@ impl Event {
|
|||
deps: Vec<Arc<Event>>,
|
||||
work: EventSig,
|
||||
) -> Arc<Event> {
|
||||
let deps = deps.iter().map(Arc::downgrade).collect();
|
||||
Arc::new(Self {
|
||||
base: CLObjectBase::new(RusticlTypes::Event),
|
||||
context: queue.context.clone(),
|
||||
|
@ -231,18 +228,14 @@ impl Event {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn deps(&self) -> impl Iterator<Item = Arc<Self>> + Clone + '_ {
|
||||
self.deps.iter().filter_map(Weak::upgrade)
|
||||
}
|
||||
|
||||
fn deep_unflushed_deps_impl(self: &Arc<Self>, result: &mut HashSet<Arc<Event>>) {
|
||||
fn deep_unflushed_deps_impl<'a>(&'a self, result: &mut HashSet<&'a Event>) {
|
||||
if self.status() <= CL_SUBMITTED as i32 {
|
||||
return;
|
||||
}
|
||||
|
||||
// only scan dependencies if it's a new one
|
||||
if result.insert(Arc::clone(self)) {
|
||||
for e in self.deps() {
|
||||
if result.insert(self) {
|
||||
for e in &self.deps {
|
||||
e.deep_unflushed_deps_impl(result);
|
||||
}
|
||||
}
|
||||
|
@ -250,7 +243,7 @@ impl Event {
|
|||
|
||||
/// does a deep search and returns a list of all dependencies including `events` which haven't
|
||||
/// been flushed out yet
|
||||
pub fn deep_unflushed_deps(events: &[Arc<Event>]) -> HashSet<Arc<Event>> {
|
||||
pub fn deep_unflushed_deps(events: &[Arc<Event>]) -> HashSet<&Event> {
|
||||
let mut result = HashSet::new();
|
||||
|
||||
for e in events {
|
||||
|
|
|
@ -127,17 +127,16 @@ impl Queue {
|
|||
let mut flushed = Vec::new();
|
||||
|
||||
for e in new_events {
|
||||
let deps_iter = e.deps();
|
||||
|
||||
// If we hit any deps from another queue, flush so we don't risk a dead
|
||||
// lock. Also clone the iter here as we'll iterate again later
|
||||
if deps_iter.clone().any(|ev| ev.queue != e.queue) {
|
||||
// this flush _has_ to happen before we wait on any of the deps
|
||||
// lock.
|
||||
if e.deps.iter().any(|ev| ev.queue != e.queue) {
|
||||
flush_events(&mut flushed, &ctx);
|
||||
}
|
||||
|
||||
// We have to wait on user events or events from other queues.
|
||||
let err = deps_iter
|
||||
let err = e
|
||||
.deps
|
||||
.iter()
|
||||
.filter(|ev| ev.is_user() || ev.queue != e.queue)
|
||||
.map(|e| e.wait())
|
||||
.find(|s| *s < 0);
|
||||
|
|
Loading…
Reference in New Issue