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

Matteo Bruni matteo.mystral at gmail.com
Fri Feb 26 12:29:20 CST 2016


2016-02-25 16:22 GMT+01:00 Miklós Máté <mtmkls at gmail.com>:
> 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;
>  };

You don't need the "has_tmp_context" field, the struct is zeroed at
allocation and you can just check if the context is non-zero.
You do need to store the context which was current at the time
tmp_context was last created though (see below).

>
>  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;
> +        }

As I mentioned in my previous reply, the temporary context is shared
with prev_context (which is correct, second to last parameter of
glXCreateNewContext()) and that means it has to be recreated if
prev_context changes between calls to wglBindTexImageARB. So please
store prev_context in object and destroy and recreate the temporary
context if the current prev_context is different.



More information about the wine-devel mailing list