From 01dcadab8b98f0ffa5bf0a859ca94ff78a8cb90a Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 2 Feb 2010 11:22:51 +0800 Subject: [PATCH] st/egl: Wrong context might be used in eglBindTexImage. If the pbuffer surface is current, gctx is set to the current context. Make sure it is set to OpenGL ES 1 context again before binding. --- .../state_trackers/egl/common/egl_g3d.c | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c index 8a73e81d4ac..30e2c347bd4 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -1087,8 +1087,8 @@ egl_g3d_bind_tex_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint buffer) { struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); - _EGLContext *ctx = _eglGetAPIContext(EGL_OPENGL_ES_API); - struct egl_g3d_context *gctx = egl_g3d_context(ctx); + _EGLContext *es1 = _eglGetAPIContext(EGL_OPENGL_ES_API); + struct egl_g3d_context *gctx; enum pipe_format target_format; int target; @@ -1118,6 +1118,11 @@ egl_g3d_bind_tex_image(_EGLDriver *drv, _EGLDisplay *dpy, return _eglError(EGL_BAD_MATCH, "eglBindTexImage"); } + if (!es1) + return EGL_TRUE; + if (!gsurf->render_surface) + return EGL_FALSE; + /* flush properly if the surface is bound */ if (gsurf->base.CurrentContext) { gctx = egl_g3d_context(gsurf->base.CurrentContext); @@ -1125,14 +1130,11 @@ egl_g3d_bind_tex_image(_EGLDriver *drv, _EGLDisplay *dpy, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); } - if (gctx) { - if (!gsurf->render_surface) - return EGL_FALSE; + gctx = egl_g3d_context(es1); + gctx->stapi->st_bind_texture_surface(gsurf->render_surface, + target, gsurf->base.MipmapLevel, target_format); - gctx->stapi->st_bind_texture_surface(gsurf->render_surface, - target, gsurf->base.MipmapLevel, target_format); - gsurf->base.BoundToTexture = EGL_TRUE; - } + gsurf->base.BoundToTexture = EGL_TRUE; return EGL_TRUE; } -- 2.30.2