From 664a5ef70b92cd59efaee676d38944ead52c8f94 Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Fri, 29 Jan 2021 09:53:23 -0800 Subject: [PATCH] drisw: Disable automatic use of layered drivers with LIBGL_ALWAYS_SOFTWARE If LIBGL_ALWAYS_SOFTWARE is set, then drisw is selected, and internally, drisw should choose one of the actual software drivers. If it's not set, but drisw is still selected (no hardware DRM driver, like in WSL), then layered drivers are preferred over pure software. Fixes: 4a3b42a7 ("drisw: Prefer hardware-layered sw-winsys drivers over pure sw") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4171 Acked-by: Daniel Stone Reviewed-by: Dave Airlie Reviewed-by: Adam Jackson Part-of: (cherry picked from commit a88cd98315c6eecd8026402cf785ca5092589b58) --- .pick_status.json | 2 +- src/gallium/auxiliary/target-helpers/inline_sw_helper.h | 6 ++++-- src/gallium/auxiliary/target-helpers/sw_helper.h | 6 ++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 1ff49963c84..d83f5622701 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2551,7 +2551,7 @@ "description": "drisw: Disable automatic use of layered drivers with LIBGL_ALWAYS_SOFTWARE", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": "4a3b42a717ce4fa4450066352f04f2e1ef78ad9a" }, diff --git a/src/gallium/auxiliary/target-helpers/inline_sw_helper.h b/src/gallium/auxiliary/target-helpers/inline_sw_helper.h index ba803d4cda3..c494840c44e 100644 --- a/src/gallium/auxiliary/target-helpers/inline_sw_helper.h +++ b/src/gallium/auxiliary/target-helpers/inline_sw_helper.h @@ -4,6 +4,7 @@ #include "pipe/p_compiler.h" #include "util/u_debug.h" +#include "util/debug.h" #include "frontend/sw_winsys.h" #include "target-helpers/inline_debug_helper.h" @@ -77,13 +78,14 @@ sw_screen_create_named(struct sw_winsys *winsys, const char *driver) static inline struct pipe_screen * sw_screen_create(struct sw_winsys *winsys) { + UNUSED bool only_sw = env_var_as_boolean("LIBGL_ALWAYS_SOFTWARE", false); const char *drivers[] = { debug_get_option("GALLIUM_DRIVER", ""), #if defined(GALLIUM_ZINK) - "zink", + only_sw ? "" : "zink", #endif #if defined(GALLIUM_D3D12) - "d3d12", + only_sw ? "" : "d3d12", #endif #if defined(GALLIUM_LLVMPIPE) "llvmpipe", diff --git a/src/gallium/auxiliary/target-helpers/sw_helper.h b/src/gallium/auxiliary/target-helpers/sw_helper.h index a4eb9ee1067..d9469d9f5e3 100644 --- a/src/gallium/auxiliary/target-helpers/sw_helper.h +++ b/src/gallium/auxiliary/target-helpers/sw_helper.h @@ -4,6 +4,7 @@ #include "pipe/p_compiler.h" #include "util/u_debug.h" +#include "util/debug.h" #include "target-helpers/sw_helper_public.h" #include "frontend/sw_winsys.h" @@ -82,13 +83,14 @@ sw_screen_create_named(struct sw_winsys *winsys, const char *driver) struct pipe_screen * sw_screen_create(struct sw_winsys *winsys) { + UNUSED bool only_sw = env_var_as_boolean("LIBGL_ALWAYS_SOFTWARE", false); const char *drivers[] = { debug_get_option("GALLIUM_DRIVER", ""), #if defined(GALLIUM_ZINK) - "zink", + only_sw ? "" : "zink", #endif #if defined(GALLIUM_D3D12) - "d3d12", + only_sw ? "" : "d3d12", #endif #if defined(GALLIUM_LLVMPIPE) "llvmpipe",