[mutter] cogl: Store CPU and GPU rendering timestamps in frame info
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] cogl: Store CPU and GPU rendering timestamps in frame info
- Date: Tue, 13 Jul 2021 08:41:55 +0000 (UTC)
commit f1024564a2651dda8beee5f39682369eb32dfade
Author: Ivan Molodetskikh <yalterz gmail com>
Date: Wed Jan 6 15:39:30 2021 +0300
cogl: Store CPU and GPU rendering timestamps in frame info
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
cogl/cogl/cogl-frame-info.c | 3 ++-
cogl/cogl/winsys/cogl-onscreen-egl.c | 16 ++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
---
diff --git a/cogl/cogl/cogl-frame-info.c b/cogl/cogl/cogl-frame-info.c
index 867740d974..adaf2bad98 100644
--- a/cogl/cogl/cogl-frame-info.c
+++ b/cogl/cogl/cogl-frame-info.c
@@ -126,7 +126,8 @@ cogl_frame_info_get_rendering_duration_ns (CoglFrameInfo *info)
{
int64_t gpu_time_rendering_done_ns;
- if (!info->timestamp_query)
+ if (!info->timestamp_query ||
+ info->gpu_time_before_buffer_swap_ns == 0)
return 0;
gpu_time_rendering_done_ns =
diff --git a/cogl/cogl/winsys/cogl-onscreen-egl.c b/cogl/cogl/winsys/cogl-onscreen-egl.c
index 347e2071cb..20b3c60efe 100644
--- a/cogl/cogl/winsys/cogl-onscreen-egl.c
+++ b/cogl/cogl/winsys/cogl-onscreen-egl.c
@@ -28,6 +28,7 @@
#include "winsys/cogl-onscreen-egl.h"
#include "cogl-context-private.h"
+#include "cogl-frame-info-private.h"
#include "cogl-renderer-private.h"
#include "cogl-trace.h"
#include "winsys/cogl-winsys-egl-private.h"
@@ -269,6 +270,21 @@ cogl_onscreen_egl_swap_buffers_with_damage (CoglOnscreen *onscreen,
COGL_FRAMEBUFFER (onscreen),
COGL_FRAMEBUFFER_STATE_BIND);
+ if (cogl_has_feature (context, COGL_FEATURE_ID_GET_GPU_TIME))
+ {
+ 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. */
+ if (cogl_has_feature (context, COGL_FEATURE_ID_TIMESTAMP_QUERY))
+ {
+ info->timestamp_query =
+ cogl_framebuffer_create_timestamp_query (COGL_FRAMEBUFFER (onscreen));
+ }
+
if (n_rectangles && egl_renderer->pf_eglSwapBuffersWithDamage)
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]