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@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11643>
This commit is contained in:
Dave Airlie
2021-06-30 05:22:58 +10:00
committed by Marge Bot
parent ed123a03be
commit 75a8246563
11 changed files with 53 additions and 26 deletions

View File

@@ -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 *

View File

@@ -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.
*

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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

View File

@@ -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

View File

@@ -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);

View File

@@ -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);

View File

@@ -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)();

View File

@@ -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;