mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 23:50:41 -05:00
cogl: Report presentation time in microseconds
KMS and GLX device timestamps have microsecond precision, and whenever we sample the time ourselves it's not the real presentation time anyway, so nanosecond precision for that case is unnecessary. The presentation timestamp in ClutterFrameInfo is in microseconds, too, so this commit makes them have the same precision. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
This commit is contained in:
parent
9f53b691c4
commit
d8606829c4
@ -835,7 +835,7 @@ frame_cb (CoglOnscreen *onscreen,
|
||||
.frame_counter = cogl_frame_info_get_global_frame_counter (frame_info),
|
||||
.refresh_rate = cogl_frame_info_get_refresh_rate (frame_info),
|
||||
.presentation_time =
|
||||
ns2us (cogl_frame_info_get_presentation_time (frame_info)),
|
||||
cogl_frame_info_get_presentation_time_us (frame_info),
|
||||
.flags = flags,
|
||||
};
|
||||
clutter_stage_view_notify_presented (view, &clutter_frame_info);
|
||||
|
@ -47,7 +47,7 @@ struct _CoglFrameInfo
|
||||
CoglObject _parent;
|
||||
|
||||
int64_t frame_counter;
|
||||
int64_t presentation_time;
|
||||
int64_t presentation_time_us;
|
||||
float refresh_rate;
|
||||
|
||||
int64_t global_frame_counter;
|
||||
|
@ -62,11 +62,11 @@ cogl_frame_info_get_frame_counter (CoglFrameInfo *info)
|
||||
}
|
||||
|
||||
int64_t
|
||||
cogl_frame_info_get_presentation_time (CoglFrameInfo *info)
|
||||
cogl_frame_info_get_presentation_time_us (CoglFrameInfo *info)
|
||||
{
|
||||
g_warn_if_fail (!(info->flags & COGL_FRAME_INFO_FLAG_SYMBOLIC));
|
||||
|
||||
return info->presentation_time;
|
||||
return info->presentation_time_us;
|
||||
}
|
||||
|
||||
float
|
||||
|
@ -90,13 +90,13 @@ COGL_EXPORT
|
||||
int64_t cogl_frame_info_get_frame_counter (CoglFrameInfo *info);
|
||||
|
||||
/**
|
||||
* cogl_frame_info_get_presentation_time:
|
||||
* cogl_frame_info_get_presentation_time_us:
|
||||
* @info: a #CoglFrameInfo object
|
||||
*
|
||||
* Gets the presentation time for the frame. This is the time at which
|
||||
* the frame became visible to the user.
|
||||
*
|
||||
* The presentation time measured in nanoseconds, is based on
|
||||
* The presentation time measured in microseconds, is based on
|
||||
* cogl_get_clock_time().
|
||||
*
|
||||
* <note>Linux kernel version less that 3.8 can result in
|
||||
@ -109,7 +109,7 @@ int64_t cogl_frame_info_get_frame_counter (CoglFrameInfo *info);
|
||||
* Stability: unstable
|
||||
*/
|
||||
COGL_EXPORT
|
||||
int64_t cogl_frame_info_get_presentation_time (CoglFrameInfo *info);
|
||||
int64_t cogl_frame_info_get_presentation_time_us (CoglFrameInfo *info);
|
||||
|
||||
/**
|
||||
* cogl_frame_info_get_refresh_rate:
|
||||
|
@ -421,11 +421,11 @@ ensure_ust_type (CoglRenderer *renderer,
|
||||
}
|
||||
|
||||
static int64_t
|
||||
ust_to_nanoseconds (CoglRenderer *renderer,
|
||||
GLXDrawable drawable,
|
||||
int64_t ust)
|
||||
ust_to_microseconds (CoglRenderer *renderer,
|
||||
GLXDrawable drawable,
|
||||
int64_t ust)
|
||||
{
|
||||
CoglGLXRenderer *glx_renderer = renderer->winsys;
|
||||
CoglGLXRenderer *glx_renderer = renderer->winsys;
|
||||
|
||||
ensure_ust_type (renderer, drawable);
|
||||
|
||||
@ -436,10 +436,10 @@ ust_to_nanoseconds (CoglRenderer *renderer,
|
||||
break;
|
||||
case COGL_GLX_UST_IS_GETTIMEOFDAY:
|
||||
case COGL_GLX_UST_IS_MONOTONIC_TIME:
|
||||
return 1000 * ust;
|
||||
return ust;
|
||||
case COGL_GLX_UST_IS_OTHER:
|
||||
/* In this case the scale of UST is undefined so we can't easily
|
||||
* scale to nanoseconds.
|
||||
* scale to microseconds.
|
||||
*
|
||||
* For example the driver may be reporting the rdtsc CPU counter
|
||||
* as UST values and so the scale would need to be determined
|
||||
@ -482,9 +482,9 @@ _cogl_winsys_wait_for_vblank (CoglOnscreen *onscreen)
|
||||
glx_renderer->glXWaitForMsc (xlib_renderer->xdpy, drawable,
|
||||
0, 1, 0,
|
||||
&ust, &msc, &sbc);
|
||||
info->presentation_time = ust_to_nanoseconds (ctx->display->renderer,
|
||||
drawable,
|
||||
ust);
|
||||
info->presentation_time_us = ust_to_microseconds (ctx->display->renderer,
|
||||
drawable,
|
||||
ust);
|
||||
info->flags |= COGL_FRAME_INFO_FLAG_HW_CLOCK;
|
||||
}
|
||||
else
|
||||
@ -496,7 +496,7 @@ _cogl_winsys_wait_for_vblank (CoglOnscreen *onscreen)
|
||||
(current_count + 1) % 2,
|
||||
¤t_count);
|
||||
|
||||
info->presentation_time = get_monotonic_time_ns ();
|
||||
info->presentation_time_us = g_get_monotonic_time ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -975,10 +975,10 @@ cogl_onscreen_glx_notify_swap_buffers (CoglOnscreen *onscreen,
|
||||
CoglFrameInfo *info;
|
||||
|
||||
info = cogl_onscreen_peek_head_frame_info (onscreen);
|
||||
info->presentation_time =
|
||||
ust_to_nanoseconds (context->display->renderer,
|
||||
onscreen_glx->glxwin,
|
||||
swap_event->ust);
|
||||
info->presentation_time_us =
|
||||
ust_to_microseconds (context->display->renderer,
|
||||
onscreen_glx->glxwin,
|
||||
swap_event->ust);
|
||||
info->flags |= COGL_FRAME_INFO_FLAG_HW_CLOCK;
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ meta_onscreen_native_swap_drm_fb (CoglOnscreen *onscreen)
|
||||
static void
|
||||
maybe_update_frame_info (MetaCrtc *crtc,
|
||||
CoglFrameInfo *frame_info,
|
||||
int64_t time_ns,
|
||||
int64_t time_us,
|
||||
CoglFrameInfoFlag flags)
|
||||
{
|
||||
const MetaCrtcConfig *crtc_config;
|
||||
@ -186,7 +186,7 @@ maybe_update_frame_info (MetaCrtc *crtc,
|
||||
refresh_rate = crtc_mode_info->refresh_rate;
|
||||
if (refresh_rate >= frame_info->refresh_rate)
|
||||
{
|
||||
frame_info->presentation_time = time_ns;
|
||||
frame_info->presentation_time_us = time_us;
|
||||
frame_info->refresh_rate = refresh_rate;
|
||||
frame_info->flags |= flags;
|
||||
}
|
||||
@ -209,7 +209,7 @@ meta_onscreen_native_notify_frame_complete (CoglOnscreen *onscreen)
|
||||
static void
|
||||
notify_view_crtc_presented (MetaRendererView *view,
|
||||
MetaKmsCrtc *kms_crtc,
|
||||
int64_t time_ns,
|
||||
int64_t time_us,
|
||||
CoglFrameInfoFlag flags)
|
||||
{
|
||||
ClutterStageView *stage_view = CLUTTER_STAGE_VIEW (view);
|
||||
@ -225,7 +225,7 @@ notify_view_crtc_presented (MetaRendererView *view,
|
||||
frame_info = cogl_onscreen_peek_head_frame_info (onscreen);
|
||||
|
||||
crtc = META_CRTC (meta_crtc_kms_from_kms_crtc (kms_crtc));
|
||||
maybe_update_frame_info (crtc, frame_info, time_ns, flags);
|
||||
maybe_update_frame_info (crtc, frame_info, time_us, flags);
|
||||
|
||||
meta_onscreen_native_notify_frame_complete (onscreen);
|
||||
|
||||
@ -245,12 +245,9 @@ notify_view_crtc_presented (MetaRendererView *view,
|
||||
}
|
||||
|
||||
static int64_t
|
||||
timeval_to_nanoseconds (const struct timeval *tv)
|
||||
timeval_to_microseconds (const struct timeval *tv)
|
||||
{
|
||||
int64_t usec = ((int64_t) tv->tv_sec) * G_USEC_PER_SEC + tv->tv_usec;
|
||||
int64_t nsec = usec * 1000;
|
||||
|
||||
return nsec;
|
||||
return ((int64_t) tv->tv_sec) * G_USEC_PER_SEC + tv->tv_usec;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -269,7 +266,7 @@ page_flip_feedback_flipped (MetaKmsCrtc *kms_crtc,
|
||||
};
|
||||
|
||||
notify_view_crtc_presented (view, kms_crtc,
|
||||
timeval_to_nanoseconds (&page_flip_time),
|
||||
timeval_to_microseconds (&page_flip_time),
|
||||
COGL_FRAME_INFO_FLAG_HW_CLOCK);
|
||||
}
|
||||
|
||||
@ -307,7 +304,10 @@ page_flip_feedback_mode_set_fallback (MetaKmsCrtc *kms_crtc,
|
||||
gpu_kms = META_GPU_KMS (meta_crtc_get_gpu (crtc));
|
||||
now_ns = meta_gpu_kms_get_current_time_ns (gpu_kms);
|
||||
|
||||
notify_view_crtc_presented (view, kms_crtc, now_ns, COGL_FRAME_INFO_FLAG_NONE);
|
||||
notify_view_crtc_presented (view,
|
||||
kms_crtc,
|
||||
ns2us (now_ns),
|
||||
COGL_FRAME_INFO_FLAG_NONE);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -335,7 +335,10 @@ page_flip_feedback_discarded (MetaKmsCrtc *kms_crtc,
|
||||
gpu_kms = META_GPU_KMS (meta_crtc_get_gpu (crtc));
|
||||
now_ns = meta_gpu_kms_get_current_time_ns (gpu_kms);
|
||||
|
||||
notify_view_crtc_presented (view, kms_crtc, now_ns, COGL_FRAME_INFO_FLAG_NONE);
|
||||
notify_view_crtc_presented (view,
|
||||
kms_crtc,
|
||||
ns2us (now_ns),
|
||||
COGL_FRAME_INFO_FLAG_NONE);
|
||||
}
|
||||
|
||||
static const MetaKmsPageFlipListenerVtable page_flip_listener_vtable = {
|
||||
|
Loading…
Reference in New Issue
Block a user