cogl/onscreen: Add cogl_onscreen_egl_maybe_create_timestamp_query
Move the code out of cogl_onscreen_egl_swap_buffers_with_damage, and call the new function from callers of the former. v2: * Use early return if the cogl context doesn't support timestamp queries. (Sebastian Wick) Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3689>
This commit is contained in:
parent
0bbc25f694
commit
09267d0bdd
@ -281,6 +281,27 @@ cogl_onscreen_egl_queue_damage_region (CoglOnscreen *onscreen,
|
|||||||
g_warning ("Error reported by eglSetDamageRegion");
|
g_warning ("Error reported by eglSetDamageRegion");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_onscreen_egl_maybe_create_timestamp_query (CoglOnscreen *onscreen,
|
||||||
|
CoglFrameInfo *info)
|
||||||
|
{
|
||||||
|
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
|
||||||
|
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
|
||||||
|
|
||||||
|
if (!cogl_has_feature (context, COGL_FEATURE_ID_TIMESTAMP_QUERY))
|
||||||
|
return;
|
||||||
|
|
||||||
|
info->gpu_time_before_buffer_swap_ns =
|
||||||
|
cogl_context_get_gpu_time_ns (context);
|
||||||
|
info->cpu_time_before_buffer_swap_us = g_get_monotonic_time ();
|
||||||
|
|
||||||
|
/* Set up a timestamp query for when all rendering will be finished. */
|
||||||
|
info->timestamp_query =
|
||||||
|
cogl_framebuffer_create_timestamp_query (framebuffer);
|
||||||
|
|
||||||
|
info->has_valid_gpu_rendering_duration = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cogl_onscreen_egl_swap_buffers_with_damage (CoglOnscreen *onscreen,
|
cogl_onscreen_egl_swap_buffers_with_damage (CoglOnscreen *onscreen,
|
||||||
const int *rectangles,
|
const int *rectangles,
|
||||||
@ -309,19 +330,6 @@ cogl_onscreen_egl_swap_buffers_with_damage (CoglOnscreen *onscreen,
|
|||||||
COGL_FRAMEBUFFER (onscreen),
|
COGL_FRAMEBUFFER (onscreen),
|
||||||
COGL_FRAMEBUFFER_STATE_BIND);
|
COGL_FRAMEBUFFER_STATE_BIND);
|
||||||
|
|
||||||
if (cogl_has_feature (context, COGL_FEATURE_ID_TIMESTAMP_QUERY))
|
|
||||||
{
|
|
||||||
info->gpu_time_before_buffer_swap_ns =
|
|
||||||
cogl_context_get_gpu_time_ns (context);
|
|
||||||
info->cpu_time_before_buffer_swap_us = g_get_monotonic_time ();
|
|
||||||
|
|
||||||
/* Set up a timestamp query for when all rendering will be finished. */
|
|
||||||
info->timestamp_query =
|
|
||||||
cogl_framebuffer_create_timestamp_query (COGL_FRAMEBUFFER (onscreen));
|
|
||||||
|
|
||||||
info->has_valid_gpu_rendering_duration = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (n_rectangles && priv->pf_eglSwapBuffersWithDamage)
|
if (n_rectangles && priv->pf_eglSwapBuffersWithDamage)
|
||||||
{
|
{
|
||||||
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
|
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
|
||||||
|
@ -40,6 +40,10 @@ struct _CoglOnscreenEglClass
|
|||||||
CoglOnscreenClass parent_class;
|
CoglOnscreenClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
COGL_EXPORT void
|
||||||
|
cogl_onscreen_egl_maybe_create_timestamp_query (CoglOnscreen *onscreen,
|
||||||
|
CoglFrameInfo *info);
|
||||||
|
|
||||||
COGL_EXPORT void
|
COGL_EXPORT void
|
||||||
cogl_onscreen_egl_set_egl_surface (CoglOnscreenEgl *onscreen_egl,
|
cogl_onscreen_egl_set_egl_surface (CoglOnscreenEgl *onscreen_egl,
|
||||||
EGLSurface egl_surface);
|
EGLSurface egl_surface);
|
||||||
|
@ -1305,6 +1305,8 @@ meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen,
|
|||||||
rectangles,
|
rectangles,
|
||||||
n_rectangles);
|
n_rectangles);
|
||||||
|
|
||||||
|
cogl_onscreen_egl_maybe_create_timestamp_query (onscreen, frame_info);
|
||||||
|
|
||||||
parent_class = COGL_ONSCREEN_CLASS (meta_onscreen_native_parent_class);
|
parent_class = COGL_ONSCREEN_CLASS (meta_onscreen_native_parent_class);
|
||||||
parent_class->swap_buffers_with_damage (onscreen,
|
parent_class->swap_buffers_with_damage (onscreen,
|
||||||
rectangles,
|
rectangles,
|
||||||
|
@ -186,6 +186,8 @@ meta_stage_x11_nested_finish_frame (ClutterStageWindow *stage_window,
|
|||||||
}
|
}
|
||||||
|
|
||||||
frame_info = cogl_frame_info_new (context, 0);
|
frame_info = cogl_frame_info_new (context, 0);
|
||||||
|
cogl_onscreen_egl_maybe_create_timestamp_query (stage_x11->onscreen,
|
||||||
|
frame_info);
|
||||||
cogl_onscreen_swap_buffers (stage_x11->onscreen, frame_info, frame);
|
cogl_onscreen_swap_buffers (stage_x11->onscreen, frame_info, frame);
|
||||||
|
|
||||||
if (!clutter_frame_has_result (frame))
|
if (!clutter_frame_has_result (frame))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user