Mesa (main): gallium/sw: add sw_vk bit to avoid having to futz with env vars for lavapipe
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jul 1 10:52:06 UTC 2021
Module: Mesa
Branch: main
Commit: 75a8246563113da1dbfda03a0efcbba80df36920
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=75a8246563113da1dbfda03a0efcbba80df36920
Author: Dave Airlie <airlied at redhat.com>
Date: Wed Jun 30 05:22:58 2021 +1000
gallium/sw: add sw_vk bit to avoid having to futz with env vars for lavapipe
lavapipe really only currently works with llvmpipe, and likely for the forseeable
future.
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11643>
---
src/gallium/auxiliary/pipe-loader/pipe_loader.c | 10 ++++++++--
src/gallium/auxiliary/pipe-loader/pipe_loader.h | 9 +++++++++
src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c | 2 +-
src/gallium/auxiliary/pipe-loader/pipe_loader_priv.h | 2 +-
src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c | 6 +++---
.../auxiliary/target-helpers/inline_sw_helper.h | 19 ++++++++++++-------
src/gallium/auxiliary/target-helpers/sw_helper.h | 20 ++++++++++++--------
.../auxiliary/target-helpers/sw_helper_public.h | 3 +++
src/gallium/frontends/lavapipe/lvp_device.c | 2 +-
src/gallium/include/frontend/sw_driver.h | 2 +-
src/gallium/targets/pipe-loader/pipe_swrast.c | 4 ++--
11 files changed, 53 insertions(+), 26 deletions(-)
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.c b/src/gallium/auxiliary/pipe-loader/pipe_loader.c
index 4b6ac054fcc..5ec9355b70c 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.c
@@ -148,7 +148,7 @@ pipe_loader_get_driinfo_xml(const char *driver_name)
}
struct pipe_screen *
-pipe_loader_create_screen(struct pipe_loader_device *dev)
+pipe_loader_create_screen_vk(struct pipe_loader_device *dev, bool sw_vk)
{
struct pipe_screen_config config;
@@ -156,7 +156,13 @@ pipe_loader_create_screen(struct pipe_loader_device *dev)
pipe_loader_load_options(dev);
config.options = &dev->option_cache;
- return dev->ops->create_screen(dev, &config);
+ return dev->ops->create_screen(dev, &config, sw_vk);
+}
+
+struct pipe_screen *
+pipe_loader_create_screen(struct pipe_loader_device *dev)
+{
+ return pipe_loader_create_screen_vk(dev, false);
}
struct util_dl_library *
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.h b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
index ab89ed6f6a8..5cd1b994213 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader.h
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
@@ -82,6 +82,15 @@ struct pipe_loader_device {
int
pipe_loader_probe(struct pipe_loader_device **devs, int ndev);
+/**
+ * Create a pipe_screen for the specified device.
+ *
+ * \param dev Device the screen will be created for.
+ * \param sw_vk Device is for software vulkan
+ */
+struct pipe_screen *
+pipe_loader_create_screen_vk(struct pipe_loader_device *dev, bool sw_vk);
+
/**
* Create a pipe_screen for the specified device.
*
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
index ca5bf121a88..b3bdfc90d97 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
@@ -262,7 +262,7 @@ pipe_loader_drm_get_driconf(struct pipe_loader_device *dev, unsigned *count)
static struct pipe_screen *
pipe_loader_drm_create_screen(struct pipe_loader_device *dev,
- const struct pipe_screen_config *config)
+ const struct pipe_screen_config *config, bool sw_vk)
{
struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(dev);
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_priv.h b/src/gallium/auxiliary/pipe-loader/pipe_loader_priv.h
index 7f87cacd929..b1c971d75e2 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_priv.h
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_priv.h
@@ -32,7 +32,7 @@
struct pipe_loader_ops {
struct pipe_screen *(*create_screen)(struct pipe_loader_device *dev,
- const struct pipe_screen_config *config);
+ const struct pipe_screen_config *config, bool sw_vk);
const struct driOptionDescription *(*get_driconf)(struct pipe_loader_device *dev,
unsigned *count);
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
index daf1546851d..85f8d94b826 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
@@ -61,7 +61,7 @@ static const struct pipe_loader_ops pipe_loader_sw_ops;
#ifdef GALLIUM_STATIC_TARGETS
static const struct sw_driver_descriptor driver_descriptors = {
- .create_screen = sw_screen_create,
+ .create_screen = sw_screen_create_vk,
.winsys = {
#ifdef HAVE_PIPE_LOADER_DRI
{
@@ -305,12 +305,12 @@ pipe_loader_sw_get_driconf(struct pipe_loader_device *dev, unsigned *count)
static struct pipe_screen *
pipe_loader_sw_create_screen(struct pipe_loader_device *dev,
- const struct pipe_screen_config *config)
+ const struct pipe_screen_config *config, bool sw_vk)
{
struct pipe_loader_sw_device *sdev = pipe_loader_sw_device(dev);
struct pipe_screen *screen;
- screen = sdev->dd->create_screen(sdev->ws);
+ screen = sdev->dd->create_screen(sdev->ws, sw_vk);
if (!screen)
sdev->ws->destroy(sdev->ws);
diff --git a/src/gallium/auxiliary/target-helpers/inline_sw_helper.h b/src/gallium/auxiliary/target-helpers/inline_sw_helper.h
index 8271df0cb0b..4fb74993d0b 100644
--- a/src/gallium/auxiliary/target-helpers/inline_sw_helper.h
+++ b/src/gallium/auxiliary/target-helpers/inline_sw_helper.h
@@ -85,28 +85,28 @@ sw_screen_create_named(struct sw_winsys *winsys, const char *driver)
static inline struct pipe_screen *
-sw_screen_create(struct sw_winsys *winsys)
+sw_screen_create_vk(struct sw_winsys *winsys, bool sw_vk)
{
UNUSED bool only_sw = env_var_as_boolean("LIBGL_ALWAYS_SOFTWARE", false);
const char *drivers[] = {
- debug_get_option("GALLIUM_DRIVER", ""),
+ (sw_vk ? "" : debug_get_option("GALLIUM_DRIVER", "")),
#if defined(GALLIUM_D3D12)
- only_sw ? "" : "d3d12",
+ (sw_vk || only_sw) ? "" : "d3d12",
#endif
#if defined(GALLIUM_ASAHI)
- only_sw ? "" : "asahi",
+ (sw_vk || only_sw) ? "" : "asahi",
#endif
#if defined(GALLIUM_LLVMPIPE)
"llvmpipe",
#endif
#if defined(GALLIUM_SOFTPIPE)
- "softpipe",
+ (sw_vk ? "" : "softpipe"),
#endif
#if defined(GALLIUM_SWR)
- "swr",
+ (sw_vk ? "" : "swr"),
#endif
#if defined(GALLIUM_ZINK)
- only_sw ? "" : "zink",
+ (sw_vk || only_sw) ? "" : "zink",
#endif
};
@@ -121,4 +121,9 @@ sw_screen_create(struct sw_winsys *winsys)
return NULL;
}
+static inline struct pipe_screen *
+sw_screen_create(struct sw_winsys *winsys)
+{
+ return sw_screen_create_vk(winsys, false);
+}
#endif
diff --git a/src/gallium/auxiliary/target-helpers/sw_helper.h b/src/gallium/auxiliary/target-helpers/sw_helper.h
index 343c0410558..059ae2d4422 100644
--- a/src/gallium/auxiliary/target-helpers/sw_helper.h
+++ b/src/gallium/auxiliary/target-helpers/sw_helper.h
@@ -88,30 +88,29 @@ sw_screen_create_named(struct sw_winsys *winsys, const char *driver)
return screen;
}
-
struct pipe_screen *
-sw_screen_create(struct sw_winsys *winsys)
+sw_screen_create_vk(struct sw_winsys *winsys, bool sw_vk)
{
UNUSED bool only_sw = env_var_as_boolean("LIBGL_ALWAYS_SOFTWARE", false);
const char *drivers[] = {
- debug_get_option("GALLIUM_DRIVER", ""),
+ (sw_vk ? "" : debug_get_option("GALLIUM_DRIVER", "")),
#if defined(GALLIUM_D3D12)
- only_sw ? "" : "d3d12",
+ (sw_vk || only_sw) ? "" : "d3d12",
#endif
#if defined(GALLIUM_ASAHI)
- only_sw ? "" : "asahi",
+ (sw_vk || only_sw) ? "" : "asahi",
#endif
#if defined(GALLIUM_LLVMPIPE)
"llvmpipe",
#endif
#if defined(GALLIUM_SOFTPIPE)
- "softpipe",
+ sw_vk ? "" : "softpipe",
#endif
#if defined(GALLIUM_SWR)
- "swr",
+ sw_vk ? "" : "swr",
#endif
#if defined(GALLIUM_ZINK)
- only_sw ? "" : "zink",
+ (sw_vk || only_sw) ? "" : "zink",
#endif
};
@@ -126,4 +125,9 @@ sw_screen_create(struct sw_winsys *winsys)
return NULL;
}
+struct pipe_screen *
+sw_screen_create(struct sw_winsys *winsys)
+{
+ return sw_screen_create_vk(winsys, false);
+}
#endif
diff --git a/src/gallium/auxiliary/target-helpers/sw_helper_public.h b/src/gallium/auxiliary/target-helpers/sw_helper_public.h
index 12b301b6ab4..499813cca4d 100644
--- a/src/gallium/auxiliary/target-helpers/sw_helper_public.h
+++ b/src/gallium/auxiliary/target-helpers/sw_helper_public.h
@@ -4,6 +4,9 @@
struct pipe_screen;
struct sw_winsys;
+struct pipe_screen *
+sw_screen_create_vk(struct sw_winsys *winsys, bool sw_vk);
+
struct pipe_screen *
sw_screen_create(struct sw_winsys *winsys);
diff --git a/src/gallium/frontends/lavapipe/lvp_device.c b/src/gallium/frontends/lavapipe/lvp_device.c
index 9420b17ed40..46e17f275ef 100644
--- a/src/gallium/frontends/lavapipe/lvp_device.c
+++ b/src/gallium/frontends/lavapipe/lvp_device.c
@@ -162,7 +162,7 @@ lvp_physical_device_init(struct lvp_physical_device *device,
}
device->pld = pld;
- device->pscreen = pipe_loader_create_screen(device->pld);
+ device->pscreen = pipe_loader_create_screen_vk(device->pld, true);
if (!device->pscreen)
return vk_error(instance, VK_ERROR_OUT_OF_HOST_MEMORY);
diff --git a/src/gallium/include/frontend/sw_driver.h b/src/gallium/include/frontend/sw_driver.h
index ca335556311..a0385c57c4c 100644
--- a/src/gallium/include/frontend/sw_driver.h
+++ b/src/gallium/include/frontend/sw_driver.h
@@ -9,7 +9,7 @@ struct sw_winsys;
struct sw_driver_descriptor
{
- struct pipe_screen *(*create_screen)(struct sw_winsys *ws);
+ struct pipe_screen *(*create_screen)(struct sw_winsys *ws, bool sw_vk);
struct {
const char * const name;
struct sw_winsys *(*create_winsys)();
diff --git a/src/gallium/targets/pipe-loader/pipe_swrast.c b/src/gallium/targets/pipe-loader/pipe_swrast.c
index ebfc11c8936..fcbc904061f 100644
--- a/src/gallium/targets/pipe-loader/pipe_swrast.c
+++ b/src/gallium/targets/pipe-loader/pipe_swrast.c
@@ -8,10 +8,10 @@
#include "sw/wrapper/wrapper_sw_winsys.h"
PUBLIC struct pipe_screen *
-swrast_create_screen(struct sw_winsys *ws);
+swrast_create_screen(struct sw_winsys *ws, bool sw_vk);
struct pipe_screen *
-swrast_create_screen(struct sw_winsys *ws)
+swrast_create_screen(struct sw_winsys *ws, bool sw_vk)
{
struct pipe_screen *screen;
More information about the mesa-commit
mailing list