Zhiyi Zhang : winex11.drv: Handle X errors from glXCopyContext().

Alexandre Julliard julliard at winehq.org
Wed Jul 13 16:56:07 CDT 2022


Module: wine
Branch: master
Commit: ed546bf190cf5570df3086e4c7c42f7083c2a5a3
URL:    https://gitlab.winehq.org/wine/wine/-/commit/ed546bf190cf5570df3086e4c7c42f7083c2a5a3

Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date:   Fri Apr 22 17:21:15 2022 +0800

winex11.drv: Handle X errors from glXCopyContext().

glxCopyContext() may throw X errors and cause the current process to exit. For example, Mesa doesn't
support glxCopyContext() for direct rendering contexts and ends up using the code path for indirect
rendering contexts. When Xorg receives such requests, it rejects them because they're for direct
rendering contexts and reports an X error. We also can't use indirect rendering context because
it needs to be explicitly enabled in xorg.conf and has poor performance. So handle this error before
graphics drivers implement the support.

Fix Cladun X2 crash at start.

Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>

---

 dlls/winex11.drv/opengl.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
index 8d6afba9a6f..7ceaeb7c2df 100644
--- a/dlls/winex11.drv/opengl.c
+++ b/dlls/winex11.drv/opengl.c
@@ -1711,9 +1711,21 @@ static BOOL WINAPI glxdrv_wglCopyContext(struct wgl_context *src, struct wgl_con
 {
     TRACE("%p -> %p mask %#x\n", src, dst, mask);
 
-    pglXCopyContext(gdi_display, src->ctx, dst->ctx, mask);
+    X11DRV_expect_error( gdi_display, GLXErrorHandler, NULL );
+    pglXCopyContext( gdi_display, src->ctx, dst->ctx, mask );
+    XSync( gdi_display, False );
+    if (X11DRV_check_error())
+    {
+        static unsigned int once;
+
+        if (!once++)
+        {
+            ERR("glXCopyContext failed. glXCopyContext() for direct rendering contexts not "
+                "implemented in the host graphics driver?\n");
+        }
+        return FALSE;
+    }
 
-    /* As opposed to wglCopyContext, glXCopyContext doesn't return anything, so hopefully we passed */
     return TRUE;
 }
 




More information about the wine-cvs mailing list