1
2 #ifndef INLINE_SW_HELPER_H
3 #define INLINE_SW_HELPER_H
4
5 #include "pipe/p_compiler.h"
6 #include "util/u_debug.h"
7 #include "frontend/sw_winsys.h"
8
9 #ifdef GALLIUM_SWR
10 #include "swr/swr_public.h"
11 #endif
12
13 /* Helper function to choose and instantiate one of the software rasterizers:
14 * llvmpipe, softpipe.
15 */
16
17 #ifdef GALLIUM_SOFTPIPE
18 #include "softpipe/sp_public.h"
19 #endif
20
21 #ifdef GALLIUM_LLVMPIPE
22 #include "llvmpipe/lp_public.h"
23 #endif
24
25 #ifdef GALLIUM_VIRGL
26 #include "virgl/virgl_public.h"
27 #include "virgl/vtest/virgl_vtest_public.h"
28 #endif
29
30 static inline struct pipe_screen *
sw_screen_create_named(struct sw_winsys * winsys,const char * driver)31 sw_screen_create_named(struct sw_winsys *winsys, const char *driver)
32 {
33 struct pipe_screen *screen = NULL;
34
35 #if defined(GALLIUM_LLVMPIPE)
36 if (screen == NULL && strcmp(driver, "llvmpipe") == 0)
37 screen = llvmpipe_create_screen(winsys);
38 #endif
39
40 #if defined(GALLIUM_VIRGL)
41 if (screen == NULL && strcmp(driver, "virpipe") == 0) {
42 struct virgl_winsys *vws;
43 vws = virgl_vtest_winsys_wrap(winsys);
44 screen = virgl_create_screen(vws, NULL);
45 }
46 #endif
47
48 #if defined(GALLIUM_SOFTPIPE)
49 if (screen == NULL && strcmp(driver, "softpipe") == 0)
50 screen = softpipe_create_screen(winsys);
51 #endif
52
53 #if defined(GALLIUM_SWR)
54 if (screen == NULL && strcmp(driver, "swr") == 0)
55 screen = swr_create_screen(winsys);
56 #endif
57
58 #if defined(GALLIUM_ZINK)
59 if (screen == NULL && strcmp(driver, "zink") == 0)
60 screen = zink_create_screen(winsys);
61 #endif
62
63 return screen;
64 }
65
66
67 static inline struct pipe_screen *
sw_screen_create(struct sw_winsys * winsys)68 sw_screen_create(struct sw_winsys *winsys)
69 {
70 const char *default_driver;
71 const char *driver;
72
73 #if defined(GALLIUM_LLVMPIPE)
74 default_driver = "llvmpipe";
75 #elif defined(GALLIUM_SOFTPIPE)
76 default_driver = "softpipe";
77 #elif defined(GALLIUM_SWR)
78 default_driver = "swr";
79 #elif defined(GALLIUM_ZINK)
80 default_driver = "zink";
81 #else
82 default_driver = "";
83 #endif
84
85 driver = debug_get_option("GALLIUM_DRIVER", default_driver);
86 return sw_screen_create_named(winsys, driver);
87 }
88
89 #endif
90