c/main: Pass GPU info to pacer

This commit is contained in:
Jakob Bornecrantz 2022-09-22 23:57:33 +01:00 committed by Jakob Bornecrantz
parent 08f6440aa4
commit 676e071aca
3 changed files with 46 additions and 11 deletions

View file

@ -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);
}

View file

@ -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
*

View file

@ -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);
}