anv: add tracepoints timestamp mode for empty dispatches

When the runtime is going to potentially emit no dispatch, we need to
have a way to capture a timestamp. Add a new flag for this to tell
whether we don't have a HW instruction to capture the timestamp and
rely on MI_STORE_REGISTER_MEM instead.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: de00fe3f66 ("anv: add BVH building tracking through u_trace")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12382
Reviewed-by: Sagar Ghuge <sagar.ghuge@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32835>
This commit is contained in:
Lionel Landwerlin 2025-01-02 15:34:16 +02:00 committed by Marge Bot
parent a224105a26
commit 6281b207db
4 changed files with 50 additions and 27 deletions

View file

@ -112,7 +112,7 @@ iris_utrace_record_ts(struct u_trace *trace, void *cs,
const bool is_end_compute =
cs == NULL &&
(flags & INTEL_DS_TRACEPOINT_FLAG_END_OF_PIPE_CS);
(flags & INTEL_DS_TRACEPOINT_FLAG_END_CS);
if (is_end_compute) {
assert(ice->utrace.last_compute_walker != NULL);
batch->screen->vtbl.rewrite_compute_walker_pc(

View file

@ -71,8 +71,14 @@ enum intel_ds_tracepoint_flags {
/**
* Whether this tracepoint's timestamp is recorded on the compute pipeline.
*/
INTEL_DS_TRACEPOINT_FLAG_END_OF_PIPE_CS = BITFIELD_BIT(1),
INTEL_DS_TRACEPOINT_FLAG_END_CS = BITFIELD_BIT(1),
/**
* Whether this tracepoint's timestamp is recorded on the compute pipeline
* or from top of pipe if there was no dispatch (useful for acceleration
* structure builds where the runtime might choose to not emit anything for
* a number of reasons).
*/
INTEL_DS_TRACEPOINT_FLAG_END_CS_OR_NOOP = BITFIELD_BIT(2),
};
/* Convert internal driver PIPE_CONTROL stall bits to intel_ds_stall_flag. */

View file

@ -47,7 +47,7 @@ def define_tracepoints(args):
def begin_end_tp(name, tp_args=[], tp_struct=None, tp_print=None,
tp_default_enabled=True, end_pipelined=True,
compute=False,
compute=False, maybe_compute=False,
need_cs_param=False):
global intel_default_tps
if tp_default_enabled:
@ -59,7 +59,9 @@ def define_tracepoints(args):
tp_flags = []
if end_pipelined:
if compute:
tp_flags.append('INTEL_DS_TRACEPOINT_FLAG_END_OF_PIPE_CS')
tp_flags.append('INTEL_DS_TRACEPOINT_FLAG_END_CS')
elif maybe_compute:
tp_flags.append('INTEL_DS_TRACEPOINT_FLAG_END_CS_OR_NOOP')
else:
tp_flags.append('INTEL_DS_TRACEPOINT_FLAG_END_OF_PIPE')
Tracepoint('intel_end_{0}'.format(name),
@ -199,13 +201,13 @@ def define_tracepoints(args):
need_cs_param=True)
begin_end_tp('as_build')
begin_end_tp('as_build_leaves', compute=True)
begin_end_tp('as_morton_generate', compute=True)
begin_end_tp('as_morton_sort', compute=True)
begin_end_tp('as_lbvh_build_internal', compute=True)
begin_end_tp('as_ploc_build_internal', compute=True)
begin_end_tp('as_encode', compute=True)
begin_end_tp('as_copy', compute=True)
begin_end_tp('as_build_leaves', maybe_compute=True)
begin_end_tp('as_morton_generate', maybe_compute=True)
begin_end_tp('as_morton_sort', maybe_compute=True)
begin_end_tp('as_lbvh_build_internal', maybe_compute=True)
begin_end_tp('as_ploc_build_internal', maybe_compute=True)
begin_end_tp('as_encode', maybe_compute=True)
begin_end_tp('as_copy', maybe_compute=True)
begin_end_tp('rays',
tp_args=[Arg(type='uint32_t', var='group_x', c_format='%u'),

View file

@ -350,21 +350,36 @@ anv_utrace_record_ts(struct u_trace *ut, void *cs,
/* Is this a end of compute trace point? */
const bool is_end_compute =
cs == NULL &&
(flags & INTEL_DS_TRACEPOINT_FLAG_END_OF_PIPE_CS);
assert(device->info->verx10 < 125 ||
!is_end_compute ||
cmd_buffer->state.last_indirect_dispatch != NULL ||
cmd_buffer->state.last_compute_walker != NULL);
enum anv_timestamp_capture_type capture_type =
(device->info->verx10 >= 125 && is_end_compute) ?
(cmd_buffer->state.last_indirect_dispatch != NULL ?
ANV_TIMESTAMP_REWRITE_INDIRECT_DISPATCH : ANV_TIMESTAMP_REWRITE_COMPUTE_WALKER) :
(flags & (INTEL_DS_TRACEPOINT_FLAG_END_OF_PIPE |
INTEL_DS_TRACEPOINT_FLAG_END_OF_PIPE_CS)) ?
ANV_TIMESTAMP_CAPTURE_END_OF_PIPE : ANV_TIMESTAMP_CAPTURE_TOP_OF_PIPE;
(flags & INTEL_DS_TRACEPOINT_FLAG_END_CS);
const bool is_end_compute_or_noop =
cs == NULL &&
(flags & INTEL_DS_TRACEPOINT_FLAG_END_CS_OR_NOOP);
enum anv_timestamp_capture_type capture_type;
if (is_end_compute) {
assert(device->info->verx10 < 125 ||
!is_end_compute ||
cmd_buffer->state.last_indirect_dispatch != NULL ||
cmd_buffer->state.last_compute_walker != NULL);
capture_type =
device->info->verx10 >= 125 ?
(cmd_buffer->state.last_indirect_dispatch != NULL ?
ANV_TIMESTAMP_REWRITE_INDIRECT_DISPATCH :
ANV_TIMESTAMP_REWRITE_COMPUTE_WALKER) :
ANV_TIMESTAMP_CAPTURE_END_OF_PIPE;
} else if (is_end_compute_or_noop) {
capture_type =
device->info->verx10 >= 125 ?
(cmd_buffer->state.last_indirect_dispatch != NULL ?
ANV_TIMESTAMP_REWRITE_INDIRECT_DISPATCH :
(cmd_buffer->state.last_compute_walker != NULL ?
ANV_TIMESTAMP_REWRITE_COMPUTE_WALKER :
ANV_TIMESTAMP_CAPTURE_TOP_OF_PIPE)) :
ANV_TIMESTAMP_CAPTURE_TOP_OF_PIPE;
} else {
capture_type = (flags & INTEL_DS_TRACEPOINT_FLAG_END_CS) ?
ANV_TIMESTAMP_CAPTURE_END_OF_PIPE :
ANV_TIMESTAMP_CAPTURE_TOP_OF_PIPE;
}
void *addr = capture_type == ANV_TIMESTAMP_REWRITE_INDIRECT_DISPATCH ?
cmd_buffer->state.last_indirect_dispatch :