mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-19 13:18:32 +00:00
u/pacing: Make present_to_display_offset_ns more clear
This commit is contained in:
parent
e93b1c61ff
commit
6c9c1e9249
|
@ -139,13 +139,15 @@ struct u_pacing_compositor
|
||||||
*
|
*
|
||||||
* This is usually used only for more complicated display systems.
|
* This is usually used only for more complicated display systems.
|
||||||
*
|
*
|
||||||
* @param[in] upc The compositor pacing helper.
|
* @param[in] upc The compositor pacing helper.
|
||||||
* @param[in] frame_id The frame ID to record for.
|
* @param[in] frame_id The frame ID to record for.
|
||||||
* @param[in] present_offset_ns The improved estimate of the time between "present" and photons.
|
* @param[in] present_to_display_offset_ns The improved estimate of the time between "present" and photons.
|
||||||
*
|
*
|
||||||
* @see @ref frame-pacing.
|
* @see @ref frame-pacing.
|
||||||
*/
|
*/
|
||||||
void (*update_present_offset)(struct u_pacing_compositor *upc, int64_t frame_id, uint64_t present_offset_ns);
|
void (*update_present_offset)(struct u_pacing_compositor *upc,
|
||||||
|
int64_t frame_id,
|
||||||
|
uint64_t present_to_display_offset_ns);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Destroy this u_pacing_compositor.
|
* Destroy this u_pacing_compositor.
|
||||||
|
@ -227,9 +229,9 @@ u_pc_info(struct u_pacing_compositor *upc,
|
||||||
* @ingroup aux_pacing
|
* @ingroup aux_pacing
|
||||||
*/
|
*/
|
||||||
static inline void
|
static inline void
|
||||||
u_pc_update_present_offset(struct u_pacing_compositor *upc, int64_t frame_id, uint64_t present_offset_ns)
|
u_pc_update_present_offset(struct u_pacing_compositor *upc, int64_t frame_id, uint64_t present_to_display_offset_ns)
|
||||||
{
|
{
|
||||||
upc->update_present_offset(upc, frame_id, present_offset_ns);
|
upc->update_present_offset(upc, frame_id, present_to_display_offset_ns);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -491,7 +493,7 @@ u_pa_destroy(struct u_pacing_app **upa_ptr)
|
||||||
struct u_pc_display_timing_config
|
struct u_pc_display_timing_config
|
||||||
{
|
{
|
||||||
//! How long after "present" is the image actually displayed
|
//! How long after "present" is the image actually displayed
|
||||||
uint64_t present_offset_ns;
|
uint64_t present_to_display_offset_ns;
|
||||||
//! Extra margin that is added to compositor time, between end of draw and present
|
//! Extra margin that is added to compositor time, between end of draw and present
|
||||||
uint64_t margin_ns;
|
uint64_t margin_ns;
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -94,7 +94,7 @@ struct pacing_compositor
|
||||||
* the display engine starts scanning out from the buffers we provided,
|
* the display engine starts scanning out from the buffers we provided,
|
||||||
* and not when the pixels turned into photons that the user sees.
|
* and not when the pixels turned into photons that the user sees.
|
||||||
*/
|
*/
|
||||||
uint64_t present_offset_ns;
|
uint64_t present_to_display_offset_ns;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Frame period of the device.
|
* Frame period of the device.
|
||||||
|
@ -173,7 +173,7 @@ calc_total_comp_time(struct pacing_compositor *pc)
|
||||||
static uint64_t
|
static uint64_t
|
||||||
calc_display_time_from_present_time(struct pacing_compositor *pc, uint64_t desired_present_time_ns)
|
calc_display_time_from_present_time(struct pacing_compositor *pc, uint64_t desired_present_time_ns)
|
||||||
{
|
{
|
||||||
return desired_present_time_ns + pc->present_offset_ns;
|
return desired_present_time_ns + pc->present_to_display_offset_ns;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
|
@ -643,13 +643,14 @@ pc_info(struct u_pacing_compositor *upc,
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pc_update_present_offset(struct u_pacing_compositor *upc, int64_t frame_id, uint64_t present_offset_ns)
|
pc_update_present_offset(struct u_pacing_compositor *upc, int64_t frame_id, uint64_t present_to_display_offset_ns)
|
||||||
{
|
{
|
||||||
struct pacing_compositor *pc = pacing_compositor(upc);
|
struct pacing_compositor *pc = pacing_compositor(upc);
|
||||||
(void)pc;
|
|
||||||
// not associating with frame IDs right now.
|
// not associating with frame IDs right now.
|
||||||
(void)frame_id;
|
(void)frame_id;
|
||||||
pc->present_offset_ns = present_offset_ns;
|
|
||||||
|
pc->present_to_display_offset_ns = present_to_display_offset_ns;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -662,7 +663,7 @@ pc_destroy(struct u_pacing_compositor *upc)
|
||||||
|
|
||||||
const struct u_pc_display_timing_config U_PC_DISPLAY_TIMING_CONFIG_DEFAULT = {
|
const struct u_pc_display_timing_config U_PC_DISPLAY_TIMING_CONFIG_DEFAULT = {
|
||||||
// Just a wild guess.
|
// Just a wild guess.
|
||||||
.present_offset_ns = U_TIME_1MS_IN_NS * 4,
|
.present_to_display_offset_ns = U_TIME_1MS_IN_NS * 4,
|
||||||
.margin_ns = U_TIME_1MS_IN_NS,
|
.margin_ns = U_TIME_1MS_IN_NS,
|
||||||
// Start by assuming the compositor takes 10% of the frame.
|
// Start by assuming the compositor takes 10% of the frame.
|
||||||
.comp_time_fraction = 10,
|
.comp_time_fraction = 10,
|
||||||
|
@ -686,7 +687,7 @@ u_pc_display_timing_create(uint64_t estimated_frame_period_ns,
|
||||||
pc->frame_period_ns = estimated_frame_period_ns;
|
pc->frame_period_ns = estimated_frame_period_ns;
|
||||||
|
|
||||||
// Estimate of how long after "present" the photons hit the eyes
|
// Estimate of how long after "present" the photons hit the eyes
|
||||||
pc->present_offset_ns = config->present_offset_ns;
|
pc->present_to_display_offset_ns = config->present_to_display_offset_ns;
|
||||||
|
|
||||||
// Start at this of frame time.
|
// Start at this of frame time.
|
||||||
pc->comp_time_ns = get_percent_of_time(estimated_frame_period_ns, config->comp_time_fraction);
|
pc->comp_time_ns = get_percent_of_time(estimated_frame_period_ns, config->comp_time_fraction);
|
||||||
|
|
|
@ -47,7 +47,7 @@ struct fake_timing
|
||||||
* the display engine starts scanning out from the buffers we provided,
|
* the display engine starts scanning out from the buffers we provided,
|
||||||
* and not when the pixels turned into photons that the user sees.
|
* and not when the pixels turned into photons that the user sees.
|
||||||
*/
|
*/
|
||||||
uint64_t present_offset_ns;
|
uint64_t present_to_display_offset_ns;
|
||||||
|
|
||||||
// The amount of time that the application needs to render frame.
|
// The amount of time that the application needs to render frame.
|
||||||
uint64_t comp_time_ns;
|
uint64_t comp_time_ns;
|
||||||
|
@ -71,7 +71,7 @@ fake_timing(struct u_pacing_compositor *upc)
|
||||||
static uint64_t
|
static uint64_t
|
||||||
predict_next_frame(struct fake_timing *ft, uint64_t now_ns)
|
predict_next_frame(struct fake_timing *ft, uint64_t now_ns)
|
||||||
{
|
{
|
||||||
uint64_t time_needed_ns = ft->present_offset_ns + ft->comp_time_ns;
|
uint64_t time_needed_ns = ft->present_to_display_offset_ns + ft->comp_time_ns;
|
||||||
uint64_t predicted_display_time_ns = ft->last_display_time_ns + ft->frame_period_ns;
|
uint64_t predicted_display_time_ns = ft->last_display_time_ns + ft->frame_period_ns;
|
||||||
|
|
||||||
while (now_ns + time_needed_ns > predicted_display_time_ns) {
|
while (now_ns + time_needed_ns > predicted_display_time_ns) {
|
||||||
|
@ -110,7 +110,7 @@ pc_predict(struct u_pacing_compositor *upc,
|
||||||
|
|
||||||
int64_t frame_id = ft->frame_id_generator++;
|
int64_t frame_id = ft->frame_id_generator++;
|
||||||
uint64_t predicted_display_time_ns = predict_next_frame(ft, now_ns);
|
uint64_t predicted_display_time_ns = predict_next_frame(ft, now_ns);
|
||||||
uint64_t desired_present_time_ns = predicted_display_time_ns - ft->present_offset_ns;
|
uint64_t desired_present_time_ns = predicted_display_time_ns - ft->present_to_display_offset_ns;
|
||||||
uint64_t wake_up_time_ns = desired_present_time_ns - ft->comp_time_ns;
|
uint64_t wake_up_time_ns = desired_present_time_ns - ft->comp_time_ns;
|
||||||
uint64_t present_slop_ns = U_TIME_HALF_MS_IN_NS;
|
uint64_t present_slop_ns = U_TIME_HALF_MS_IN_NS;
|
||||||
uint64_t predicted_display_period_ns = ft->frame_period_ns;
|
uint64_t predicted_display_period_ns = ft->frame_period_ns;
|
||||||
|
@ -153,13 +153,14 @@ pc_info(struct u_pacing_compositor *upc,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pc_update_present_offset(struct u_pacing_compositor *upc, int64_t frame_id, uint64_t present_offset_ns)
|
pc_update_present_offset(struct u_pacing_compositor *upc, int64_t frame_id, uint64_t present_to_display_offset_ns)
|
||||||
{
|
{
|
||||||
struct fake_timing *ft = fake_timing(upc);
|
struct fake_timing *ft = fake_timing(upc);
|
||||||
(void)ft;
|
|
||||||
// not associating with frame IDs right now.
|
// not associating with frame IDs right now.
|
||||||
(void)frame_id;
|
(void)frame_id;
|
||||||
ft->present_offset_ns = present_offset_ns;
|
|
||||||
|
ft->present_to_display_offset_ns = present_to_display_offset_ns;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -187,11 +188,12 @@ u_pc_fake_create(uint64_t estimated_frame_period_ns, uint64_t now_ns, struct u_p
|
||||||
ft->base.destroy = pc_destroy;
|
ft->base.destroy = pc_destroy;
|
||||||
ft->frame_period_ns = estimated_frame_period_ns;
|
ft->frame_period_ns = estimated_frame_period_ns;
|
||||||
|
|
||||||
|
|
||||||
// To make sure the code can start from a non-zero frame id.
|
// To make sure the code can start from a non-zero frame id.
|
||||||
ft->frame_id_generator = 5;
|
ft->frame_id_generator = 5;
|
||||||
|
|
||||||
// Just a wild guess.
|
// Just a wild guess.
|
||||||
ft->present_offset_ns = U_TIME_1MS_IN_NS * 4;
|
ft->present_to_display_offset_ns = U_TIME_1MS_IN_NS * 4;
|
||||||
|
|
||||||
// 20% of the frame time.
|
// 20% of the frame time.
|
||||||
ft->comp_time_ns = get_percent_of_time(estimated_frame_period_ns, 20);
|
ft->comp_time_ns = get_percent_of_time(estimated_frame_period_ns, 20);
|
||||||
|
|
Loading…
Reference in a new issue