mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 09:08:10 +02:00
rusticl/queue: check device error status
If the underlying GPU context hit any execution errors (e.g. it times out or something) we want to report it to the application as well. Cc: mesa-stable Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32929>
This commit is contained in:
parent
2c52ddd1a6
commit
3129fd8dcf
1 changed files with 27 additions and 10 deletions
|
|
@ -6,6 +6,7 @@ use crate::core::platform::*;
|
||||||
use crate::impl_cl_type_trait;
|
use crate::impl_cl_type_trait;
|
||||||
|
|
||||||
use mesa_rust::pipe::context::PipeContext;
|
use mesa_rust::pipe::context::PipeContext;
|
||||||
|
use mesa_rust_gen::*;
|
||||||
use mesa_rust_util::properties::*;
|
use mesa_rust_util::properties::*;
|
||||||
use rusticl_opencl_gen::*;
|
use rusticl_opencl_gen::*;
|
||||||
|
|
||||||
|
|
@ -93,13 +94,22 @@ pub struct Queue {
|
||||||
|
|
||||||
impl_cl_type_trait!(cl_command_queue, Queue, CL_INVALID_COMMAND_QUEUE);
|
impl_cl_type_trait!(cl_command_queue, Queue, CL_INVALID_COMMAND_QUEUE);
|
||||||
|
|
||||||
fn flush_events(evs: &mut Vec<Arc<Event>>, pipe: &PipeContext) {
|
fn flush_events(evs: &mut Vec<Arc<Event>>, pipe: &PipeContext) -> cl_int {
|
||||||
if !evs.is_empty() {
|
if !evs.is_empty() {
|
||||||
pipe.flush().wait();
|
pipe.flush().wait();
|
||||||
|
if pipe.device_reset_status() != pipe_reset_status::PIPE_NO_RESET {
|
||||||
|
// if the context reset while executing, simply put all events into error state.
|
||||||
|
evs.drain(..)
|
||||||
|
.for_each(|e| e.set_user_status(CL_OUT_OF_RESOURCES));
|
||||||
|
return CL_OUT_OF_RESOURCES;
|
||||||
|
} else {
|
||||||
evs.drain(..).for_each(|e| e.signal());
|
evs.drain(..).for_each(|e| e.signal());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CL_SUCCESS as cl_int
|
||||||
|
}
|
||||||
|
|
||||||
impl Queue {
|
impl Queue {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
context: Arc<Context>,
|
context: Arc<Context>,
|
||||||
|
|
@ -152,7 +162,8 @@ impl Queue {
|
||||||
// If we hit any deps from another queue, flush so we don't risk a dead
|
// If we hit any deps from another queue, flush so we don't risk a dead
|
||||||
// lock.
|
// lock.
|
||||||
if e.deps.iter().any(|ev| ev.queue != e.queue) {
|
if e.deps.iter().any(|ev| ev.queue != e.queue) {
|
||||||
flush_events(&mut flushed, &ctx);
|
let dep_err = flush_events(&mut flushed, &ctx);
|
||||||
|
last_err = cmp::min(last_err, dep_err);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if any dependency has an error
|
// check if any dependency has an error
|
||||||
|
|
@ -184,20 +195,23 @@ impl Queue {
|
||||||
if e.is_user() {
|
if e.is_user() {
|
||||||
// On each user event we flush our events as application might
|
// On each user event we flush our events as application might
|
||||||
// wait on them before signaling user events.
|
// wait on them before signaling user events.
|
||||||
flush_events(&mut flushed, &ctx);
|
last_err = flush_events(&mut flushed, &ctx);
|
||||||
|
|
||||||
|
if last_err >= 0 {
|
||||||
// Wait on user events as they are synchronization points in the
|
// Wait on user events as they are synchronization points in the
|
||||||
// application's control.
|
// application's control.
|
||||||
e.wait();
|
e.wait();
|
||||||
|
}
|
||||||
} else if Platform::dbg().sync_every_event {
|
} else if Platform::dbg().sync_every_event {
|
||||||
flushed.push(e);
|
flushed.push(e);
|
||||||
flush_events(&mut flushed, &ctx);
|
last_err = flush_events(&mut flushed, &ctx);
|
||||||
} else {
|
} else {
|
||||||
flushed.push(e);
|
flushed.push(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flush_events(&mut flushed, &ctx);
|
let flush_err = flush_events(&mut flushed, &ctx);
|
||||||
|
last_err = cmp::min(last_err, flush_err);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
|
|
@ -245,7 +259,10 @@ impl Queue {
|
||||||
// Waiting on the last event is good enough here as the queue will process it in order
|
// Waiting on the last event is good enough here as the queue will process it in order
|
||||||
// It's not a problem if the weak ref is invalid as that means the work is already done
|
// It's not a problem if the weak ref is invalid as that means the work is already done
|
||||||
// and waiting isn't necessary anymore.
|
// and waiting isn't necessary anymore.
|
||||||
last.upgrade().map(|e| e.wait());
|
let err = last.upgrade().map(|e| e.wait()).unwrap_or_default();
|
||||||
|
if err < 0 {
|
||||||
|
return Err(err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue