targets/nine: use the existing sw_screen_wrap() over our custom version
[mesa.git] / src / gallium / auxiliary / target-helpers / inline_sw_helper.h
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 "state_tracker/sw_winsys.h"
8
9
10 /* Helper function to choose and instantiate one of the software rasterizers:
11 * llvmpipe, softpipe.
12 */
13
14 #ifdef GALLIUM_SOFTPIPE
15 #include "softpipe/sp_public.h"
16 #endif
17
18 #ifdef GALLIUM_LLVMPIPE
19 #include "llvmpipe/lp_public.h"
20 #endif
21
22 #ifdef GALLIUM_VIRGL
23 #include "virgl/virgl_public.h"
24 #include "virgl/vtest/virgl_vtest_public.h"
25 #endif
26
27 static inline struct pipe_screen *
28 sw_screen_create_named(struct sw_winsys *winsys, const char *driver)
29 {
30 struct pipe_screen *screen = NULL;
31
32 #if defined(GALLIUM_LLVMPIPE)
33 if (screen == NULL && strcmp(driver, "llvmpipe") == 0)
34 screen = llvmpipe_create_screen(winsys);
35 #endif
36
37 #if defined(GALLIUM_VIRGL)
38 if (screen == NULL && strcmp(driver, "virpipe") == 0) {
39 struct virgl_winsys *vws;
40 vws = virgl_vtest_winsys_wrap(winsys);
41 screen = virgl_create_screen(vws);
42 }
43 #endif
44
45 #if defined(GALLIUM_SOFTPIPE)
46 if (screen == NULL)
47 screen = softpipe_create_screen(winsys);
48 #endif
49
50 return screen;
51 }
52
53
54 static inline struct pipe_screen *
55 sw_screen_create(struct sw_winsys *winsys)
56 {
57 const char *default_driver;
58 const char *driver;
59
60 #if defined(GALLIUM_LLVMPIPE)
61 default_driver = "llvmpipe";
62 #elif defined(GALLIUM_SOFTPIPE)
63 default_driver = "softpipe";
64 #else
65 default_driver = "";
66 #endif
67
68 driver = debug_get_option("GALLIUM_DRIVER", default_driver);
69 return sw_screen_create_named(winsys, driver);
70 }
71
72 #if defined(GALLIUM_SOFTPIPE)
73 #if defined(DRI_TARGET)
74 #include "target-helpers/inline_debug_helper.h"
75 #include "sw/dri/dri_sw_winsys.h"
76 #include "dri_screen.h"
77
78 const __DRIextension **__driDriverGetExtensions_swrast(void);
79
80 PUBLIC const __DRIextension **__driDriverGetExtensions_swrast(void)
81 {
82 globalDriverAPI = &galliumsw_driver_api;
83 return galliumsw_driver_extensions;
84 }
85
86 inline struct pipe_screen *
87 drisw_create_screen(struct drisw_loader_funcs *lf)
88 {
89 struct sw_winsys *winsys = NULL;
90 struct pipe_screen *screen = NULL;
91
92 winsys = dri_create_sw_winsys(lf);
93 if (winsys == NULL)
94 return NULL;
95
96 screen = sw_screen_create(winsys);
97 if (screen == NULL) {
98 winsys->destroy(winsys);
99 return NULL;
100 }
101
102 screen = debug_screen_wrap(screen);
103 return screen;
104 }
105 #endif // DRI_TARGET
106
107 #endif // GALLIUM_SOFTPIPE
108
109
110 #endif