Mesa (master): drisw: Add fallback logic for choosing a driver to use
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Dec 18 01:06:05 UTC 2020
Module: Mesa
Branch: master
Commit: 27ed515c0519f7907362081c790d98240f0919eb
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=27ed515c0519f7907362081c790d98240f0919eb
Author: Jesse Natalie <jenatali at microsoft.com>
Date: Tue Dec 8 16:32:03 2020 -0800
drisw: Add fallback logic for choosing a driver to use
Reviewed-by: Adam Jackson <ajax at redhat.com>
Reviewed-by: Eric Anholt <eric at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8128>
---
.../auxiliary/target-helpers/inline_sw_helper.h | 45 +++++++++++++---------
src/gallium/auxiliary/target-helpers/sw_helper.h | 45 +++++++++++++---------
2 files changed, 54 insertions(+), 36 deletions(-)
diff --git a/src/gallium/auxiliary/target-helpers/inline_sw_helper.h b/src/gallium/auxiliary/target-helpers/inline_sw_helper.h
index e3300940555..9347909f326 100644
--- a/src/gallium/auxiliary/target-helpers/inline_sw_helper.h
+++ b/src/gallium/auxiliary/target-helpers/inline_sw_helper.h
@@ -76,25 +76,34 @@ sw_screen_create_named(struct sw_winsys *winsys, const char *driver)
static inline struct pipe_screen *
sw_screen_create(struct sw_winsys *winsys)
{
- const char *default_driver;
- const char *driver;
-
+ const char *drivers[] = {
+ debug_get_option("GALLIUM_DRIVER", ""),
#if defined(GALLIUM_LLVMPIPE)
- default_driver = "llvmpipe";
-#elif defined(GALLIUM_SOFTPIPE)
- default_driver = "softpipe";
-#elif defined(GALLIUM_SWR)
- default_driver = "swr";
-#elif defined(GALLIUM_ZINK)
- default_driver = "zink";
-#elif defined(GALLIUM_D3D12)
- default_driver = "d3d12";
-#else
- default_driver = "";
-#endif
-
- driver = debug_get_option("GALLIUM_DRIVER", default_driver);
- return sw_screen_create_named(winsys, driver);
+ "llvmpipe",
+#endif
+#if defined(GALLIUM_SOFTPIPE)
+ "softpipe",
+#endif
+#if defined(GALLIUM_SWR)
+ "swr",
+#endif
+#if defined(GALLIUM_ZINK)
+ "zink",
+#endif
+#if defined(GALLIUM_D3D12)
+ "d3d12",
+#endif
+ };
+
+ for (unsigned i = 0; i < ARRAY_SIZE(drivers); i++) {
+ struct pipe_screen *screen = sw_screen_create_named(winsys, drivers[i]);
+ if (screen)
+ return screen;
+ /* If the env var is set, don't keep trying things */
+ else if (i == 0 && drivers[i][0] != '\0')
+ return NULL;
+ }
+ return NULL;
}
#endif
diff --git a/src/gallium/auxiliary/target-helpers/sw_helper.h b/src/gallium/auxiliary/target-helpers/sw_helper.h
index fd1ad904dfb..4fbec159d79 100644
--- a/src/gallium/auxiliary/target-helpers/sw_helper.h
+++ b/src/gallium/auxiliary/target-helpers/sw_helper.h
@@ -82,25 +82,34 @@ sw_screen_create_named(struct sw_winsys *winsys, const char *driver)
struct pipe_screen *
sw_screen_create(struct sw_winsys *winsys)
{
- const char *default_driver;
- const char *driver;
-
+ const char *drivers[] = {
+ debug_get_option("GALLIUM_DRIVER", ""),
#if defined(GALLIUM_LLVMPIPE)
- default_driver = "llvmpipe";
-#elif defined(GALLIUM_SOFTPIPE)
- default_driver = "softpipe";
-#elif defined(GALLIUM_SWR)
- default_driver = "swr";
-#elif defined(GALLIUM_ZINK)
- default_driver = "zink";
-#elif defined(GALLIUM_D3D12)
- default_driver = "d3d12";
-#else
- default_driver = "";
-#endif
-
- driver = debug_get_option("GALLIUM_DRIVER", default_driver);
- return sw_screen_create_named(winsys, driver);
+ "llvmpipe",
+#endif
+#if defined(GALLIUM_SOFTPIPE)
+ "softpipe",
+#endif
+#if defined(GALLIUM_SWR)
+ "swr",
+#endif
+#if defined(GALLIUM_ZINK)
+ "zink",
+#endif
+#if defined(GALLIUM_D3D12)
+ "d3d12",
+#endif
+ };
+
+ for (unsigned i = 0; i < ARRAY_SIZE(drivers); i++) {
+ struct pipe_screen *screen = sw_screen_create_named(winsys, drivers[i]);
+ if (screen)
+ return screen;
+ /* If the env var is set, don't keep trying things */
+ else if (i == 0 && drivers[i][0] != '\0')
+ return NULL;
+ }
+ return NULL;
}
#endif
More information about the mesa-commit
mailing list