Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/egl/main/egldisplay.h
4560 views
1
/**************************************************************************
2
*
3
* Copyright 2008 VMware, Inc.
4
* Copyright 2009-2010 Chia-I Wu <[email protected]>
5
* Copyright 2010-2011 LunarG, Inc.
6
* All Rights Reserved.
7
*
8
* Permission is hereby granted, free of charge, to any person obtaining a
9
* copy of this software and associated documentation files (the
10
* "Software"), to deal in the Software without restriction, including
11
* without limitation the rights to use, copy, modify, merge, publish,
12
* distribute, sub license, and/or sell copies of the Software, and to
13
* permit persons to whom the Software is furnished to do so, subject to
14
* the following conditions:
15
*
16
* The above copyright notice and this permission notice (including the
17
* next paragraph) shall be included in all copies or substantial portions
18
* of the Software.
19
*
20
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26
* DEALINGS IN THE SOFTWARE.
27
*
28
**************************************************************************/
29
30
31
#ifndef EGLDISPLAY_INCLUDED
32
#define EGLDISPLAY_INCLUDED
33
34
#include "c99_compat.h"
35
#include "c11/threads.h"
36
37
#include "egltypedefs.h"
38
#include "egldefines.h"
39
#include "eglarray.h"
40
41
42
#ifdef __cplusplus
43
extern "C" {
44
#endif
45
46
enum _egl_platform_type {
47
_EGL_PLATFORM_X11,
48
_EGL_PLATFORM_XCB,
49
_EGL_PLATFORM_WAYLAND,
50
_EGL_PLATFORM_DRM,
51
_EGL_PLATFORM_ANDROID,
52
_EGL_PLATFORM_HAIKU,
53
_EGL_PLATFORM_SURFACELESS,
54
_EGL_PLATFORM_DEVICE,
55
56
_EGL_NUM_PLATFORMS,
57
_EGL_INVALID_PLATFORM = -1
58
};
59
typedef enum _egl_platform_type _EGLPlatformType;
60
61
62
enum _egl_resource_type {
63
_EGL_RESOURCE_CONTEXT,
64
_EGL_RESOURCE_SURFACE,
65
_EGL_RESOURCE_IMAGE,
66
_EGL_RESOURCE_SYNC,
67
68
_EGL_NUM_RESOURCES
69
};
70
/* this cannot and need not go into egltypedefs.h */
71
typedef enum _egl_resource_type _EGLResourceType;
72
73
74
/**
75
* A resource of a display.
76
*/
77
struct _egl_resource
78
{
79
/* which display the resource belongs to */
80
_EGLDisplay *Display;
81
EGLBoolean IsLinked;
82
EGLint RefCount;
83
84
EGLLabelKHR Label;
85
86
/* used to link resources of the same type */
87
_EGLResource *Next;
88
};
89
90
91
/**
92
* Optional EGL extensions info.
93
*/
94
struct _egl_extensions
95
{
96
/* Please keep these sorted alphabetically. */
97
EGLBoolean ANDROID_blob_cache;
98
EGLBoolean ANDROID_framebuffer_target;
99
EGLBoolean ANDROID_image_native_buffer;
100
EGLBoolean ANDROID_native_fence_sync;
101
EGLBoolean ANDROID_recordable;
102
103
EGLBoolean CHROMIUM_sync_control;
104
105
EGLBoolean EXT_buffer_age;
106
EGLBoolean EXT_create_context_robustness;
107
EGLBoolean EXT_image_dma_buf_import;
108
EGLBoolean EXT_image_dma_buf_import_modifiers;
109
EGLBoolean EXT_pixel_format_float;
110
EGLBoolean EXT_protected_surface;
111
EGLBoolean EXT_surface_CTA861_3_metadata;
112
EGLBoolean EXT_surface_SMPTE2086_metadata;
113
EGLBoolean EXT_swap_buffers_with_damage;
114
115
unsigned int IMG_context_priority;
116
#define __EGL_CONTEXT_PRIORITY_LOW_BIT 0
117
#define __EGL_CONTEXT_PRIORITY_MEDIUM_BIT 1
118
#define __EGL_CONTEXT_PRIORITY_HIGH_BIT 2
119
120
EGLBoolean KHR_cl_event2;
121
EGLBoolean KHR_config_attribs;
122
EGLBoolean KHR_context_flush_control;
123
EGLBoolean KHR_create_context;
124
EGLBoolean KHR_create_context_no_error;
125
EGLBoolean KHR_fence_sync;
126
EGLBoolean KHR_get_all_proc_addresses;
127
EGLBoolean KHR_gl_colorspace;
128
EGLBoolean KHR_gl_renderbuffer_image;
129
EGLBoolean KHR_gl_texture_2D_image;
130
EGLBoolean KHR_gl_texture_3D_image;
131
EGLBoolean KHR_gl_texture_cubemap_image;
132
EGLBoolean KHR_image;
133
EGLBoolean KHR_image_base;
134
EGLBoolean KHR_image_pixmap;
135
EGLBoolean KHR_mutable_render_buffer;
136
EGLBoolean KHR_no_config_context;
137
EGLBoolean KHR_partial_update;
138
EGLBoolean KHR_reusable_sync;
139
EGLBoolean KHR_surfaceless_context;
140
EGLBoolean KHR_wait_sync;
141
142
EGLBoolean MESA_drm_image;
143
EGLBoolean MESA_image_dma_buf_export;
144
EGLBoolean MESA_query_driver;
145
146
EGLBoolean NOK_swap_region;
147
EGLBoolean NOK_texture_from_pixmap;
148
149
EGLBoolean NV_post_sub_buffer;
150
151
EGLBoolean WL_bind_wayland_display;
152
EGLBoolean WL_create_wayland_buffer_from_image;
153
};
154
155
struct _egl_display
156
{
157
/* used to link displays */
158
_EGLDisplay *Next;
159
160
mtx_t Mutex;
161
162
_EGLPlatformType Platform; /**< The type of the platform display */
163
void *PlatformDisplay; /**< A pointer to the platform display */
164
165
_EGLDevice *Device; /**< Device backing the display */
166
const _EGLDriver *Driver; /**< Matched driver of the display */
167
EGLBoolean Initialized; /**< True if the display is initialized */
168
169
/* options that affect how the driver initializes the display */
170
struct {
171
EGLBoolean ForceSoftware; /**< Use software path only */
172
EGLAttrib *Attribs; /**< Platform-specific options */
173
int fd; /**< plaform device specific, local fd */
174
} Options;
175
176
/* these fields are set by the driver during init */
177
void *DriverData; /**< Driver private data */
178
EGLint Version; /**< EGL version major*10+minor */
179
EGLint ClientAPIs; /**< Bitmask of APIs supported (EGL_xxx_BIT) */
180
_EGLExtensions Extensions; /**< Extensions supported */
181
182
/* these fields are derived from above */
183
char VersionString[100]; /**< EGL_VERSION */
184
char ClientAPIsString[100]; /**< EGL_CLIENT_APIS */
185
char ExtensionsString[_EGL_MAX_EXTENSIONS_LEN]; /**< EGL_EXTENSIONS */
186
187
_EGLArray *Configs;
188
189
/* lists of resources */
190
_EGLResource *ResourceLists[_EGL_NUM_RESOURCES];
191
192
EGLLabelKHR Label;
193
194
EGLSetBlobFuncANDROID BlobCacheSet;
195
EGLGetBlobFuncANDROID BlobCacheGet;
196
};
197
198
199
extern _EGLPlatformType
200
_eglGetNativePlatform(void *nativeDisplay);
201
202
203
extern void
204
_eglFiniDisplay(void);
205
206
207
extern _EGLDisplay *
208
_eglFindDisplay(_EGLPlatformType plat, void *plat_dpy, const EGLAttrib *attr);
209
210
211
extern void
212
_eglReleaseDisplayResources(_EGLDisplay *disp);
213
214
215
extern void
216
_eglCleanupDisplay(_EGLDisplay *disp);
217
218
219
extern EGLBoolean
220
_eglCheckDisplayHandle(EGLDisplay dpy);
221
222
223
extern EGLBoolean
224
_eglCheckResource(void *res, _EGLResourceType type, _EGLDisplay *disp);
225
226
227
/**
228
* Lookup a handle to find the linked display.
229
* Return NULL if the handle has no corresponding linked display.
230
*/
231
static inline _EGLDisplay *
232
_eglLookupDisplay(EGLDisplay dpy)
233
{
234
_EGLDisplay *disp = (_EGLDisplay *) dpy;
235
if (!_eglCheckDisplayHandle(dpy))
236
disp = NULL;
237
return disp;
238
}
239
240
241
/**
242
* Return the handle of a linked display, or EGL_NO_DISPLAY.
243
*/
244
static inline EGLDisplay
245
_eglGetDisplayHandle(_EGLDisplay *disp)
246
{
247
return (EGLDisplay) ((disp) ? disp : EGL_NO_DISPLAY);
248
}
249
250
251
extern void
252
_eglInitResource(_EGLResource *res, EGLint size, _EGLDisplay *disp);
253
254
255
extern void
256
_eglGetResource(_EGLResource *res);
257
258
259
extern EGLBoolean
260
_eglPutResource(_EGLResource *res);
261
262
263
extern void
264
_eglLinkResource(_EGLResource *res, _EGLResourceType type);
265
266
267
extern void
268
_eglUnlinkResource(_EGLResource *res, _EGLResourceType type);
269
270
271
/**
272
* Return true if the resource is linked.
273
*/
274
static inline EGLBoolean
275
_eglIsResourceLinked(_EGLResource *res)
276
{
277
return res->IsLinked;
278
}
279
280
static inline size_t
281
_eglNumAttribs(const EGLAttrib *attribs)
282
{
283
size_t len = 0;
284
285
if (attribs) {
286
while (attribs[len] != EGL_NONE)
287
len += 2;
288
len++;
289
}
290
return len;
291
}
292
293
#ifdef HAVE_X11_PLATFORM
294
_EGLDisplay*
295
_eglGetX11Display(Display *native_display, const EGLAttrib *attrib_list);
296
#endif
297
298
#ifdef HAVE_XCB_PLATFORM
299
typedef struct xcb_connection_t xcb_connection_t;
300
_EGLDisplay*
301
_eglGetXcbDisplay(xcb_connection_t *native_display, const EGLAttrib *attrib_list);
302
#endif
303
304
#ifdef HAVE_DRM_PLATFORM
305
struct gbm_device;
306
307
_EGLDisplay*
308
_eglGetGbmDisplay(struct gbm_device *native_display,
309
const EGLAttrib *attrib_list);
310
#endif
311
312
#ifdef HAVE_WAYLAND_PLATFORM
313
struct wl_display;
314
315
_EGLDisplay*
316
_eglGetWaylandDisplay(struct wl_display *native_display,
317
const EGLAttrib *attrib_list);
318
#endif
319
320
_EGLDisplay*
321
_eglGetSurfacelessDisplay(void *native_display,
322
const EGLAttrib *attrib_list);
323
324
#ifdef HAVE_ANDROID_PLATFORM
325
_EGLDisplay*
326
_eglGetAndroidDisplay(void *native_display,
327
const EGLAttrib *attrib_list);
328
#endif
329
330
_EGLDisplay*
331
_eglGetDeviceDisplay(void *native_display,
332
const EGLAttrib *attrib_list);
333
334
#ifdef __cplusplus
335
}
336
#endif
337
338
#endif /* EGLDISPLAY_INCLUDED */
339
340