Module: wine Branch: master Commit: b535dea0aafd37ff45bc55293e73ed59313c4d5d URL: https://source.winehq.org/git/wine.git/?a=commit;h=b535dea0aafd37ff45bc55293...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Fri Sep 10 21:32:47 2021 +0200
wined3d: Do not attempt to restore GL contexts corresponding to wined3d contexts in wined3d_context_gl_cleanup().
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/wined3d/context_gl.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index da7c70a8863..f6d046c410a 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -1347,6 +1347,7 @@ static void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl) struct wined3d_so_statistics_query *so_statistics_query; struct wined3d_timestamp_query *timestamp_query; struct wined3d_occlusion_query *occlusion_query; + struct wined3d_context_gl *current; struct fbo_entry *entry, *entry2; struct wined3d_fence *fence; HGLRC restore_ctx; @@ -1356,10 +1357,22 @@ static void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl) restore_ctx = wglGetCurrentContext(); restore_dc = wglGetCurrentDC();
- if (restore_ctx == context_gl->gl_ctx) - restore_ctx = NULL; - else if (context_gl->valid) + if (context_gl->valid && context_gl->gl_ctx != restore_ctx) + { + /* Attempting to restore a GL context corresponding to a wined3d + * context is not particularly useful. Worse, when we're called from + * wined3d_context_gl_destroy(), we subsequently clear the "current + * D3D context" TLS value, which would cause + * wined3d_context_gl_enter() to consider the GL context a non-D3D + * context. */ + if ((current = wined3d_context_gl_get_current()) && current->gl_ctx == restore_ctx) + restore_ctx = NULL; wined3d_context_gl_set_gl_context(context_gl); + } + else + { + restore_ctx = NULL; + }
if (context_gl->valid) {