Chia-I Wu | f2001df | 2011-07-02 17:57:30 +0900 | [diff] [blame] | 1 | /************************************************************************** |
| 2 | * |
José Fonseca | 8771285 | 2014-01-17 16:27:50 +0000 | [diff] [blame] | 3 | * Copyright 2008 VMware, Inc. |
Chia-I Wu | f2001df | 2011-07-02 17:57:30 +0900 | [diff] [blame] | 4 | * 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 Paul | adbff7e | 2005-04-22 21:09:39 +0000 | [diff] [blame] | 31 | #ifndef EGLDRIVER_INCLUDED |
| 32 | #define EGLDRIVER_INCLUDED |
| 33 | |
| 34 | |
Emil Velikov | 7bd1693 | 2015-02-28 16:35:22 +0000 | [diff] [blame] | 35 | #include "c99_compat.h" |
| 36 | |
Brian Paul | adbff7e | 2005-04-22 21:09:39 +0000 | [diff] [blame] | 37 | #include "egltypedefs.h" |
Thomas Hellstrom | 675aec8 | 2010-11-01 17:10:03 +0100 | [diff] [blame] | 38 | #include <stddef.h> |
Brian Paul | 5285c32 | 2005-11-29 04:43:37 +0000 | [diff] [blame] | 39 | |
Alexander von Gluck IV | 8362068 | 2015-05-13 17:13:37 -0500 | [diff] [blame] | 40 | |
| 41 | #ifdef __cplusplus |
| 42 | extern "C" { |
| 43 | #endif |
| 44 | |
Chia-I Wu | bdb9e20 | 2010-02-04 12:52:15 +0800 | [diff] [blame] | 45 | /** |
| 46 | * Define an inline driver typecast function. |
Chia-I Wu | cb260e1 | 2010-02-05 11:42:05 +0800 | [diff] [blame] | 47 | * |
| 48 | * Note that this macro defines a function and should not be ended with a |
| 49 | * semicolon when used. |
Chia-I Wu | bdb9e20 | 2010-02-04 12:52:15 +0800 | [diff] [blame] | 50 | */ |
| 51 | #define _EGL_DRIVER_TYPECAST(drvtype, egltype, code) \ |
Emil Velikov | 7bd1693 | 2015-02-28 16:35:22 +0000 | [diff] [blame] | 52 | static inline struct drvtype *drvtype(const egltype *obj) \ |
Chia-I Wu | bdb9e20 | 2010-02-04 12:52:15 +0800 | [diff] [blame] | 53 | { return (struct drvtype *) code; } |
| 54 | |
| 55 | |
| 56 | /** |
| 57 | * Define the driver typecast functions for _EGLDriver, _EGLDisplay, |
| 58 | * _EGLContext, _EGLSurface, and _EGLConfig. |
Chia-I Wu | cb260e1 | 2010-02-05 11:42:05 +0800 | [diff] [blame] | 59 | * |
| 60 | * Note that this macro defines several functions and should not be ended with |
| 61 | * a semicolon when used. |
Chia-I Wu | bdb9e20 | 2010-02-04 12:52:15 +0800 | [diff] [blame] | 62 | */ |
| 63 | #define _EGL_DRIVER_STANDARD_TYPECASTS(drvname) \ |
| 64 | _EGL_DRIVER_TYPECAST(drvname ## _driver, _EGLDriver, obj) \ |
| 65 | /* note that this is not a direct cast */ \ |
| 66 | _EGL_DRIVER_TYPECAST(drvname ## _display, _EGLDisplay, obj->DriverData) \ |
| 67 | _EGL_DRIVER_TYPECAST(drvname ## _context, _EGLContext, obj) \ |
| 68 | _EGL_DRIVER_TYPECAST(drvname ## _surface, _EGLSurface, obj) \ |
| 69 | _EGL_DRIVER_TYPECAST(drvname ## _config, _EGLConfig, obj) |
| 70 | |
Eric Engestrom | cc03448 | 2020-07-20 13:38:24 +0200 | [diff] [blame^] | 71 | /** |
| 72 | * A generic function ptr type |
| 73 | */ |
| 74 | typedef void (*_EGLProc)(void); |
| 75 | |
| 76 | struct wl_display; |
| 77 | struct mesa_glinterop_device_info; |
| 78 | struct mesa_glinterop_export_in; |
| 79 | struct mesa_glinterop_export_out; |
Chia-I Wu | bdb9e20 | 2010-02-04 12:52:15 +0800 | [diff] [blame] | 80 | |
Brian Paul | 5285c32 | 2005-11-29 04:43:37 +0000 | [diff] [blame] | 81 | /** |
Eric Engestrom | cc03448 | 2020-07-20 13:38:24 +0200 | [diff] [blame^] | 82 | * The API dispatcher jumps through these functions |
Brian Paul | adbff7e | 2005-04-22 21:09:39 +0000 | [diff] [blame] | 83 | */ |
| 84 | struct _egl_driver |
| 85 | { |
Eric Engestrom | cc03448 | 2020-07-20 13:38:24 +0200 | [diff] [blame^] | 86 | /* driver funcs */ |
| 87 | EGLBoolean (*Initialize)(_EGLDriver *, _EGLDisplay *disp); |
| 88 | EGLBoolean (*Terminate)(_EGLDriver *, _EGLDisplay *disp); |
| 89 | const char *(*QueryDriverName)(_EGLDisplay *disp); |
| 90 | char *(*QueryDriverConfig)(_EGLDisplay *disp); |
| 91 | |
| 92 | /* context funcs */ |
| 93 | _EGLContext *(*CreateContext)(_EGLDriver *drv, _EGLDisplay *disp, |
| 94 | _EGLConfig *config, _EGLContext *share_list, |
| 95 | const EGLint *attrib_list); |
| 96 | EGLBoolean (*DestroyContext)(_EGLDriver *drv, _EGLDisplay *disp, |
| 97 | _EGLContext *ctx); |
| 98 | /* this is the only function (other than Initialize) that may be called |
| 99 | * with an uninitialized display |
| 100 | */ |
| 101 | EGLBoolean (*MakeCurrent)(_EGLDriver *drv, _EGLDisplay *disp, |
| 102 | _EGLSurface *draw, _EGLSurface *read, |
| 103 | _EGLContext *ctx); |
| 104 | |
| 105 | /* surface funcs */ |
| 106 | _EGLSurface *(*CreateWindowSurface)(_EGLDriver *drv, _EGLDisplay *disp, |
| 107 | _EGLConfig *config, void *native_window, |
| 108 | const EGLint *attrib_list); |
| 109 | _EGLSurface *(*CreatePixmapSurface)(_EGLDriver *drv, _EGLDisplay *disp, |
| 110 | _EGLConfig *config, void *native_pixmap, |
| 111 | const EGLint *attrib_list); |
| 112 | _EGLSurface *(*CreatePbufferSurface)(_EGLDriver *drv, _EGLDisplay *disp, |
| 113 | _EGLConfig *config, |
| 114 | const EGLint *attrib_list); |
| 115 | EGLBoolean (*DestroySurface)(_EGLDriver *drv, _EGLDisplay *disp, |
| 116 | _EGLSurface *surface); |
| 117 | EGLBoolean (*QuerySurface)(_EGLDriver *drv, _EGLDisplay *disp, |
| 118 | _EGLSurface *surface, EGLint attribute, |
| 119 | EGLint *value); |
| 120 | EGLBoolean (*BindTexImage)(_EGLDriver *drv, _EGLDisplay *disp, |
| 121 | _EGLSurface *surface, EGLint buffer); |
| 122 | EGLBoolean (*ReleaseTexImage)(_EGLDriver *drv, _EGLDisplay *disp, |
| 123 | _EGLSurface *surface, EGLint buffer); |
| 124 | EGLBoolean (*SwapInterval)(_EGLDriver *drv, _EGLDisplay *disp, |
| 125 | _EGLSurface *surf, EGLint interval); |
| 126 | EGLBoolean (*SwapBuffers)(_EGLDriver *drv, _EGLDisplay *disp, |
| 127 | _EGLSurface *draw); |
| 128 | EGLBoolean (*CopyBuffers)(_EGLDriver *drv, _EGLDisplay *disp, |
| 129 | _EGLSurface *surface, void *native_pixmap_target); |
| 130 | EGLBoolean (*SetDamageRegion)(_EGLDriver *drv, _EGLDisplay *disp, |
| 131 | _EGLSurface *surface, EGLint *rects, EGLint n_rects); |
| 132 | |
| 133 | /* misc functions */ |
| 134 | EGLBoolean (*WaitClient)(_EGLDriver *drv, _EGLDisplay *disp, |
| 135 | _EGLContext *ctx); |
| 136 | EGLBoolean (*WaitNative)(_EGLDriver *drv, _EGLDisplay *disp, |
| 137 | EGLint engine); |
| 138 | |
| 139 | /* this function may be called from multiple threads at the same time */ |
| 140 | _EGLProc (*GetProcAddress)(_EGLDriver *drv, const char *procname); |
| 141 | |
| 142 | _EGLImage *(*CreateImageKHR)(_EGLDriver *drv, _EGLDisplay *disp, |
| 143 | _EGLContext *ctx, EGLenum target, |
| 144 | EGLClientBuffer buffer, |
| 145 | const EGLint *attr_list); |
| 146 | EGLBoolean (*DestroyImageKHR)(_EGLDriver *drv, _EGLDisplay *disp, |
| 147 | _EGLImage *image); |
| 148 | |
| 149 | _EGLSync *(*CreateSyncKHR)(_EGLDriver *drv, _EGLDisplay *disp, EGLenum type, |
| 150 | const EGLAttrib *attrib_list); |
| 151 | EGLBoolean (*DestroySyncKHR)(_EGLDriver *drv, _EGLDisplay *disp, |
| 152 | _EGLSync *sync); |
| 153 | EGLint (*ClientWaitSyncKHR)(_EGLDriver *drv, _EGLDisplay *disp, |
| 154 | _EGLSync *sync, EGLint flags, EGLTime timeout); |
| 155 | EGLint (*WaitSyncKHR)(_EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync); |
| 156 | EGLBoolean (*SignalSyncKHR)(_EGLDriver *drv, _EGLDisplay *disp, |
| 157 | _EGLSync *sync, EGLenum mode); |
| 158 | EGLint (*DupNativeFenceFDANDROID)(_EGLDriver *drv, _EGLDisplay *disp, |
| 159 | _EGLSync *sync); |
| 160 | |
| 161 | EGLBoolean (*SwapBuffersRegionNOK)(_EGLDriver *drv, _EGLDisplay *disp, |
| 162 | _EGLSurface *surf, EGLint numRects, |
| 163 | const EGLint *rects); |
| 164 | |
| 165 | _EGLImage *(*CreateDRMImageMESA)(_EGLDriver *drv, _EGLDisplay *disp, |
| 166 | const EGLint *attr_list); |
| 167 | EGLBoolean (*ExportDRMImageMESA)(_EGLDriver *drv, _EGLDisplay *disp, |
| 168 | _EGLImage *img, EGLint *name, |
| 169 | EGLint *handle, EGLint *stride); |
| 170 | |
| 171 | EGLBoolean (*BindWaylandDisplayWL)(_EGLDriver *drv, _EGLDisplay *disp, |
| 172 | struct wl_display *display); |
| 173 | EGLBoolean (*UnbindWaylandDisplayWL)(_EGLDriver *drv, _EGLDisplay *disp, |
| 174 | struct wl_display *display); |
| 175 | EGLBoolean (*QueryWaylandBufferWL)(_EGLDriver *drv, _EGLDisplay *displ, |
| 176 | struct wl_resource *buffer, |
| 177 | EGLint attribute, EGLint *value); |
| 178 | |
| 179 | struct wl_buffer *(*CreateWaylandBufferFromImageWL)(_EGLDriver *drv, |
| 180 | _EGLDisplay *disp, |
| 181 | _EGLImage *img); |
| 182 | |
| 183 | EGLBoolean (*SwapBuffersWithDamageEXT)(_EGLDriver *drv, _EGLDisplay *disp, |
| 184 | _EGLSurface *surface, |
| 185 | const EGLint *rects, EGLint n_rects); |
| 186 | |
| 187 | EGLBoolean (*PostSubBufferNV)(_EGLDriver *drv, _EGLDisplay *disp, |
| 188 | _EGLSurface *surface, EGLint x, EGLint y, |
| 189 | EGLint width, EGLint height); |
| 190 | |
| 191 | EGLint (*QueryBufferAge)(_EGLDriver *drv, |
| 192 | _EGLDisplay *disp, _EGLSurface *surface); |
| 193 | EGLBoolean (*GetSyncValuesCHROMIUM)(_EGLDisplay *disp, _EGLSurface *surface, |
| 194 | EGLuint64KHR *ust, EGLuint64KHR *msc, |
| 195 | EGLuint64KHR *sbc); |
| 196 | |
| 197 | EGLBoolean (*ExportDMABUFImageQueryMESA)(_EGLDriver *drv, _EGLDisplay *disp, |
| 198 | _EGLImage *img, EGLint *fourcc, |
| 199 | EGLint *nplanes, |
| 200 | EGLuint64KHR *modifiers); |
| 201 | EGLBoolean (*ExportDMABUFImageMESA)(_EGLDriver *drv, _EGLDisplay *disp, |
| 202 | _EGLImage *img, EGLint *fds, |
| 203 | EGLint *strides, EGLint *offsets); |
| 204 | |
| 205 | int (*GLInteropQueryDeviceInfo)(_EGLDisplay *disp, _EGLContext *ctx, |
| 206 | struct mesa_glinterop_device_info *out); |
| 207 | int (*GLInteropExportObject)(_EGLDisplay *disp, _EGLContext *ctx, |
| 208 | struct mesa_glinterop_export_in *in, |
| 209 | struct mesa_glinterop_export_out *out); |
| 210 | |
| 211 | EGLBoolean (*QueryDmaBufFormatsEXT)(_EGLDriver *drv, _EGLDisplay *disp, |
| 212 | EGLint max_formats, EGLint *formats, |
| 213 | EGLint *num_formats); |
| 214 | EGLBoolean (*QueryDmaBufModifiersEXT) (_EGLDriver *drv, _EGLDisplay *disp, |
| 215 | EGLint format, EGLint max_modifiers, |
| 216 | EGLuint64KHR *modifiers, |
| 217 | EGLBoolean *external_only, |
| 218 | EGLint *num_modifiers); |
| 219 | |
| 220 | void (*SetBlobCacheFuncsANDROID) (_EGLDriver *drv, _EGLDisplay *disp, |
| 221 | EGLSetBlobFuncANDROID set, |
| 222 | EGLGetBlobFuncANDROID get); |
Brian Paul | adbff7e | 2005-04-22 21:09:39 +0000 | [diff] [blame] | 223 | }; |
| 224 | |
| 225 | |
Eric Engestrom | cb0980e | 2017-09-25 22:35:24 +0100 | [diff] [blame] | 226 | extern void |
| 227 | _eglInitDriver(_EGLDriver *driver); |
Brian Paul | adbff7e | 2005-04-22 21:09:39 +0000 | [diff] [blame] | 228 | |
| 229 | |
Brian Paul | adbff7e | 2005-04-22 21:09:39 +0000 | [diff] [blame] | 230 | extern _EGLDriver * |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 231 | _eglMatchDriver(_EGLDisplay *disp); |
Brian Paul | adbff7e | 2005-04-22 21:09:39 +0000 | [diff] [blame] | 232 | |
| 233 | |
Chia-I Wu | f2aa361 | 2010-07-04 15:55:12 +0800 | [diff] [blame] | 234 | extern __eglMustCastToProperFunctionPointerType |
| 235 | _eglGetDriverProc(const char *procname); |
Chia-I Wu | b3bcd33 | 2010-01-19 18:13:50 +0800 | [diff] [blame] | 236 | |
| 237 | |
| 238 | extern void |
Chia-I Wu | 0eaa02c | 2009-08-13 13:01:48 +0800 | [diff] [blame] | 239 | _eglUnloadDrivers(void); |
Brian Paul | e3805ca | 2008-05-30 14:50:33 -0600 | [diff] [blame] | 240 | |
| 241 | |
Emil Velikov | dd438ae | 2015-02-28 17:20:01 +0000 | [diff] [blame] | 242 | extern void |
Chia-I Wu | e8ba281 | 2010-05-05 17:37:19 +0800 | [diff] [blame] | 243 | _eglSearchPathForEach(EGLBoolean (*callback)(const char *, size_t, void *), |
| 244 | void *callback_data); |
| 245 | |
| 246 | |
Alexander von Gluck IV | 8362068 | 2015-05-13 17:13:37 -0500 | [diff] [blame] | 247 | #ifdef __cplusplus |
| 248 | } |
| 249 | #endif |
| 250 | |
| 251 | |
Brian Paul | adbff7e | 2005-04-22 21:09:39 +0000 | [diff] [blame] | 252 | #endif /* EGLDRIVER_INCLUDED */ |