[gtk/wip/fencing-without-context-is-discouraged] x11: ensure some context is bound before calling glClientWaitSync



commit a0f6ff101e781aaf0a931be6e22f2885f4f69e04
Author: Ray Strode <rstrode redhat com>
Date:   Mon Jun 22 17:13:54 2020 -0400

    x11: ensure some context is bound before calling glClientWaitSync
    
    Since commit 972134abe48a4c9c7b6ad41b0723f30f4e7ae16b we now call
    glClientWaitSync for the vendor nvidia driver, to know when a frame
    is ready for the compositor to process.
    
    glClientWaitSync can be called regardless of which context is currently
    bound, but if no context is bound at all, it returns 0 without
    doing anything.
    
    This commit checks for that edge case, and ensures a context gets
    made current in the event no context is already current, before calling
    glClientWaitSync.

 gdk/x11/gdkglcontext-x11.c | 8 ++++++++
 1 file changed, 8 insertions(+)
---
diff --git a/gdk/x11/gdkglcontext-x11.c b/gdk/x11/gdkglcontext-x11.c
index 834d23ac93..d9e30ad09e 100644
--- a/gdk/x11/gdkglcontext-x11.c
+++ b/gdk/x11/gdkglcontext-x11.c
@@ -606,6 +606,14 @@ on_gl_surface_xevent (GdkGLContext   *context,
     {
       GLenum wait_result;
 
+      /* We don't care if the passed context is the current context,
+       * necessarily, but we do care that *some* context is bound,
+       * otherwise, the GL dispatch layer will make glClientWaitSync()
+       * silently return 0.
+       */
+      if (glXGetCurrentContext () == NULL)
+        gdk_gl_context_make_current (context);
+
       wait_result = glClientWaitSync (context_x11->frame_fence, 0, 0);
 
       switch (wait_result)


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