u/pacing: Track when the app wants the frame to be displayed

This commit is contained in:
Jakob Bornecrantz 2022-03-30 12:26:35 +01:00 committed by Jakob Bornecrantz
parent 8e8a0b38c6
commit 47649f56b6
3 changed files with 16 additions and 8 deletions
src/xrt

View file

@ -319,11 +319,12 @@ struct u_pacing_app
* A frame has been delivered from the client, see `xrEndFrame`. The GPU might
* still be rendering the work.
*
* @param upa Render timing helper.
* @param[in] frame_id The frame ID to mark as delivered.
* @param[in] when_ns The time when it was delivered, nominally from @ref os_monotonic_get_ns
* @param upa Render timing helper.
* @param[in] frame_id The frame ID to mark as delivered.
* @param[in] when_ns The time when it was delivered, nominally from @ref os_monotonic_get_ns
* @param[in] display_time_ns The time the frame is to be displayed.
*/
void (*mark_delivered)(struct u_pacing_app *upa, int64_t frame_id, uint64_t when_ns);
void (*mark_delivered)(struct u_pacing_app *upa, int64_t frame_id, uint64_t when_ns, uint64_t display_time_ns);
/*!
* A frame has been completed rendered by the GPU, this can happen after `xrEndFrame` has returned.
@ -420,9 +421,9 @@ u_pa_mark_discarded(struct u_pacing_app *upa, int64_t frame_id, uint64_t when_ns
* @ingroup aux_pacing
*/
static inline void
u_pa_mark_delivered(struct u_pacing_app *upa, int64_t frame_id, uint64_t when_ns)
u_pa_mark_delivered(struct u_pacing_app *upa, int64_t frame_id, uint64_t when_ns, uint64_t display_time_ns)
{
upa->mark_delivered(upa, frame_id, when_ns);
upa->mark_delivered(upa, frame_id, when_ns, display_time_ns);
}
/*!

View file

@ -59,6 +59,12 @@ struct u_pa_frame
//! When the client should have delivered the frame.
uint64_t predicted_delivery_time_ns;
/*!
* When the app told us to display this frame, can be different
* then the predicted display time so we track that separately.
*/
uint64_t display_time_ns;
//! When something happened.
struct
{
@ -309,7 +315,7 @@ pa_mark_discarded(struct u_pacing_app *upa, int64_t frame_id, uint64_t when_ns)
}
static void
pa_mark_delivered(struct u_pacing_app *upa, int64_t frame_id, uint64_t when_ns)
pa_mark_delivered(struct u_pacing_app *upa, int64_t frame_id, uint64_t when_ns, uint64_t display_time_ns)
{
struct pacing_app *pa = pacing_app(upa);
@ -321,6 +327,7 @@ pa_mark_delivered(struct u_pacing_app *upa, int64_t frame_id, uint64_t when_ns)
assert(f->state == U_RT_BEGUN);
f->when.delivered_ns = when_ns;
f->display_time_ns = display_time_ns;
f->state = U_RT_DELIVERED;
}

View file

@ -327,7 +327,7 @@ multi_compositor_layer_begin(struct xrt_compositor *xc,
// As early as possible.
uint64_t now_ns = os_monotonic_get_ns();
os_mutex_lock(&mc->msc->list_and_timing_lock);
u_pa_mark_delivered(mc->upa, frame_id, now_ns);
u_pa_mark_delivered(mc->upa, frame_id, now_ns, display_time_ns);
os_mutex_unlock(&mc->msc->list_and_timing_lock);
assert(mc->progress.layer_count == 0);