intel/ds: simplify clock sync emit

In short, perfetto doesn't require the initial clock snapshot to be
earlier than the timestamp to be converted. So we don't have to do
complex handling for it.

With this change:
- renderstage event requires clock sync, so we'd only emit clock
  snapshots on the traceq thread that handles the callbacks
- drops redundant sync_timestamp calls as well as sync_gpu_ts tracking
- no need to reset next_clock_sync_ns when tracing is disabled, since a
  snapshot is always emitted right after the initial interned data emit
  upon tracing start

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37425>
This commit is contained in:
Yiwei Zhang 2025-09-17 21:39:23 -07:00 committed by Marge Bot
parent 7795669953
commit 7689aca21f
2 changed files with 1 additions and 31 deletions

View file

@ -147,7 +147,6 @@ sync_timestamp(IntelRenderpassDataSource::TraceContext &ctx,
PERFETTO_LOG("sending clocks gpu=0x%08x", device->gpu_clock_id);
device->sync_gpu_ts = gpu_ts;
device->next_clock_sync_ns = boottime + 1000000000ull;
MesaRenderpassDataSource<IntelRenderpassDataSource, IntelRenderpassTraits>::EmitClockSync(ctx,
@ -231,7 +230,6 @@ setup_incremental_state(IntelRenderpassDataSource::TraceContext &ctx,
}
device->next_clock_sync_ns = 0;
sync_timestamp(ctx, device);
}
static void
@ -239,14 +237,6 @@ begin_event(struct intel_ds_queue *queue, uint64_t ts_ns,
enum intel_ds_queue_stage stage_id)
{
uint32_t level = queue->stages[stage_id].level;
/* If we haven't managed to calibrate the alignment between GPU and CPU
* timestamps yet, then skip this trace, otherwise perfetto won't know
* what to do with it.
*/
if (!queue->device->sync_gpu_ts) {
queue->stages[stage_id].start_ns[level] = 0;
return;
}
if (level >= (ARRAY_SIZE(queue->stages[stage_id].start_ns) - 1))
return;
@ -267,13 +257,6 @@ end_event(struct intel_ds_queue *queue, uint64_t ts_ns,
{
struct intel_ds_device *device = queue->device;
/* If we haven't managed to calibrate the alignment between GPU and CPU
* timestamps yet, then skip this trace, otherwise perfetto won't know
* what to do with it.
*/
if (!device->sync_gpu_ts)
return;
if (queue->stages[stage_id].level == 0)
return;
@ -540,18 +523,13 @@ void
intel_ds_end_submit(struct intel_ds_queue *queue,
uint64_t start_ts)
{
if (!u_trace_should_process(&queue->device->trace_context)) {
queue->device->sync_gpu_ts = 0;
queue->device->next_clock_sync_ns = 0;
if (!u_trace_should_process(&queue->device->trace_context))
return;
}
uint64_t end_ts = perfetto::base::GetBootTimeNs().count();
uint32_t submission_id = queue->submission_id++;
IntelRenderpassDataSource::Trace([=](IntelRenderpassDataSource::TraceContext tctx) {
sync_timestamp(tctx, queue->device);
auto packet = tctx.NewTracePacket();
packet->set_timestamp(start_ts);

View file

@ -116,14 +116,6 @@ struct intel_ds_device {
/* Clock identifier for this device. */
uint32_t gpu_clock_id;
/* The timestamp at the point where we first emitted the clock_sync..
* this will be a *later* timestamp that the first GPU traces (since
* we capture the first clock_sync from the CPU *after* the first GPU
* tracepoints happen). To avoid confusing perfetto we need to drop
* the GPU traces with timestamps before this.
*/
uint64_t sync_gpu_ts;
/* Next timestamp after which we should resend a clock correlation. */
uint64_t next_clock_sync_ns;