[PATCH] winex11: Don't create a temporary context each time X11DRV_wglBindTexImageARB is called.

Miklós Máté mtmkls at gmail.com
Thu Feb 25 09:22:01 CST 2016


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 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 | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
index 99befde..d2b72cf 100644
--- a/dlls/winex11.drv/opengl.c
+++ b/dlls/winex11.drv/opengl.c
@@ -235,6 +235,8 @@ struct wgl_pbuffer
     GLenum     texture_type;
     GLuint     texture;
     int        texture_level;
+    GLXContext tmp_context;
+    int        has_tmp_context;
 };
 
 enum dc_gl_type
@@ -2940,12 +2942,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);
+        if (!object->has_tmp_context) {
+            object->tmp_context = pglXCreateNewContext(gdi_display, object->fmt->fbconfig, object->fmt->render_type, prev_context, True);
+            object->has_tmp_context = 1;
+        }
 
         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, object->tmp_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. */
-- 
2.7.0




More information about the wine-patches mailing list