cogl/frame: Keep track of target presentation time

It's yet to be used for anything, but will later on.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2795>
This commit is contained in:
Jonas Ådahl 2022-10-26 19:45:46 +02:00
parent 08b0e563d4
commit e5602062e2
3 changed files with 23 additions and 0 deletions

View File

@ -78,10 +78,17 @@ struct _CoglFrameInfo
CoglTimestampQuery *timestamp_query; CoglTimestampQuery *timestamp_query;
int64_t gpu_time_before_buffer_swap_ns; int64_t gpu_time_before_buffer_swap_ns;
int64_t cpu_time_before_buffer_swap_us; int64_t cpu_time_before_buffer_swap_us;
gboolean has_target_presentation_time;
int64_t target_presentation_time_us;
}; };
COGL_EXPORT COGL_EXPORT
CoglFrameInfo *cogl_frame_info_new (CoglContext *context, CoglFrameInfo *cogl_frame_info_new (CoglContext *context,
int64_t global_frame_counter); int64_t global_frame_counter);
COGL_EXPORT
void cogl_frame_info_set_target_presentation_time (CoglFrameInfo *info,
int64_t presentation_time_us);
#endif /* __COGL_FRAME_INFO_PRIVATE_H */ #endif /* __COGL_FRAME_INFO_PRIVATE_H */

View File

@ -142,3 +142,11 @@ cogl_frame_info_get_time_before_buffer_swap_us (CoglFrameInfo *info)
{ {
return info->cpu_time_before_buffer_swap_us; return info->cpu_time_before_buffer_swap_us;
} }
void
cogl_frame_info_set_target_presentation_time (CoglFrameInfo *info,
int64_t presentation_time_us)
{
info->has_target_presentation_time = TRUE;
info->target_presentation_time_us = presentation_time_us;
}

View File

@ -265,6 +265,7 @@ swap_framebuffer (ClutterStageWindow *stage_window,
if (COGL_IS_ONSCREEN (framebuffer)) if (COGL_IS_ONSCREEN (framebuffer))
{ {
CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer); CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer);
int64_t target_presentation_time_us;
int *damage, n_rects, i; int *damage, n_rects, i;
CoglFrameInfo *frame_info; CoglFrameInfo *frame_info;
@ -285,6 +286,13 @@ swap_framebuffer (ClutterStageWindow *stage_window,
cogl_frame_info_new (cogl_context, priv->global_frame_counter); cogl_frame_info_new (cogl_context, priv->global_frame_counter);
priv->global_frame_counter++; priv->global_frame_counter++;
if (clutter_frame_get_target_presentation_time (frame,
&target_presentation_time_us))
{
cogl_frame_info_set_target_presentation_time (frame_info,
target_presentation_time_us);
}
/* push on the screen */ /* push on the screen */
if (n_rects > 0 && !swap_with_damage) if (n_rects > 0 && !swap_with_damage)
{ {