[mutter] cogl/frame-info: Add VSYNC flag



commit 47183a94eb36b196212401e9e5473a8b3915ca2b
Author: Ivan Molodetskikh <yalterz gmail com>
Date:   Sat Jan 30 21:14:27 2021 +0300

    cogl/frame-info: Add VSYNC flag
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>

 cogl/cogl/cogl-frame-info-private.h        | 8 ++++++++
 cogl/cogl/cogl-frame-info.c                | 6 ++++++
 cogl/cogl/cogl-frame-info.h                | 3 +++
 cogl/cogl/winsys/cogl-onscreen-glx.c       | 2 ++
 src/backends/native/meta-onscreen-native.c | 2 +-
 5 files changed, 20 insertions(+), 1 deletion(-)
---
diff --git a/cogl/cogl/cogl-frame-info-private.h b/cogl/cogl/cogl-frame-info-private.h
index 675b6da450..81904f7a42 100644
--- a/cogl/cogl/cogl-frame-info-private.h
+++ b/cogl/cogl/cogl-frame-info-private.h
@@ -48,6 +48,14 @@ typedef enum _CoglFrameInfoFlag
    * fullscreen surface and a surface on a hardware overlay.
    */
   COGL_FRAME_INFO_FLAG_ZERO_COPY = 1 << 2,
+  /*
+   * The presentation was synchronized to the "vertical retrace" by the display
+   * hardware such that tearing does not happen. Relying on user space
+   * scheduling is not acceptable for this flag. If presentation is done by a
+   * copy to the active frontbuffer, then it must guarantee that tearing cannot
+   * happen.
+   */
+  COGL_FRAME_INFO_FLAG_VSYNC = 1 << 3,
 } CoglFrameInfoFlag;
 
 struct _CoglFrameInfo
diff --git a/cogl/cogl/cogl-frame-info.c b/cogl/cogl/cogl-frame-info.c
index 24a100bfa7..a31d916896 100644
--- a/cogl/cogl/cogl-frame-info.c
+++ b/cogl/cogl/cogl-frame-info.c
@@ -101,6 +101,12 @@ cogl_frame_info_is_zero_copy (CoglFrameInfo *info)
   return !!(info->flags & COGL_FRAME_INFO_FLAG_ZERO_COPY);
 }
 
+gboolean
+cogl_frame_info_is_vsync (CoglFrameInfo *info)
+{
+  return !!(info->flags & COGL_FRAME_INFO_FLAG_VSYNC);
+}
+
 unsigned int
 cogl_frame_info_get_sequence (CoglFrameInfo *info)
 {
diff --git a/cogl/cogl/cogl-frame-info.h b/cogl/cogl/cogl-frame-info.h
index 62a9bb0eab..7278a08ca6 100644
--- a/cogl/cogl/cogl-frame-info.h
+++ b/cogl/cogl/cogl-frame-info.h
@@ -144,6 +144,9 @@ gboolean cogl_frame_info_is_hw_clock (CoglFrameInfo *info);
 COGL_EXPORT
 gboolean cogl_frame_info_is_zero_copy (CoglFrameInfo *info);
 
+COGL_EXPORT
+gboolean cogl_frame_info_is_vsync (CoglFrameInfo *info);
+
 COGL_EXPORT
 unsigned int cogl_frame_info_get_sequence (CoglFrameInfo *info);
 
diff --git a/cogl/cogl/winsys/cogl-onscreen-glx.c b/cogl/cogl/winsys/cogl-onscreen-glx.c
index df8922b5d1..8bbb508b7f 100644
--- a/cogl/cogl/winsys/cogl-onscreen-glx.c
+++ b/cogl/cogl/winsys/cogl-onscreen-glx.c
@@ -472,6 +472,7 @@ _cogl_winsys_wait_for_vblank (CoglOnscreen *onscreen)
   if (glx_display->can_vblank_wait)
     {
       CoglFrameInfo *info = cogl_onscreen_peek_tail_frame_info (onscreen);
+      info->flags |= COGL_FRAME_INFO_FLAG_VSYNC;
 
       if (glx_renderer->glXWaitForMsc)
         {
@@ -987,6 +988,7 @@ cogl_onscreen_glx_notify_swap_buffers (CoglOnscreen          *onscreen,
   set_sync_pending (onscreen);
 
   info = cogl_onscreen_peek_head_frame_info (onscreen);
+  info->flags |= COGL_FRAME_INFO_FLAG_VSYNC;
 
   ust_is_monotonic = is_ust_monotonic (context->display->renderer,
                                        onscreen_glx->glxwin);
diff --git a/src/backends/native/meta-onscreen-native.c b/src/backends/native/meta-onscreen-native.c
index a69f31c733..ff2b3a0545 100644
--- a/src/backends/native/meta-onscreen-native.c
+++ b/src/backends/native/meta-onscreen-native.c
@@ -265,7 +265,7 @@ page_flip_feedback_flipped (MetaKmsCrtc  *kms_crtc,
   MetaCrtc *crtc;
   MetaGpuKms *gpu_kms;
   int64_t presentation_time_us;
-  CoglFrameInfoFlag flags = COGL_FRAME_INFO_FLAG_NONE;
+  CoglFrameInfoFlag flags = COGL_FRAME_INFO_FLAG_VSYNC;
 
   page_flip_time = (struct timeval) {
     .tv_sec = tv_sec,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]