From 7f3ea4e00c57db64c171c66ef30c7a3e70a34526 Mon Sep 17 00:00:00 2001 From: Kurt Kartaltepe Date: Tue, 9 Aug 2022 09:15:48 -0700 Subject: [PATCH] libobs-opengl: Check window creation for errors Without this we get somewhat misleading errors from later in the swapchain creation when this fails. This is currently happening for users attempting to use multi-gpu with prime offloading on nvidia. --- libobs-opengl/gl-x11-egl.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/libobs-opengl/gl-x11-egl.c b/libobs-opengl/gl-x11-egl.c index c3e541afb..2ca20441a 100644 --- a/libobs-opengl/gl-x11-egl.c +++ b/libobs-opengl/gl-x11-egl.c @@ -416,9 +416,20 @@ static bool gl_x11_egl_platform_init_swapchain(struct gs_swap_chain *swap) xcb_create_colormap(xcb_conn, XCB_COLORMAP_ALLOC_NONE, colormap, parent, visual); - xcb_create_window(xcb_conn, 24 /* Hardcoded? */, wid, parent, 0, 0, - geometry->width, geometry->height, 0, 0, visual, mask, - mask_values); + xcb_void_cookie_t window_cookie = xcb_create_window_checked( + xcb_conn, 24 /* Hardcoded? */, wid, parent, 0, 0, + geometry->width, geometry->height, 0, 0, visual, mask, + mask_values); + xcb_generic_error_t *err = xcb_request_check(xcb_conn, window_cookie); + if (err != NULL) { + char text[512]; + XGetErrorText(display, err->error_code, text, sizeof(text)); + blog(LOG_ERROR, + "Swapchain window creation failed: %s" + ", Major opcode: %d, Minor opcode: %d", + text, err->major_code, err->minor_code); + goto fail_window_surface; + } const EGLSurface surface = eglCreateWindowSurface(plat->edisplay, plat->config, wid, 0);