From: Enpeng Xu <enpen...@gmail.com>

Currently, a simple egl test case will fail like this:

eglMakeCurrent(dpy, surf, surf, ctx);
eglDestroyContext(dpy, ctx);
ctx2 = eglGetCurrentContext();  // ctx2 will be EGL_NO_CONTEXT
assert(ctx == ctx2);

It's caused by function _eglGetContextHandle, the function will check the link 
status of egl context and return EGL_NO_CONTEXT if it's unlinked.

We should remove link status checking(_eglIsResourceLinked) inside of function 
_eglGetContextHandle, the function is used for checking current context(TLS) 
only, so it should be safe enough to trust the context pointer. Since current 
egl context could be removed from resource list by function eglDestroyContext, 
according to egl spec, it should be valid if the ctx is still in use, so 
_eglLookupContext should return it instead of EGL_NO_CONTEXT.
---
 src/egl/main/eglcontext.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/egl/main/eglcontext.h b/src/egl/main/eglcontext.h
index 241917f..aeec84f 100644
--- a/src/egl/main/eglcontext.h
+++ b/src/egl/main/eglcontext.h
@@ -145,7 +145,7 @@ static inline EGLContext
 _eglGetContextHandle(_EGLContext *ctx)
 {
    _EGLResource *res = (_EGLResource *) ctx;
-   return (res && _eglIsResourceLinked(res)) ?
+   return (res) ?
       (EGLContext) ctx : EGL_NO_CONTEXT;
 }
 
-- 
2.1.0

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to