Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/auxiliary/target-helpers/inline_sw_helper.h
4561 views
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 "util/debug.h"
8
#include "frontend/sw_winsys.h"
9
#include "target-helpers/inline_debug_helper.h"
10
11
#ifdef GALLIUM_SWR
12
#include "swr/swr_public.h"
13
#endif
14
15
/* Helper function to choose and instantiate one of the software rasterizers:
16
* llvmpipe, softpipe.
17
*/
18
19
#ifdef GALLIUM_SOFTPIPE
20
#include "softpipe/sp_public.h"
21
#endif
22
23
#ifdef GALLIUM_LLVMPIPE
24
#include "llvmpipe/lp_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
#ifdef GALLIUM_D3D12
33
#include "d3d12/d3d12_public.h"
34
#endif
35
36
#ifdef GALLIUM_ASAHI
37
#include "asahi/agx_public.h"
38
#endif
39
40
#ifdef GALLIUM_ZINK
41
struct pipe_screen *zink_create_screen(struct sw_winsys *winsys);
42
#endif
43
44
static inline struct pipe_screen *
45
sw_screen_create_named(struct sw_winsys *winsys, const char *driver)
46
{
47
struct pipe_screen *screen = NULL;
48
49
#if defined(GALLIUM_LLVMPIPE)
50
if (screen == NULL && strcmp(driver, "llvmpipe") == 0)
51
screen = llvmpipe_create_screen(winsys);
52
#endif
53
54
#if defined(GALLIUM_VIRGL)
55
if (screen == NULL && strcmp(driver, "virpipe") == 0) {
56
struct virgl_winsys *vws;
57
vws = virgl_vtest_winsys_wrap(winsys);
58
screen = virgl_create_screen(vws, NULL);
59
}
60
#endif
61
62
#if defined(GALLIUM_SOFTPIPE)
63
if (screen == NULL && strcmp(driver, "softpipe") == 0)
64
screen = softpipe_create_screen(winsys);
65
#endif
66
67
#if defined(GALLIUM_SWR)
68
if (screen == NULL && strcmp(driver, "swr") == 0)
69
screen = swr_create_screen(winsys);
70
#endif
71
72
#if defined(GALLIUM_ZINK)
73
if (screen == NULL && strcmp(driver, "zink") == 0)
74
screen = zink_create_screen(winsys);
75
#endif
76
77
#if defined(GALLIUM_D3D12)
78
if (screen == NULL && strcmp(driver, "d3d12") == 0)
79
screen = d3d12_create_dxcore_screen(winsys, NULL);
80
#endif
81
82
#if defined(GALLIUM_ASAHI)
83
if (screen == NULL && strcmp(driver, "asahi") == 0)
84
screen = agx_screen_create(winsys);
85
#endif
86
87
return screen ? debug_screen_wrap(screen) : NULL;
88
}
89
90
91
static inline struct pipe_screen *
92
sw_screen_create_vk(struct sw_winsys *winsys, bool sw_vk)
93
{
94
UNUSED bool only_sw = env_var_as_boolean("LIBGL_ALWAYS_SOFTWARE", false);
95
const char *drivers[] = {
96
(sw_vk ? "" : debug_get_option("GALLIUM_DRIVER", "")),
97
#if defined(GALLIUM_D3D12)
98
(sw_vk || only_sw) ? "" : "d3d12",
99
#endif
100
#if defined(GALLIUM_ASAHI)
101
(sw_vk || only_sw) ? "" : "asahi",
102
#endif
103
#if defined(GALLIUM_LLVMPIPE)
104
"llvmpipe",
105
#endif
106
#if defined(GALLIUM_SOFTPIPE)
107
(sw_vk ? "" : "softpipe"),
108
#endif
109
#if defined(GALLIUM_SWR)
110
(sw_vk ? "" : "swr"),
111
#endif
112
#if defined(GALLIUM_ZINK)
113
(sw_vk || only_sw) ? "" : "zink",
114
#endif
115
};
116
117
for (unsigned i = 0; i < ARRAY_SIZE(drivers); i++) {
118
struct pipe_screen *screen = sw_screen_create_named(winsys, drivers[i]);
119
if (screen)
120
return screen;
121
/* If the env var is set, don't keep trying things */
122
else if (i == 0 && drivers[i][0] != '\0')
123
return NULL;
124
}
125
return NULL;
126
}
127
128
static inline struct pipe_screen *
129
sw_screen_create(struct sw_winsys *winsys)
130
{
131
return sw_screen_create_vk(winsys, false);
132
}
133
#endif
134
135