From b5e394b3f5d80749af0148611df2eb009e7bf823 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 14 Mar 2014 17:20:12 -0700 Subject: [PATCH] glamor: Use lastGLContext to coordinate the context with GLX. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Michel Dänzer Reviewed-by: Adam Jackson --- glamor/glamor_egl.c | 14 ++++++-------- glamor/glamor_glx.c | 6 ------ glamor/glamor_utils.h | 5 ++++- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c index 9b6b3236e..33a95a066 100644 --- a/glamor/glamor_egl.c +++ b/glamor/glamor_egl.c @@ -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"); } } diff --git a/glamor/glamor_glx.c b/glamor/glamor_glx.c index 8f47c3d2c..d56581cd7 100644 --- a/glamor/glamor_glx.c +++ b/glamor/glamor_glx.c @@ -36,15 +36,9 @@ 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); } diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h index 53b7d9bec..56ef6a97c 100644 --- a/glamor/glamor_utils.h +++ b/glamor/glamor_utils.h @@ -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