Module: wine Branch: master Commit: 28233dd3bc4963e6205d33aedb665bfdb995c9c6 URL: https://gitlab.winehq.org/wine/wine/-/commit/28233dd3bc4963e6205d33aedb665bf...
Author: Alex Henrie alexhenrie24@gmail.com Date: Sun Apr 9 22:32:57 2023 -0600
winex11: Allow replacing either context in wglShareLists.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=11436
---
dlls/opengl32/tests/opengl.c | 5 ++--- dlls/winex11.drv/opengl.c | 41 ++++++++++++++++++++++------------------- 2 files changed, 24 insertions(+), 22 deletions(-)
diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c index d7a28339916..fca0aea73e7 100644 --- a/dlls/opengl32/tests/opengl.c +++ b/dlls/opengl32/tests/opengl.c @@ -577,7 +577,6 @@ static void test_sharelists(HDC winhdc) if (source_sharing) { res = wglShareLists(other, source); - todo_wine_if(source_current) ok(res, "Sharing of display lists from other to source failed\n"); } if (dest_current) @@ -588,12 +587,12 @@ static void test_sharelists(HDC winhdc) if (dest_sharing) { res = wglShareLists(other, dest); - todo_wine_if(dest_current) + todo_wine_if(source_sharing && dest_current) ok(res, "Sharing of display lists from other to dest failed\n"); }
res = wglShareLists(source, dest); - todo_wine_if(dest_current || dest_sharing) + todo_wine_if((source_current || source_sharing) && (dest_current || dest_sharing)) ok(res || broken(nvidia && !source_sharing && dest_sharing), "Sharing of display lists from source to dest failed\n");
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index 565df8bb4c6..8c1ab90595a 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -1916,6 +1916,8 @@ done: */ static BOOL glxdrv_wglShareLists(struct wgl_context *org, struct wgl_context *dest) { + struct wgl_context *keep, *clobber; + TRACE("(%p, %p)\n", org, dest);
/* Sharing of display lists works differently in GLX and WGL. In case of GLX it is done @@ -1926,34 +1928,35 @@ static BOOL glxdrv_wglShareLists(struct wgl_context *org, struct wgl_context *de * so there delaying context creation doesn't work. * * The new approach is to create a GLX context in wglCreateContext / wglCreateContextAttribsARB - * and when a program requests sharing we recreate the destination context if it hasn't been made - * current or when it hasn't shared display lists before. + * and when a program requests sharing we recreate the destination or source context if it + * hasn't been made current and it hasn't shared display lists before. */
- if(dest->has_been_current) + if (!dest->has_been_current && !dest->sharing) { - ERR("Could not share display lists because the destination context has already been current\n"); - return FALSE; + keep = org; + clobber = dest; } - else if(dest->sharing) + else if (!org->has_been_current && !org->sharing) { - ERR("Could not share display lists because the destination context has already shared lists\n"); - return FALSE; + keep = dest; + clobber = org; } else { - /* Re-create the GLX context and share display lists */ - pglXDestroyContext(gdi_display, dest->ctx); - dest->ctx = create_glxcontext(gdi_display, dest, org->ctx); - TRACE(" re-created context (%p) for Wine context %p (%s) sharing lists with ctx %p (%s)\n", - dest->ctx, dest, debugstr_fbconfig(dest->fmt->fbconfig), - org->ctx, debugstr_fbconfig( org->fmt->fbconfig)); - - org->sharing = TRUE; - dest->sharing = TRUE; - return TRUE; + ERR("Could not share display lists because both of the contexts have already been current or shared\n"); + return FALSE; } - return FALSE; + + pglXDestroyContext(gdi_display, clobber->ctx); + clobber->ctx = create_glxcontext(gdi_display, clobber, keep->ctx); + TRACE("re-created context (%p) for Wine context %p (%s) sharing lists with ctx %p (%s)\n", + clobber->ctx, clobber, debugstr_fbconfig(clobber->fmt->fbconfig), + keep->ctx, debugstr_fbconfig(keep->fmt->fbconfig)); + + org->sharing = TRUE; + dest->sharing = TRUE; + return TRUE; }
static void wglFinish(void)