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