Module: Mesa
Branch: master
Commit: 551bfe7a09b0d1bc277796edc10c649b2b07a5b7
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=551bfe7a09b0d1bc277796edc10c649b2b07a5b7

Author: Chia-I Wu <[email protected]>
Date:   Sun Mar 28 02:11:16 2010 +0800

egl: Always return the previously bound context.

When a newly bound context is the same as the previously bound one,
_eglBindContextToThread should still return the context instead of NULL.
This gives the driver a chance to flush the context.

---

 src/egl/main/eglcontext.c |   17 ++++++++---------
 1 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c
index 012d8df..710752f 100644
--- a/src/egl/main/eglcontext.c
+++ b/src/egl/main/eglcontext.c
@@ -246,15 +246,14 @@ _eglBindContextToThread(_EGLContext *ctx, _EGLThreadInfo 
*t)
       _eglConvertApiToIndex(ctx->ClientAPI) : t->CurrentAPIIndex;
 
    oldCtx = t->CurrentContexts[apiIndex];
-   if (ctx == oldCtx)
-      return NULL;
+   if (ctx != oldCtx) {
+      if (oldCtx)
+         oldCtx->Binding = NULL;
+      if (ctx)
+         ctx->Binding = t;
 
-   if (oldCtx)
-      oldCtx->Binding = NULL;
-   if (ctx)
-      ctx->Binding = t;
-
-   t->CurrentContexts[apiIndex] = ctx;
+      t->CurrentContexts[apiIndex] = ctx;
+   }
 
    return oldCtx;
 }
@@ -352,7 +351,7 @@ _eglBindContext(_EGLContext **ctx, _EGLSurface **draw, 
_EGLSurface **read)
       _eglBindContextToSurfaces(newCtx, draw, read);
 
    /* unbind the old context from its binding surfaces */
-   if (oldCtx) {
+   if (oldCtx && oldCtx != newCtx) {
       /*
        * If the new context replaces some old context, the new one should not
        * be current before the replacement and it should not be bound to any

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to