Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/auxiliary/target-helpers/drm_helper.h
4561 views
1
#ifndef DRM_HELPER_H
2
#define DRM_HELPER_H
3
4
#include <stdio.h>
5
#include "target-helpers/inline_debug_helper.h"
6
#include "target-helpers/drm_helper_public.h"
7
#include "frontend/drm_driver.h"
8
#include "util/driconf.h"
9
10
/**
11
* Instantiate a drm_driver_descriptor struct.
12
*/
13
#define DEFINE_DRM_DRIVER_DESCRIPTOR(descriptor_name, driver, _driconf, _driconf_count, func) \
14
const struct drm_driver_descriptor descriptor_name = { \
15
.driver_name = #driver, \
16
.driconf = _driconf, \
17
.driconf_count = _driconf_count, \
18
.create_screen = func, \
19
};
20
21
/* The static pipe loader refers to the *_driver_descriptor structs for all
22
* drivers, regardless of whether they are configured in this Mesa build, or
23
* whether they're included in the specific gallium target. The target (dri,
24
* vdpau, etc.) will include this header with the #defines for the specific
25
* drivers it's including, and the disabled drivers will have a descriptor
26
* with a stub create function logging the failure.
27
*
28
* The dynamic pipe loader instead has target/pipeloader/pipe_*.c including
29
* this header in a pipe_*.so for each driver which will have one driver's
30
* GALLIUM_* defined. We make a single driver_descriptor entrypoint that is
31
* dlsym()ed by the dynamic pipe loader.
32
*/
33
34
#ifdef PIPE_LOADER_DYNAMIC
35
36
#define DRM_DRIVER_DESCRIPTOR(driver, driconf, driconf_count) \
37
PUBLIC DEFINE_DRM_DRIVER_DESCRIPTOR(driver_descriptor, driver, driconf, driconf_count, pipe_##driver##_create_screen)
38
39
#define DRM_DRIVER_DESCRIPTOR_STUB(driver)
40
41
#define DRM_DRIVER_DESCRIPTOR_ALIAS(driver, alias, driconf, driconf_count)
42
43
#else
44
45
#define DRM_DRIVER_DESCRIPTOR(driver, driconf, driconf_count) \
46
DEFINE_DRM_DRIVER_DESCRIPTOR(driver##_driver_descriptor, driver, driconf, driconf_count, pipe_##driver##_create_screen)
47
48
#define DRM_DRIVER_DESCRIPTOR_STUB(driver) \
49
static struct pipe_screen * \
50
pipe_##driver##_create_screen(int fd, const struct pipe_screen_config *config) \
51
{ \
52
fprintf(stderr, #driver ": driver missing\n"); \
53
return NULL; \
54
} \
55
DRM_DRIVER_DESCRIPTOR(driver, NULL, 0)
56
57
#define DRM_DRIVER_DESCRIPTOR_ALIAS(driver, alias, driconf, driconf_count) \
58
DEFINE_DRM_DRIVER_DESCRIPTOR(alias##_driver_descriptor, alias, driconf, \
59
driconf_count, pipe_##driver##_create_screen)
60
61
#endif
62
63
#ifdef GALLIUM_KMSRO_ONLY
64
#undef GALLIUM_V3D
65
#undef GALLIUM_VC4
66
#undef GALLIUM_FREEDRENO
67
#undef GALLIUM_ETNAVIV
68
#undef GALLIUM_PANFROST
69
#undef GALLIUM_LIMA
70
#endif
71
72
#ifdef GALLIUM_I915
73
#include "i915/drm/i915_drm_public.h"
74
#include "i915/i915_public.h"
75
76
static struct pipe_screen *
77
pipe_i915_create_screen(int fd, const struct pipe_screen_config *config)
78
{
79
struct i915_winsys *iws;
80
struct pipe_screen *screen;
81
82
iws = i915_drm_winsys_create(fd);
83
if (!iws)
84
return NULL;
85
86
screen = i915_screen_create(iws);
87
return screen ? debug_screen_wrap(screen) : NULL;
88
}
89
DRM_DRIVER_DESCRIPTOR(i915, NULL, 0)
90
#else
91
DRM_DRIVER_DESCRIPTOR_STUB(i915)
92
#endif
93
94
#ifdef GALLIUM_IRIS
95
#include "iris/drm/iris_drm_public.h"
96
97
static struct pipe_screen *
98
pipe_iris_create_screen(int fd, const struct pipe_screen_config *config)
99
{
100
struct pipe_screen *screen;
101
102
screen = iris_drm_screen_create(fd, config);
103
return screen ? debug_screen_wrap(screen) : NULL;
104
}
105
106
const driOptionDescription iris_driconf[] = {
107
#include "iris/driinfo_iris.h"
108
};
109
DRM_DRIVER_DESCRIPTOR(iris, iris_driconf, ARRAY_SIZE(iris_driconf))
110
111
#else
112
DRM_DRIVER_DESCRIPTOR_STUB(iris)
113
#endif
114
115
#ifdef GALLIUM_CROCUS
116
#include "crocus/drm/crocus_drm_public.h"
117
118
static struct pipe_screen *
119
pipe_crocus_create_screen(int fd, const struct pipe_screen_config *config)
120
{
121
struct pipe_screen *screen;
122
123
screen = crocus_drm_screen_create(fd, config);
124
return screen ? debug_screen_wrap(screen) : NULL;
125
}
126
127
const driOptionDescription crocus_driconf[] = {
128
#include "crocus/driinfo_crocus.h"
129
};
130
DRM_DRIVER_DESCRIPTOR(crocus, crocus_driconf, ARRAY_SIZE(crocus_driconf))
131
#else
132
DRM_DRIVER_DESCRIPTOR_STUB(crocus)
133
#endif
134
135
#ifdef GALLIUM_NOUVEAU
136
#include "nouveau/drm/nouveau_drm_public.h"
137
138
static struct pipe_screen *
139
pipe_nouveau_create_screen(int fd, const struct pipe_screen_config *config)
140
{
141
struct pipe_screen *screen;
142
143
screen = nouveau_drm_screen_create(fd);
144
return screen ? debug_screen_wrap(screen) : NULL;
145
}
146
DRM_DRIVER_DESCRIPTOR(nouveau, NULL, 0)
147
148
#else
149
DRM_DRIVER_DESCRIPTOR_STUB(nouveau)
150
#endif
151
152
#if defined(GALLIUM_VC4) || defined(GALLIUM_V3D)
153
const driOptionDescription v3d_driconf[] = {
154
#include "v3d/driinfo_v3d.h"
155
};
156
#endif
157
158
#ifdef GALLIUM_KMSRO
159
#include "kmsro/drm/kmsro_drm_public.h"
160
161
static struct pipe_screen *
162
pipe_kmsro_create_screen(int fd, const struct pipe_screen_config *config)
163
{
164
struct pipe_screen *screen;
165
166
screen = kmsro_drm_screen_create(fd, config);
167
return screen ? debug_screen_wrap(screen) : NULL;
168
}
169
#if defined(GALLIUM_VC4) || defined(GALLIUM_V3D)
170
DRM_DRIVER_DESCRIPTOR(kmsro, v3d_driconf, ARRAY_SIZE(v3d_driconf))
171
#else
172
DRM_DRIVER_DESCRIPTOR(kmsro, NULL, 0)
173
#endif
174
175
#else
176
DRM_DRIVER_DESCRIPTOR_STUB(kmsro)
177
#endif
178
179
#ifdef GALLIUM_R300
180
#include "radeon/radeon_winsys.h"
181
#include "radeon/drm/radeon_drm_public.h"
182
#include "r300/r300_public.h"
183
184
static struct pipe_screen *
185
pipe_r300_create_screen(int fd, const struct pipe_screen_config *config)
186
{
187
struct radeon_winsys *rw;
188
189
rw = radeon_drm_winsys_create(fd, config, r300_screen_create);
190
return rw ? debug_screen_wrap(rw->screen) : NULL;
191
}
192
DRM_DRIVER_DESCRIPTOR(r300, NULL, 0)
193
194
#else
195
DRM_DRIVER_DESCRIPTOR_STUB(r300)
196
#endif
197
198
#ifdef GALLIUM_R600
199
#include "radeon/radeon_winsys.h"
200
#include "radeon/drm/radeon_drm_public.h"
201
#include "r600/r600_public.h"
202
203
static struct pipe_screen *
204
pipe_r600_create_screen(int fd, const struct pipe_screen_config *config)
205
{
206
struct radeon_winsys *rw;
207
208
rw = radeon_drm_winsys_create(fd, config, r600_screen_create);
209
return rw ? debug_screen_wrap(rw->screen) : NULL;
210
}
211
DRM_DRIVER_DESCRIPTOR(r600, NULL, 0)
212
213
#else
214
DRM_DRIVER_DESCRIPTOR_STUB(r600)
215
#endif
216
217
#ifdef GALLIUM_RADEONSI
218
#include "radeonsi/si_public.h"
219
220
static struct pipe_screen *
221
pipe_radeonsi_create_screen(int fd, const struct pipe_screen_config *config)
222
{
223
struct pipe_screen *screen = radeonsi_screen_create(fd, config);
224
225
return screen ? debug_screen_wrap(screen) : NULL;
226
}
227
228
const driOptionDescription radeonsi_driconf[] = {
229
#include "radeonsi/driinfo_radeonsi.h"
230
};
231
DRM_DRIVER_DESCRIPTOR(radeonsi, radeonsi_driconf, ARRAY_SIZE(radeonsi_driconf))
232
233
#else
234
DRM_DRIVER_DESCRIPTOR_STUB(radeonsi)
235
#endif
236
237
#ifdef GALLIUM_VMWGFX
238
#include "svga/drm/svga_drm_public.h"
239
#include "svga/svga_public.h"
240
241
static struct pipe_screen *
242
pipe_vmwgfx_create_screen(int fd, const struct pipe_screen_config *config)
243
{
244
struct svga_winsys_screen *sws;
245
struct pipe_screen *screen;
246
247
sws = svga_drm_winsys_screen_create(fd);
248
if (!sws)
249
return NULL;
250
251
screen = svga_screen_create(sws);
252
return screen ? debug_screen_wrap(screen) : NULL;
253
}
254
DRM_DRIVER_DESCRIPTOR(vmwgfx, NULL, 0)
255
256
#else
257
DRM_DRIVER_DESCRIPTOR_STUB(vmwgfx)
258
#endif
259
260
#ifdef GALLIUM_FREEDRENO
261
#include "freedreno/drm/freedreno_drm_public.h"
262
263
static struct pipe_screen *
264
pipe_msm_create_screen(int fd, const struct pipe_screen_config *config)
265
{
266
struct pipe_screen *screen;
267
268
screen = fd_drm_screen_create(fd, NULL);
269
return screen ? debug_screen_wrap(screen) : NULL;
270
}
271
DRM_DRIVER_DESCRIPTOR(msm, NULL, 0)
272
#else
273
DRM_DRIVER_DESCRIPTOR_STUB(msm)
274
#endif
275
DRM_DRIVER_DESCRIPTOR_ALIAS(msm, kgsl, NULL, 0)
276
277
#ifdef GALLIUM_VIRGL
278
#include "virgl/drm/virgl_drm_public.h"
279
#include "virgl/virgl_public.h"
280
281
static struct pipe_screen *
282
pipe_virtio_gpu_create_screen(int fd, const struct pipe_screen_config *config)
283
{
284
struct pipe_screen *screen;
285
286
screen = virgl_drm_screen_create(fd, config);
287
return screen ? debug_screen_wrap(screen) : NULL;
288
}
289
290
const driOptionDescription virgl_driconf[] = {
291
#include "virgl/virgl_driinfo.h.in"
292
};
293
DRM_DRIVER_DESCRIPTOR(virtio_gpu, virgl_driconf, ARRAY_SIZE(virgl_driconf))
294
295
#else
296
DRM_DRIVER_DESCRIPTOR_STUB(virtio_gpu)
297
#endif
298
299
#ifdef GALLIUM_VC4
300
#include "vc4/drm/vc4_drm_public.h"
301
302
static struct pipe_screen *
303
pipe_vc4_create_screen(int fd, const struct pipe_screen_config *config)
304
{
305
struct pipe_screen *screen;
306
307
screen = vc4_drm_screen_create(fd, config);
308
return screen ? debug_screen_wrap(screen) : NULL;
309
}
310
DRM_DRIVER_DESCRIPTOR(vc4, v3d_driconf, ARRAY_SIZE(v3d_driconf))
311
#else
312
DRM_DRIVER_DESCRIPTOR_STUB(vc4)
313
#endif
314
315
#ifdef GALLIUM_V3D
316
#include "v3d/drm/v3d_drm_public.h"
317
318
static struct pipe_screen *
319
pipe_v3d_create_screen(int fd, const struct pipe_screen_config *config)
320
{
321
struct pipe_screen *screen;
322
323
screen = v3d_drm_screen_create(fd, config);
324
return screen ? debug_screen_wrap(screen) : NULL;
325
}
326
327
DRM_DRIVER_DESCRIPTOR(v3d, v3d_driconf, ARRAY_SIZE(v3d_driconf))
328
329
#else
330
DRM_DRIVER_DESCRIPTOR_STUB(v3d)
331
#endif
332
333
#ifdef GALLIUM_PANFROST
334
#include "panfrost/drm/panfrost_drm_public.h"
335
336
static struct pipe_screen *
337
pipe_panfrost_create_screen(int fd, const struct pipe_screen_config *config)
338
{
339
struct pipe_screen *screen;
340
341
screen = panfrost_drm_screen_create(fd);
342
return screen ? debug_screen_wrap(screen) : NULL;
343
}
344
DRM_DRIVER_DESCRIPTOR(panfrost, NULL, 0)
345
346
#else
347
DRM_DRIVER_DESCRIPTOR_STUB(panfrost)
348
#endif
349
350
#ifdef GALLIUM_ETNAVIV
351
#include "etnaviv/drm/etnaviv_drm_public.h"
352
353
static struct pipe_screen *
354
pipe_etnaviv_create_screen(int fd, const struct pipe_screen_config *config)
355
{
356
struct pipe_screen *screen;
357
358
screen = etna_drm_screen_create(fd);
359
return screen ? debug_screen_wrap(screen) : NULL;
360
}
361
DRM_DRIVER_DESCRIPTOR(etnaviv, NULL, 0)
362
363
#else
364
DRM_DRIVER_DESCRIPTOR_STUB(etnaviv)
365
#endif
366
367
#ifdef GALLIUM_TEGRA
368
#include "tegra/drm/tegra_drm_public.h"
369
370
static struct pipe_screen *
371
pipe_tegra_create_screen(int fd, const struct pipe_screen_config *config)
372
{
373
struct pipe_screen *screen;
374
375
screen = tegra_drm_screen_create(fd);
376
377
return screen ? debug_screen_wrap(screen) : NULL;
378
}
379
DRM_DRIVER_DESCRIPTOR(tegra, NULL, 0)
380
381
#else
382
DRM_DRIVER_DESCRIPTOR_STUB(tegra)
383
#endif
384
385
#ifdef GALLIUM_LIMA
386
#include "lima/drm/lima_drm_public.h"
387
388
static struct pipe_screen *
389
pipe_lima_create_screen(int fd, const struct pipe_screen_config *config)
390
{
391
struct pipe_screen *screen;
392
393
screen = lima_drm_screen_create(fd);
394
return screen ? debug_screen_wrap(screen) : NULL;
395
}
396
DRM_DRIVER_DESCRIPTOR(lima, NULL, 0)
397
398
#else
399
DRM_DRIVER_DESCRIPTOR_STUB(lima)
400
#endif
401
402
#ifdef GALLIUM_ZINK
403
#include "zink/zink_public.h"
404
405
static struct pipe_screen *
406
pipe_zink_create_screen(int fd, const struct pipe_screen_config *config)
407
{
408
struct pipe_screen *screen;
409
screen = zink_drm_create_screen(fd, config);
410
return screen ? debug_screen_wrap(screen) : NULL;
411
}
412
413
const driOptionDescription zink_driconf[] = {
414
#include "zink/driinfo_zink.h"
415
};
416
DRM_DRIVER_DESCRIPTOR(zink, zink_driconf, ARRAY_SIZE(zink_driconf))
417
418
#else
419
DRM_DRIVER_DESCRIPTOR_STUB(zink)
420
#endif
421
422
#endif /* DRM_HELPER_H */
423
424