u_trace: Add an interface for checking trace enablement outside a context.

For zink, we want to know if we should pass command stream markers down to
the underlying driver, but we don't have our own trace context we're
recording trace events with.  We definitely want those markers if the
underlying driver is going to be doing perfetto tracing, or is requesting
marker tracing.  So, create an interface for querying those flags before
they get copied down to an actual u_trace_context.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20657>
This commit is contained in:
Emma Anholt 2023-02-06 13:18:08 -08:00 committed by Marge Bot
parent fb6e65c72c
commit 4dc6390445
2 changed files with 16 additions and 1 deletions

View file

@ -394,12 +394,24 @@ u_trace_state_init_once(void)
}
}
static void
void
u_trace_state_init(void)
{
util_call_once(&u_trace_state.once, u_trace_state_init_once);
}
bool
u_trace_is_enabled(enum u_trace_type type)
{
/* Active is only tracked in a given u_trace context, so if you're asking us
* if U_TRACE_TYPE_PERFETTO (_ENV | _ACTIVE) is enabled, then just check
* _ENV ("perfetto tracing is desired, but perfetto might not be running").
*/
type &= ~U_TRACE_TYPE_PERFETTO_ACTIVE;
return (u_trace_state.enabled_traces & type) == type;
}
static void
queue_init(struct u_trace_context *utctx)
{

View file

@ -234,6 +234,9 @@ void u_trace_context_process(struct u_trace_context *utctx, bool eof);
void u_trace_init(struct u_trace *ut, struct u_trace_context *utctx);
void u_trace_fini(struct u_trace *ut);
void u_trace_state_init(void);
bool u_trace_is_enabled(enum u_trace_type type);
bool u_trace_has_points(struct u_trace *ut);
struct u_trace_iterator