[PATCH 1/2] opengl: don't create a tmp context for glCopyTexImage2D

Miklós Máté mtmkls at gmail.com
Tue Feb 23 11:37:29 CST 2016


It works fine without the tmp context, and Mesa's wgl state tracker doesn't
do that either. Theoretically wglBindTexImageARB is supposed to be a fast
render-to-texture method, and creating a new context is anything but fast.

This fixes horrible performance and broken MSAA in Star Wars
Knights of the Old Republic when post-process effects are enabled.

Signed-off-by: Miklós Máté <mtmkls at gmail.com>
---
 dlls/winex11.drv/opengl.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
index 99befde..871cfc1 100644
--- a/dlls/winex11.drv/opengl.c
+++ b/dlls/winex11.drv/opengl.c
@@ -2922,10 +2922,8 @@ static BOOL X11DRV_wglBindTexImageARB( struct wgl_pbuffer *object, int iBuffer )
 
     if (use_render_texture_emulation) {
         static BOOL initialized = FALSE;
-        int prev_binded_texture = 0;
         GLXContext prev_context;
         Drawable prev_drawable;
-        GLXContext tmp_context;
 
         prev_context = pglXGetCurrentContext();
         prev_drawable = pglXGetCurrentDrawable();
@@ -2940,21 +2938,15 @@ static BOOL X11DRV_wglBindTexImageARB( struct wgl_pbuffer *object, int iBuffer )
         }
 
         TRACE("drawable=%lx, context=%p\n", object->drawable, prev_context);
-        tmp_context = pglXCreateNewContext(gdi_display, object->fmt->fbconfig, object->fmt->render_type, prev_context, True);
-
-        opengl_funcs.gl.p_glGetIntegerv(object->texture_bind_target, &prev_binded_texture);
 
         /* Switch to our pbuffer */
-        pglXMakeCurrent(gdi_display, object->drawable, tmp_context);
+        pglXMakeCurrent(gdi_display, object->drawable, prev_context);
 
-        /* Make sure that the prev_binded_texture is set as the current texture state isn't shared between contexts.
-         * After that upload the pbuffer texture data. */
-        opengl_funcs.gl.p_glBindTexture(object->texture_target, prev_binded_texture);
+        /* Upload the pbuffer texture data. */
         opengl_funcs.gl.p_glCopyTexImage2D(object->texture_target, 0, object->use_render_texture, 0, 0, object->width, object->height, 0);
 
         /* Switch back to the original drawable and upload the pbuffer-texture */
         pglXMakeCurrent(gdi_display, prev_drawable, prev_context);
-        pglXDestroyContext(gdi_display, tmp_context);
         return GL_TRUE;
     }
 
-- 
2.7.0




More information about the wine-patches mailing list