blob: 0d0f50726b190c9ecb414ddc41e6e77b0951250d [file] [log] [blame]
Chia-I Wuf2001df2011-07-02 17:57:30 +09001/**************************************************************************
2 *
José Fonseca87712852014-01-17 16:27:50 +00003 * Copyright 2008 VMware, Inc.
Chia-I Wuf2001df2011-07-02 17:57:30 +09004 * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
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
Brian Pauladbff7e2005-04-22 21:09:39 +000031#ifndef EGLDRIVER_INCLUDED
32#define EGLDRIVER_INCLUDED
33
34
Emil Velikov7bd16932015-02-28 16:35:22 +000035#include "c99_compat.h"
36
Brian Pauladbff7e2005-04-22 21:09:39 +000037#include "egltypedefs.h"
Eric Engestroma77050c2020-07-22 00:51:51 +020038#include <stdbool.h>
Thomas Hellstrom675aec82010-11-01 17:10:03 +010039#include <stddef.h>
Brian Paul5285c322005-11-29 04:43:37 +000040
Alexander von Gluck IV83620682015-05-13 17:13:37 -050041
42#ifdef __cplusplus
43extern "C" {
44#endif
45
Chia-I Wubdb9e202010-02-04 12:52:15 +080046/**
47 * Define an inline driver typecast function.
Chia-I Wucb260e12010-02-05 11:42:05 +080048 *
49 * Note that this macro defines a function and should not be ended with a
50 * semicolon when used.
Chia-I Wubdb9e202010-02-04 12:52:15 +080051 */
52#define _EGL_DRIVER_TYPECAST(drvtype, egltype, code) \
Emil Velikov7bd16932015-02-28 16:35:22 +000053 static inline struct drvtype *drvtype(const egltype *obj) \
Chia-I Wubdb9e202010-02-04 12:52:15 +080054 { return (struct drvtype *) code; }
55
56
57/**
58 * Define the driver typecast functions for _EGLDriver, _EGLDisplay,
59 * _EGLContext, _EGLSurface, and _EGLConfig.
Chia-I Wucb260e12010-02-05 11:42:05 +080060 *
61 * Note that this macro defines several functions and should not be ended with
62 * a semicolon when used.
Chia-I Wubdb9e202010-02-04 12:52:15 +080063 */
64#define _EGL_DRIVER_STANDARD_TYPECASTS(drvname) \
65 _EGL_DRIVER_TYPECAST(drvname ## _driver, _EGLDriver, obj) \
66 /* note that this is not a direct cast */ \
67 _EGL_DRIVER_TYPECAST(drvname ## _display, _EGLDisplay, obj->DriverData) \
68 _EGL_DRIVER_TYPECAST(drvname ## _context, _EGLContext, obj) \
69 _EGL_DRIVER_TYPECAST(drvname ## _surface, _EGLSurface, obj) \
70 _EGL_DRIVER_TYPECAST(drvname ## _config, _EGLConfig, obj)
71
Eric Engestromcc034482020-07-20 13:38:24 +020072/**
73 * A generic function ptr type
74 */
75typedef void (*_EGLProc)(void);
76
77struct wl_display;
78struct mesa_glinterop_device_info;
79struct mesa_glinterop_export_in;
80struct mesa_glinterop_export_out;
Chia-I Wubdb9e202010-02-04 12:52:15 +080081
Brian Paul5285c322005-11-29 04:43:37 +000082/**
Eric Engestromcc034482020-07-20 13:38:24 +020083 * The API dispatcher jumps through these functions
Brian Pauladbff7e2005-04-22 21:09:39 +000084 */
85struct _egl_driver
86{
Eric Engestromcc034482020-07-20 13:38:24 +020087 /* driver funcs */
88 EGLBoolean (*Initialize)(_EGLDriver *, _EGLDisplay *disp);
89 EGLBoolean (*Terminate)(_EGLDriver *, _EGLDisplay *disp);
90 const char *(*QueryDriverName)(_EGLDisplay *disp);
91 char *(*QueryDriverConfig)(_EGLDisplay *disp);
92
93 /* context funcs */
94 _EGLContext *(*CreateContext)(_EGLDriver *drv, _EGLDisplay *disp,
95 _EGLConfig *config, _EGLContext *share_list,
96 const EGLint *attrib_list);
97 EGLBoolean (*DestroyContext)(_EGLDriver *drv, _EGLDisplay *disp,
98 _EGLContext *ctx);
99 /* this is the only function (other than Initialize) that may be called
100 * with an uninitialized display
101 */
102 EGLBoolean (*MakeCurrent)(_EGLDriver *drv, _EGLDisplay *disp,
103 _EGLSurface *draw, _EGLSurface *read,
104 _EGLContext *ctx);
105
106 /* surface funcs */
107 _EGLSurface *(*CreateWindowSurface)(_EGLDriver *drv, _EGLDisplay *disp,
108 _EGLConfig *config, void *native_window,
109 const EGLint *attrib_list);
110 _EGLSurface *(*CreatePixmapSurface)(_EGLDriver *drv, _EGLDisplay *disp,
111 _EGLConfig *config, void *native_pixmap,
112 const EGLint *attrib_list);
113 _EGLSurface *(*CreatePbufferSurface)(_EGLDriver *drv, _EGLDisplay *disp,
114 _EGLConfig *config,
115 const EGLint *attrib_list);
116 EGLBoolean (*DestroySurface)(_EGLDriver *drv, _EGLDisplay *disp,
117 _EGLSurface *surface);
118 EGLBoolean (*QuerySurface)(_EGLDriver *drv, _EGLDisplay *disp,
119 _EGLSurface *surface, EGLint attribute,
120 EGLint *value);
121 EGLBoolean (*BindTexImage)(_EGLDriver *drv, _EGLDisplay *disp,
122 _EGLSurface *surface, EGLint buffer);
123 EGLBoolean (*ReleaseTexImage)(_EGLDriver *drv, _EGLDisplay *disp,
124 _EGLSurface *surface, EGLint buffer);
125 EGLBoolean (*SwapInterval)(_EGLDriver *drv, _EGLDisplay *disp,
126 _EGLSurface *surf, EGLint interval);
127 EGLBoolean (*SwapBuffers)(_EGLDriver *drv, _EGLDisplay *disp,
128 _EGLSurface *draw);
129 EGLBoolean (*CopyBuffers)(_EGLDriver *drv, _EGLDisplay *disp,
130 _EGLSurface *surface, void *native_pixmap_target);
131 EGLBoolean (*SetDamageRegion)(_EGLDriver *drv, _EGLDisplay *disp,
132 _EGLSurface *surface, EGLint *rects, EGLint n_rects);
133
134 /* misc functions */
135 EGLBoolean (*WaitClient)(_EGLDriver *drv, _EGLDisplay *disp,
136 _EGLContext *ctx);
137 EGLBoolean (*WaitNative)(_EGLDriver *drv, _EGLDisplay *disp,
138 EGLint engine);
139
140 /* this function may be called from multiple threads at the same time */
141 _EGLProc (*GetProcAddress)(_EGLDriver *drv, const char *procname);
142
143 _EGLImage *(*CreateImageKHR)(_EGLDriver *drv, _EGLDisplay *disp,
144 _EGLContext *ctx, EGLenum target,
145 EGLClientBuffer buffer,
146 const EGLint *attr_list);
147 EGLBoolean (*DestroyImageKHR)(_EGLDriver *drv, _EGLDisplay *disp,
148 _EGLImage *image);
149
150 _EGLSync *(*CreateSyncKHR)(_EGLDriver *drv, _EGLDisplay *disp, EGLenum type,
151 const EGLAttrib *attrib_list);
152 EGLBoolean (*DestroySyncKHR)(_EGLDriver *drv, _EGLDisplay *disp,
153 _EGLSync *sync);
154 EGLint (*ClientWaitSyncKHR)(_EGLDriver *drv, _EGLDisplay *disp,
155 _EGLSync *sync, EGLint flags, EGLTime timeout);
156 EGLint (*WaitSyncKHR)(_EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync);
157 EGLBoolean (*SignalSyncKHR)(_EGLDriver *drv, _EGLDisplay *disp,
158 _EGLSync *sync, EGLenum mode);
159 EGLint (*DupNativeFenceFDANDROID)(_EGLDriver *drv, _EGLDisplay *disp,
160 _EGLSync *sync);
161
162 EGLBoolean (*SwapBuffersRegionNOK)(_EGLDriver *drv, _EGLDisplay *disp,
163 _EGLSurface *surf, EGLint numRects,
164 const EGLint *rects);
165
166 _EGLImage *(*CreateDRMImageMESA)(_EGLDriver *drv, _EGLDisplay *disp,
167 const EGLint *attr_list);
168 EGLBoolean (*ExportDRMImageMESA)(_EGLDriver *drv, _EGLDisplay *disp,
169 _EGLImage *img, EGLint *name,
170 EGLint *handle, EGLint *stride);
171
172 EGLBoolean (*BindWaylandDisplayWL)(_EGLDriver *drv, _EGLDisplay *disp,
173 struct wl_display *display);
174 EGLBoolean (*UnbindWaylandDisplayWL)(_EGLDriver *drv, _EGLDisplay *disp,
175 struct wl_display *display);
176 EGLBoolean (*QueryWaylandBufferWL)(_EGLDriver *drv, _EGLDisplay *displ,
177 struct wl_resource *buffer,
178 EGLint attribute, EGLint *value);
179
180 struct wl_buffer *(*CreateWaylandBufferFromImageWL)(_EGLDriver *drv,
181 _EGLDisplay *disp,
182 _EGLImage *img);
183
184 EGLBoolean (*SwapBuffersWithDamageEXT)(_EGLDriver *drv, _EGLDisplay *disp,
185 _EGLSurface *surface,
186 const EGLint *rects, EGLint n_rects);
187
188 EGLBoolean (*PostSubBufferNV)(_EGLDriver *drv, _EGLDisplay *disp,
189 _EGLSurface *surface, EGLint x, EGLint y,
190 EGLint width, EGLint height);
191
192 EGLint (*QueryBufferAge)(_EGLDriver *drv,
193 _EGLDisplay *disp, _EGLSurface *surface);
194 EGLBoolean (*GetSyncValuesCHROMIUM)(_EGLDisplay *disp, _EGLSurface *surface,
195 EGLuint64KHR *ust, EGLuint64KHR *msc,
196 EGLuint64KHR *sbc);
197
198 EGLBoolean (*ExportDMABUFImageQueryMESA)(_EGLDriver *drv, _EGLDisplay *disp,
199 _EGLImage *img, EGLint *fourcc,
200 EGLint *nplanes,
201 EGLuint64KHR *modifiers);
202 EGLBoolean (*ExportDMABUFImageMESA)(_EGLDriver *drv, _EGLDisplay *disp,
203 _EGLImage *img, EGLint *fds,
204 EGLint *strides, EGLint *offsets);
205
206 int (*GLInteropQueryDeviceInfo)(_EGLDisplay *disp, _EGLContext *ctx,
207 struct mesa_glinterop_device_info *out);
208 int (*GLInteropExportObject)(_EGLDisplay *disp, _EGLContext *ctx,
209 struct mesa_glinterop_export_in *in,
210 struct mesa_glinterop_export_out *out);
211
212 EGLBoolean (*QueryDmaBufFormatsEXT)(_EGLDriver *drv, _EGLDisplay *disp,
213 EGLint max_formats, EGLint *formats,
214 EGLint *num_formats);
215 EGLBoolean (*QueryDmaBufModifiersEXT) (_EGLDriver *drv, _EGLDisplay *disp,
216 EGLint format, EGLint max_modifiers,
217 EGLuint64KHR *modifiers,
218 EGLBoolean *external_only,
219 EGLint *num_modifiers);
220
221 void (*SetBlobCacheFuncsANDROID) (_EGLDriver *drv, _EGLDisplay *disp,
222 EGLSetBlobFuncANDROID set,
223 EGLGetBlobFuncANDROID get);
Brian Pauladbff7e2005-04-22 21:09:39 +0000224};
225
226
Eric Engestroma77050c2020-07-22 00:51:51 +0200227extern bool
Eric Engestrom54fa5ec2019-02-02 11:38:45 +0000228_eglMatchDriver(_EGLDisplay *disp);
Brian Pauladbff7e2005-04-22 21:09:39 +0000229
230
Chia-I Wuf2aa3612010-07-04 15:55:12 +0800231extern __eglMustCastToProperFunctionPointerType
232_eglGetDriverProc(const char *procname);
Chia-I Wub3bcd332010-01-19 18:13:50 +0800233
234
235extern void
Chia-I Wue8ba2812010-05-05 17:37:19 +0800236_eglSearchPathForEach(EGLBoolean (*callback)(const char *, size_t, void *),
237 void *callback_data);
238
239
Alexander von Gluck IV83620682015-05-13 17:13:37 -0500240#ifdef __cplusplus
241}
242#endif
243
244
Brian Pauladbff7e2005-04-22 21:09:39 +0000245#endif /* EGLDRIVER_INCLUDED */