diff --git a/src/xrt/compositor/main/comp_renderer.c b/src/xrt/compositor/main/comp_renderer.c index 28c2a98d8..05fd87c76 100644 --- a/src/xrt/compositor/main/comp_renderer.c +++ b/src/xrt/compositor/main/comp_renderer.c @@ -1615,17 +1615,8 @@ comp_renderer_draw(struct comp_renderer *r) uint64_t gpu_start_ns, gpu_end_ns; if (render_resources_get_timestamps(&c->nr, &gpu_start_ns, &gpu_end_ns)) { - //! @todo submit data to target (pacer). - (void)frame_id; - -#define TE_BEG(TRACK, TIME, NAME) U_TRACE_EVENT_BEGIN_ON_TRACK_DATA(timing, TRACK, TIME, NAME, PERCETTO_I(frame_id)) -#define TE_END(TRACK, TIME) U_TRACE_EVENT_END_ON_TRACK(timing, TRACK, TIME) - - TE_BEG(pc_gpu, gpu_start_ns, "gpu"); - TE_END(pc_gpu, gpu_end_ns); - -#undef TE_BEG -#undef TE_END + uint64_t now_ns = os_monotonic_get_ns(); + comp_target_info_gpu(ct, frame_id, gpu_start_ns, gpu_end_ns, now_ns); } diff --git a/src/xrt/compositor/main/comp_target.h b/src/xrt/compositor/main/comp_target.h index 2c20dfedb..9519c998e 100644 --- a/src/xrt/compositor/main/comp_target.h +++ b/src/xrt/compositor/main/comp_target.h @@ -213,6 +213,23 @@ struct comp_target */ VkResult (*update_timings)(struct comp_target *ct); + /*! + * Provide frame timing information about GPU start and stop time. + * + * Depend on when the information is delivered this can be called at any + * point of the following frames. + * + * @param[in] ct The compositor target. + * @param[in] frame_id The frame ID to record for. + * @param[in] gpu_start_ns When the GPU work startred. + * @param[in] gpu_end_ns When the GPU work stopped. + * @param[in] when_ns When the informatioon collected, nominally + * from @ref os_monotonic_get_ns. + * + * @see @ref frame-pacing. + */ + void (*info_gpu)( + struct comp_target *ct, int64_t frame_id, uint64_t gpu_start_ns, uint64_t gpu_end_ns, uint64_t when_ns); /* * @@ -452,6 +469,21 @@ comp_target_update_timings(struct comp_target *ct) return ct->update_timings(ct); } +/*! + * @copydoc comp_target::info_gpu + * + * @public @memberof comp_target + * @ingroup comp_main + */ +static inline void +comp_target_info_gpu( + struct comp_target *ct, int64_t frame_id, uint64_t gpu_start_ns, uint64_t gpu_end_ns, uint64_t when_ns) +{ + COMP_TRACE_MARKER(); + + ct->info_gpu(ct, frame_id, gpu_start_ns, gpu_end_ns, when_ns); +} + /*! * @copydoc comp_target::set_title * diff --git a/src/xrt/compositor/main/comp_target_swapchain.c b/src/xrt/compositor/main/comp_target_swapchain.c index 3b76fce52..03a3bd345 100644 --- a/src/xrt/compositor/main/comp_target_swapchain.c +++ b/src/xrt/compositor/main/comp_target_swapchain.c @@ -971,6 +971,17 @@ comp_target_swapchain_update_timings(struct comp_target *ct) return VK_SUCCESS; } +static void +comp_target_swapchain_info_gpu( + struct comp_target *ct, int64_t frame_id, uint64_t gpu_start_ns, uint64_t gpu_end_ns, uint64_t when_ns) +{ + COMP_TRACE_MARKER(); + + struct comp_target_swapchain *cts = (struct comp_target_swapchain *)ct; + + u_pc_info_gpu(cts->upc, frame_id, gpu_start_ns, gpu_end_ns, when_ns); +} + /* * @@ -1026,5 +1037,6 @@ comp_target_swapchain_init_and_set_fnptrs(struct comp_target_swapchain *cts, cts->base.calc_frame_pacing = comp_target_swapchain_calc_frame_pacing; cts->base.mark_timing_point = comp_target_swapchain_mark_timing_point; cts->base.update_timings = comp_target_swapchain_update_timings; + cts->base.info_gpu = comp_target_swapchain_info_gpu; os_thread_helper_init(&cts->vblank.event_thread); }