mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-17 02:18:21 +02:00
rusticl: Flush perfetto track events
Flush periodically in the single and worker thread. And also before thread exit. Signed-off-by: Rob Clark <rob.clark@oss.qualcomm.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/42013>
This commit is contained in:
parent
f68e6f8848
commit
4adf158aef
3 changed files with 45 additions and 11 deletions
|
|
@ -358,6 +358,12 @@ fn flush_events(
|
|||
CL_SUCCESS as cl_int
|
||||
}
|
||||
|
||||
fn flush_perfetto() {
|
||||
unsafe {
|
||||
util_perfetto_thread_flush();
|
||||
}
|
||||
}
|
||||
|
||||
impl Queue {
|
||||
pub fn new(
|
||||
context: Arc<Context>,
|
||||
|
|
@ -417,8 +423,19 @@ impl Queue {
|
|||
loop {
|
||||
debug_assert!(flushed.is_empty());
|
||||
|
||||
let Ok(new_events) = rx_t.recv() else {
|
||||
break;
|
||||
let new_events = match rx_t.try_recv() {
|
||||
Ok(evs) => evs,
|
||||
Err(_) => {
|
||||
// Flush thread's track events before blocking:
|
||||
flush_perfetto();
|
||||
|
||||
// break out of the loop when we get an error as this
|
||||
// indicates the sender has disconnected.
|
||||
let Ok(new_events) = rx_t.recv() else {
|
||||
break;
|
||||
};
|
||||
new_events
|
||||
}
|
||||
};
|
||||
|
||||
let new_events = QueueEvents::new(new_events);
|
||||
|
|
@ -478,21 +495,36 @@ impl Queue {
|
|||
let flush_err = flush_events(&mut flushed, &ctx, &tx_q2);
|
||||
last_err = cmp::min(last_err, flush_err);
|
||||
}
|
||||
flush_perfetto();
|
||||
})
|
||||
.unwrap(),
|
||||
_thrd_signal: thread::Builder::new()
|
||||
.name("rusticl queue signal thread".into())
|
||||
.spawn(move || loop {
|
||||
let Ok((fence, events)) = rx_t2.recv() else {
|
||||
break;
|
||||
};
|
||||
.spawn(move || {
|
||||
loop {
|
||||
let (fence, events) = match rx_t2.try_recv() {
|
||||
Ok((fence, events)) => (fence, events),
|
||||
Err(_) => {
|
||||
// Flush thread's track events before blocking:
|
||||
flush_perfetto();
|
||||
|
||||
let evs = events.iter();
|
||||
if fence.wait() {
|
||||
evs.for_each(|e| e.signal());
|
||||
} else {
|
||||
evs.for_each(|e| e.set_user_status(CL_OUT_OF_RESOURCES));
|
||||
// break out of the loop when we get an error as this
|
||||
// indicates the sender has disconnected.
|
||||
let Ok((fence, events)) = rx_t2.recv() else {
|
||||
break;
|
||||
};
|
||||
(fence, events)
|
||||
}
|
||||
};
|
||||
|
||||
let evs = events.iter();
|
||||
if fence.wait() {
|
||||
evs.for_each(|e| e.signal());
|
||||
} else {
|
||||
evs.for_each(|e| e.set_user_status(CL_OUT_OF_RESOURCES));
|
||||
}
|
||||
}
|
||||
flush_perfetto();
|
||||
})
|
||||
.unwrap(),
|
||||
}))
|
||||
|
|
|
|||
|
|
@ -281,6 +281,7 @@ rusticl_mesa_bindings = rust.bindgen(
|
|||
'--allowlist-function', 'util_queue_.*',
|
||||
'--allowlist-function', 'util_vma_.*',
|
||||
'--allowlist-function', 'util_get_cpu_caps',
|
||||
'--allowlist-function', 'util_perfetto_thread_flush',
|
||||
'--no-copy', 'util_vma_heap', # it's a linked list
|
||||
'--no-copy', 'util_queue',
|
||||
'--no-copy', 'util_queue_fence',
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include "util/disk_cache.h"
|
||||
#include "util/hex.h"
|
||||
#include "util/os_time.h"
|
||||
#include "util/perf/u_perfetto.h"
|
||||
#include "util/u_cpu_detect.h"
|
||||
#include "util/u_inlines.h"
|
||||
#include "util/u_upload_mgr.h"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue