mirror of https://gitlab.freedesktop.org/mesa/mesa
util/perf: simplify u_trace_instrument
When ut_perfetto_enabled changes, update _u_trace_instrument as well. This allows u_trace_instrument to check just a single variable. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18309>
This commit is contained in:
parent
18d7cb4abb
commit
4d747d5690
|
@ -38,7 +38,7 @@
|
|||
#define TIMESTAMP_BUF_SIZE 0x1000
|
||||
#define TRACES_PER_CHUNK (TIMESTAMP_BUF_SIZE / sizeof(uint64_t))
|
||||
|
||||
bool _u_trace_instrument;
|
||||
int _u_trace_instrument;
|
||||
|
||||
#ifdef HAVE_PERFETTO
|
||||
int ut_perfetto_enabled;
|
||||
|
@ -369,7 +369,8 @@ get_tracefile(void)
|
|||
tracefile = stdout;
|
||||
}
|
||||
|
||||
_u_trace_instrument = tracefile || debug_get_option_trace_instrument();
|
||||
if (tracefile || debug_get_option_trace_instrument())
|
||||
p_atomic_inc(&_u_trace_instrument);
|
||||
|
||||
firsttime = false;
|
||||
}
|
||||
|
@ -465,14 +466,16 @@ u_trace_perfetto_start(void)
|
|||
{
|
||||
list_for_each_entry (struct u_trace_context, utctx, &ctx_list, node)
|
||||
queue_init(utctx);
|
||||
ut_perfetto_enabled++;
|
||||
if (p_atomic_inc_return(&ut_perfetto_enabled) == 1)
|
||||
p_atomic_inc(&_u_trace_instrument);
|
||||
}
|
||||
|
||||
void
|
||||
u_trace_perfetto_stop(void)
|
||||
{
|
||||
assert(ut_perfetto_enabled > 0);
|
||||
ut_perfetto_enabled--;
|
||||
if (p_atomic_dec_return(&ut_perfetto_enabled) == 0)
|
||||
p_atomic_dec(&_u_trace_instrument);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "util/u_atomic.h"
|
||||
#include "util/u_queue.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -286,8 +287,8 @@ void u_trace_perfetto_stop(void);
|
|||
static inline bool
|
||||
u_trace_instrument(void)
|
||||
{
|
||||
extern bool _u_trace_instrument;
|
||||
return _u_trace_instrument || ut_perfetto_enabled;
|
||||
extern int _u_trace_instrument;
|
||||
return p_atomic_read_relaxed(&_u_trace_instrument);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
|
|
Loading…
Reference in New Issue