glamor: Use lastGLContext to coordinate the context with GLX.
authorEric Anholt <eric@anholt.net>
Sat, 15 Mar 2014 00:20:12 +0000 (17:20 -0700)
committerEric Anholt <eric@anholt.net>
Wed, 23 Apr 2014 17:32:18 +0000 (10:32 -0700)
This gets us some more context changes that are needed to make sure
the two sides render to the right drawables and manipulate the right
objects.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
glamor/glamor_egl.c
glamor/glamor_glx.c
glamor/glamor_utils.h

index 9b6b323..33a95a0 100644 (file)
@@ -100,14 +100,12 @@ glamor_egl_get_context(struct glamor_context *glamor_ctx)
     if (glamor_ctx->get_count++)
         return;
 
-    if (glamor_ctx->ctx != eglGetCurrentContext()) {
-        eglMakeCurrent(glamor_ctx->display, EGL_NO_SURFACE,
-                       EGL_NO_SURFACE, EGL_NO_CONTEXT);
-        if (!eglMakeCurrent(glamor_ctx->display,
-                            EGL_NO_SURFACE, EGL_NO_SURFACE,
-                            glamor_ctx->ctx)) {
-            FatalError("Failed to make EGL context current\n");
-        }
+    eglMakeCurrent(glamor_ctx->display, EGL_NO_SURFACE,
+                   EGL_NO_SURFACE, EGL_NO_CONTEXT);
+    if (!eglMakeCurrent(glamor_ctx->display,
+                        EGL_NO_SURFACE, EGL_NO_SURFACE,
+                        glamor_ctx->ctx)) {
+        FatalError("Failed to make EGL context current\n");
     }
 }
 
index 8f47c3d..d56581c 100644 (file)
 static void
 glamor_glx_get_context(struct glamor_context *glamor_ctx)
 {
-    GLXContext old_ctx;
-
     if (glamor_ctx->get_count++)
         return;
 
-    old_ctx = glXGetCurrentContext();
-    if (old_ctx == glamor_ctx->ctx)
-        return;
-
     glXMakeCurrent(glamor_ctx->display, glamor_ctx->drawable_xid,
                    glamor_ctx->ctx);
 }
index 53b7d9b..56ef6a9 100644 (file)
@@ -1501,7 +1501,10 @@ __fls(unsigned long x)
 static inline void
 glamor_get_context(glamor_screen_private * glamor_priv)
 {
-    glamor_priv->ctx.get_context(&glamor_priv->ctx);
+    if (lastGLContext != &glamor_priv->ctx) {
+        lastGLContext = &glamor_priv->ctx;
+        glamor_priv->ctx.get_context(&glamor_priv->ctx);
+    }
 }
 
 static inline void