From cfa955ed78bef56ba025a64468e8b841149fab18 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 12 Mar 2024 14:59:55 -0400 Subject: [PATCH] glx/egl: fix LIBGL_KOPPER_DISABLE when set, this disables the use of vk swapchains and lets the dri frontend manage buffers like any other driver also document some kopper env vars Acked-by: Dave Airlie Part-of: --- docs/envvars.rst | 16 ++++++++++++++++ src/egl/drivers/dri2/platform_x11.c | 3 ++- src/egl/drivers/dri2/platform_x11_dri3.c | 3 ++- src/gallium/targets/dri/target.c | 6 +----- src/glx/dri3_glx.c | 3 ++- src/glx/glxext.c | 3 ++- 6 files changed, 25 insertions(+), 9 deletions(-) diff --git a/docs/envvars.rst b/docs/envvars.rst index e7250b7f6ae93..ddcd3515785fa 100644 --- a/docs/envvars.rst +++ b/docs/envvars.rst @@ -38,6 +38,22 @@ LibGL environment variables disable DRI3 if set to ``true``. +.. envvar:: LIBGL_KOPPER_DISABLE + + disable vulkan swapchains with zink if set to ``true``. + In general, this should not be used unless you know what you are + doing. Some examples of "knowing what you are doing" include: + - using a VK driver which has no WSI implementation for your display server + - profiling the DRI frontend against your VK driver's WSI implementation + +.. envvar:: LIBGL_KOPPER_DRI2 + + disable DRI3 with zink if set to ``true``. + In general, this should not be used unless you know what you are + doing. Some examples of "knowing what you are doing" include: + - running xrdp + - using a VK driver which doesn't support modifiers + Core Mesa environment variables ------------------------------- diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c index ad1c1856a4bdf..f1535bec1a856 100644 --- a/src/egl/drivers/dri2/platform_x11.c +++ b/src/egl/drivers/dri2/platform_x11.c @@ -1803,7 +1803,8 @@ EGLBoolean dri2_initialize_x11(_EGLDisplay *disp) { enum dri2_egl_driver_fail status = DRI2_EGL_DRIVER_FAILED; - if (disp->Options.ForceSoftware || disp->Options.Zink) + if (disp->Options.ForceSoftware || + (disp->Options.Zink && !debug_get_bool_option("LIBGL_KOPPER_DISABLE", false))) return dri2_initialize_x11_swrast(disp); #ifdef HAVE_DRI3 diff --git a/src/egl/drivers/dri2/platform_x11_dri3.c b/src/egl/drivers/dri2/platform_x11_dri3.c index 528c0a22bb274..c80e73eaae6c5 100644 --- a/src/egl/drivers/dri2/platform_x11_dri3.c +++ b/src/egl/drivers/dri2/platform_x11_dri3.c @@ -635,7 +635,8 @@ dri3_x11_connect(struct dri2_egl_display *dri2_dpy) if (!dri2_dpy->driver_name) dri2_dpy->driver_name = loader_get_driver_for_fd(dri2_dpy->fd_render_gpu); - if (!strcmp(dri2_dpy->driver_name, "zink")) { + if (!strcmp(dri2_dpy->driver_name, "zink") && + !debug_get_bool_option("LIBGL_KOPPER_DISABLE", false)) { close(dri2_dpy->fd_render_gpu); return DRI2_EGL_DRIVER_PREFER_ZINK; } diff --git a/src/gallium/targets/dri/target.c b/src/gallium/targets/dri/target.c index 972d1d2416625..b5e360349aca9 100644 --- a/src/gallium/targets/dri/target.c +++ b/src/gallium/targets/dri/target.c @@ -142,17 +142,13 @@ DEFINE_LOADER_DRM_ENTRYPOINT(lima) #endif #if defined(GALLIUM_ZINK) -#if DETECT_OS_ANDROID -DEFINE_LOADER_DRM_ENTRYPOINT(zink); -#else const __DRIextension **__driDriverGetExtensions_zink(void); PUBLIC const __DRIextension **__driDriverGetExtensions_zink(void) { - return galliumvk_driver_extensions; + return debug_get_bool_option("LIBGL_KOPPER_DISABLE", false) ? galliumdrm_driver_extensions : galliumvk_driver_extensions; } #endif -#endif #if defined(GALLIUM_D3D12) DEFINE_LOADER_DRM_ENTRYPOINT(d3d12); diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c index 12a05246af1d0..68257cc72bd48 100644 --- a/src/glx/dri3_glx.c +++ b/src/glx/dri3_glx.c @@ -78,6 +78,7 @@ #include "loader.h" #include "loader_dri_helper.h" #include "dri2.h" +#include "util/u_debug.h" static struct dri3_drawable * loader_drawable_to_dri3_drawable(struct loader_dri3_drawable *draw) { @@ -836,7 +837,7 @@ dri3_create_screen(int screen, struct glx_display * priv) goto handle_error; } - if (!strcmp(driverName, "zink")) { + if (!strcmp(driverName, "zink") && !debug_get_bool_option("LIBGL_KOPPER_DISABLE", false)) { return_zink = true; goto handle_error; } diff --git a/src/glx/glxext.c b/src/glx/glxext.c index 6a9ba8b5975d6..dad8ef4722bc7 100644 --- a/src/glx/glxext.c +++ b/src/glx/glxext.c @@ -907,7 +907,8 @@ __glXInitialize(Display * dpy) ** (e.g., those called in AllocAndFetchScreenConfigs). */ #if defined(GLX_USE_DRM) - if (glx_direct && glx_accel && !zink) { + if (glx_direct && glx_accel && + (!zink || debug_get_bool_option("LIBGL_KOPPER_DISABLE", false))) { #if defined(HAVE_DRI3) if (!debug_get_bool_option("LIBGL_DRI3_DISABLE", false)) { dpyPriv->dri3Display = dri3_create_display(dpy);