| 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 |
#ifndef EGLDRIVER_INCLUDED |
| 31 |
#define EGLDRIVER_INCLUDED |
| 32 |
|
| 33 |
#include <stdbool.h> |
| 34 |
#include <stddef.h> |
| 35 |
#include "egltypedefs.h" |
| 36 |
|
| 37 |
#ifdef __cplusplus |
| 38 |
extern "C" { |
| 39 |
#endif |
| 40 |
|
| 41 |
/** |
| 42 |
* Define an inline driver typecast function. |
| 43 |
* |
| 44 |
* Note that this macro defines a function and should not be ended with a |
| 45 |
* semicolon when used. |
| 46 |
*/ |
| 47 |
#define _EGL_DRIVER_TYPECAST(drvtype, egltype, code) \ |
| 48 |
static inline struct drvtype *drvtype(const egltype *obj) \ |
| 49 |
{ \ |
| 50 |
return (struct drvtype *)code; \ |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Define the driver typecast functions for _EGLDisplay, |
| 55 |
* _EGLContext, _EGLSurface, and _EGLConfig. |
| 56 |
* |
| 57 |
* Note that this macro defines several functions and should not be ended with |
| 58 |
* a semicolon when used. |
| 59 |
*/ |
| 60 |
#define _EGL_DRIVER_STANDARD_TYPECASTS(drvname) \ |
| 61 |
/* note that this is not a direct cast */ \ |
| 62 |
_EGL_DRIVER_TYPECAST(drvname##_display, _EGLDisplay, obj->DriverData) \ |
| 63 |
_EGL_DRIVER_TYPECAST(drvname##_context, _EGLContext, obj) \ |
| 64 |
_EGL_DRIVER_TYPECAST(drvname##_surface, _EGLSurface, obj) \ |
| 65 |
_EGL_DRIVER_TYPECAST(drvname##_config, _EGLConfig, obj) |
| 66 |
|
| 67 |
/** |
| 68 |
* A generic function ptr type |
| 69 |
*/ |
| 70 |
typedef void (*_EGLProc)(void); |
| 71 |
|
| 72 |
struct wl_display; |
| 73 |
struct mesa_glinterop_device_info; |
| 74 |
struct mesa_glinterop_export_in; |
| 75 |
struct mesa_glinterop_export_out; |
| 76 |
struct mesa_glinterop_flush_out; |
| 77 |
typedef struct __GLsync *GLsync; |
| 78 |
|
| 79 |
#define EGL_UUID_SIZE 16 |
| 80 |
|
| 81 |
/** |
| 82 |
* For use in EGL_EXT_device_query_name and EGL_EXT_device_persistent_id |
| 83 |
*/ |
| 84 |
struct egl_device_info { |
| 85 |
uint8_t device_uuid[EGL_UUID_SIZE]; |
| 86 |
uint8_t driver_uuid[EGL_UUID_SIZE]; |
| 87 |
/* Data below needs to be freed manually */ |
| 88 |
char *vendor_name; |
| 89 |
char *renderer_name; |
| 90 |
char *driver_name; |
| 91 |
}; |
| 92 |
|
| 93 |
/** |
| 94 |
* The API dispatcher jumps through these functions |
| 95 |
*/ |
| 96 |
struct _egl_driver { |
| 97 |
/* driver funcs */ |
| 98 |
EGLBoolean (*Initialize)(_EGLDisplay *disp); |
| 99 |
EGLBoolean (*Terminate)(_EGLDisplay *disp); |
| 100 |
|
| 101 |
/* context funcs */ |
| 102 |
_EGLContext *(*CreateContext)(_EGLDisplay *disp, _EGLConfig *config, |
| 103 |
_EGLContext *share_list, |
| 104 |
const EGLint *attrib_list); |
| 105 |
EGLBoolean (*DestroyContext)(_EGLDisplay *disp, _EGLContext *ctx); |
| 106 |
/* this is the only function (other than Initialize) that may be called |
| 107 |
* with an uninitialized display |
| 108 |
*/ |
| 109 |
EGLBoolean (*MakeCurrent)(_EGLDisplay *disp, _EGLSurface *draw, |
| 110 |
_EGLSurface *read, _EGLContext *ctx); |
| 111 |
|
| 112 |
/* surface funcs */ |
| 113 |
_EGLSurface *(*CreateWindowSurface)(_EGLDisplay *disp, _EGLConfig *config, |
| 114 |
void *native_window, |
| 115 |
const EGLint *attrib_list); |
| 116 |
_EGLSurface *(*CreatePixmapSurface)(_EGLDisplay *disp, _EGLConfig *config, |
| 117 |
void *native_pixmap, |
| 118 |
const EGLint *attrib_list); |
| 119 |
_EGLSurface *(*CreatePbufferSurface)(_EGLDisplay *disp, _EGLConfig *config, |
| 120 |
const EGLint *attrib_list); |
| 121 |
EGLBoolean (*DestroySurface)(_EGLDisplay *disp, _EGLSurface *surface); |
| 122 |
EGLBoolean (*QuerySurface)(_EGLDisplay *disp, _EGLSurface *surface, |
| 123 |
EGLint attribute, EGLint *value); |
| 124 |
EGLBoolean (*BindTexImage)(_EGLDisplay *disp, _EGLSurface *surface, |
| 125 |
EGLint buffer); |
| 126 |
EGLBoolean (*ReleaseTexImage)(_EGLDisplay *disp, _EGLSurface *surface, |
| 127 |
EGLint buffer); |
| 128 |
EGLBoolean (*SwapInterval)(_EGLDisplay *disp, _EGLSurface *surf, |
| 129 |
EGLint interval); |
| 130 |
EGLBoolean (*SwapBuffers)(_EGLDisplay *disp, _EGLSurface *draw); |
| 131 |
EGLBoolean (*CopyBuffers)(_EGLDisplay *disp, _EGLSurface *surface, |
| 132 |
void *native_pixmap_target); |
| 133 |
|
| 134 |
/* for EGL_KHR_partial_update */ |
| 135 |
EGLBoolean (*SetDamageRegion)(_EGLDisplay *disp, _EGLSurface *surface, |
| 136 |
EGLint *rects, EGLint n_rects); |
| 137 |
|
| 138 |
/* misc functions */ |
| 139 |
EGLBoolean (*WaitClient)(_EGLDisplay *disp, _EGLContext *ctx); |
| 140 |
EGLBoolean (*WaitNative)(EGLint engine); |
| 141 |
|
| 142 |
/* for EGL_KHR_image_base */ |
| 143 |
_EGLImage *(*CreateImageKHR)(_EGLDisplay *disp, _EGLContext *ctx, |
| 144 |
EGLenum target, EGLClientBuffer buffer, |
| 145 |
const EGLint *attr_list); |
| 146 |
EGLBoolean (*DestroyImageKHR)(_EGLDisplay *disp, _EGLImage *image); |
| 147 |
|
| 148 |
/* for EGL_KHR_reusable_sync/EGL_KHR_fence_sync */ |
| 149 |
_EGLSync *(*CreateSyncKHR)(_EGLDisplay *disp, EGLenum type, |
| 150 |
const EGLAttrib *attrib_list); |
| 151 |
EGLBoolean (*DestroySyncKHR)(_EGLDisplay *disp, _EGLSync *sync); |
| 152 |
EGLint (*ClientWaitSyncKHR)(_EGLDisplay *disp, _EGLSync *sync, EGLint flags, |
| 153 |
EGLTime timeout); |
| 154 |
EGLint (*WaitSyncKHR)(_EGLDisplay *disp, _EGLSync *sync); |
| 155 |
/* for EGL_KHR_reusable_sync */ |
| 156 |
EGLBoolean (*SignalSyncKHR)(_EGLDisplay *disp, _EGLSync *sync, EGLenum mode); |
| 157 |
|
| 158 |
/* for EGL_ANDROID_native_fence_sync */ |
| 159 |
EGLint (*DupNativeFenceFDANDROID)(_EGLDisplay *disp, _EGLSync *sync); |
| 160 |
|
| 161 |
#ifdef HAVE_BIND_WL_DISPLAY |
| 162 |
/* for EGL_WL_bind_wayland_display */ |
| 163 |
EGLBoolean (*BindWaylandDisplayWL)(_EGLDisplay *disp, |
| 164 |
struct wl_display *display); |
| 165 |
EGLBoolean (*UnbindWaylandDisplayWL)(_EGLDisplay *disp, |
| 166 |
struct wl_display *display); |
| 167 |
EGLBoolean (*QueryWaylandBufferWL)(_EGLDisplay *displ, |
| 168 |
struct wl_resource *buffer, |
| 169 |
EGLint attribute, EGLint *value); |
| 170 |
|
| 171 |
/* for EGL_WL_create_wayland_buffer_from_image */ |
| 172 |
struct wl_buffer *(*CreateWaylandBufferFromImageWL)(_EGLDisplay *disp, |
| 173 |
_EGLImage *img); |
| 174 |
#endif |
| 175 |
|
| 176 |
/* for EGL_EXT_swap_buffers_with_damage */ |
| 177 |
EGLBoolean (*SwapBuffersWithDamageEXT)(_EGLDisplay *disp, |
| 178 |
_EGLSurface *surface, |
| 179 |
const EGLint *rects, EGLint n_rects); |
| 180 |
|
| 181 |
/* for EGL_EXT_buffer_age/EGL_KHR_partial_update */ |
| 182 |
EGLint (*QueryBufferAge)(_EGLDisplay *disp, _EGLSurface *surface); |
| 183 |
|
| 184 |
/* for EGL_CHROMIUM_sync_control */ |
| 185 |
EGLBoolean (*GetSyncValuesCHROMIUM)(_EGLDisplay *disp, _EGLSurface *surface, |
| 186 |
EGLuint64KHR *ust, EGLuint64KHR *msc, |
| 187 |
EGLuint64KHR *sbc); |
| 188 |
|
| 189 |
EGLBoolean (*GetMscRateANGLE)(_EGLDisplay *disp, _EGLSurface *surface, |
| 190 |
EGLint *numerator, EGLint *denominator); |
| 191 |
|
| 192 |
/* for EGL_MESA_image_dma_buf_export */ |
| 193 |
EGLBoolean (*ExportDMABUFImageQueryMESA)(_EGLDisplay *disp, _EGLImage *img, |
| 194 |
EGLint *fourcc, EGLint *nplanes, |
| 195 |
EGLuint64KHR *modifiers); |
| 196 |
EGLBoolean (*ExportDMABUFImageMESA)(_EGLDisplay *disp, _EGLImage *img, |
| 197 |
EGLint *fds, EGLint *strides, |
| 198 |
EGLint *offsets); |
| 199 |
|
| 200 |
/* for EGL_MESA_query_driver */ |
| 201 |
const char *(*QueryDriverName)(_EGLDisplay *disp); |
| 202 |
char *(*QueryDriverConfig)(_EGLDisplay *disp); |
| 203 |
|
| 204 |
/* for EGL_EXT_device_query_name and EGL_EXT_device_persistent_id */ |
| 205 |
bool (*QueryDeviceInfo)(const void* driver_device_identifier, |
| 206 |
struct egl_device_info *device_info); |
| 207 |
|
| 208 |
/* for OpenGL-OpenCL interop; see include/GL/mesa_glinterop.h */ |
| 209 |
int (*GLInteropQueryDeviceInfo)(_EGLDisplay *disp, _EGLContext *ctx, |
| 210 |
struct mesa_glinterop_device_info *out); |
| 211 |
int (*GLInteropExportObject)(_EGLDisplay *disp, _EGLContext *ctx, |
| 212 |
struct mesa_glinterop_export_in *in, |
| 213 |
struct mesa_glinterop_export_out *out); |
| 214 |
int (*GLInteropFlushObjects)(_EGLDisplay *disp, _EGLContext *ctx, |
| 215 |
unsigned count, |
| 216 |
struct mesa_glinterop_export_in *in, |
| 217 |
struct mesa_glinterop_flush_out *out); |
| 218 |
|
| 219 |
/* for EGL_EXT_image_dma_buf_import_modifiers */ |
| 220 |
EGLBoolean (*QueryDmaBufFormatsEXT)(_EGLDisplay *disp, EGLint max_formats, |
| 221 |
EGLint *formats, EGLint *num_formats); |
| 222 |
EGLBoolean (*QueryDmaBufModifiersEXT)(_EGLDisplay *disp, EGLint format, |
| 223 |
EGLint max_modifiers, |
| 224 |
EGLuint64KHR *modifiers, |
| 225 |
EGLBoolean *external_only, |
| 226 |
EGLint *num_modifiers); |
| 227 |
|
| 228 |
/* for EGL_ANDROID_blob_cache */ |
| 229 |
void (*SetBlobCacheFuncsANDROID)(_EGLDisplay *disp, |
| 230 |
EGLSetBlobFuncANDROID set, |
| 231 |
EGLGetBlobFuncANDROID get); |
| 232 |
|
| 233 |
/* for EGL_EXT_surface_compression */ |
| 234 |
EGLBoolean (*QuerySupportedCompressionRatesEXT)(_EGLDisplay *disp, |
| 235 |
_EGLConfig *config, |
| 236 |
const EGLAttrib *attr_list, |
| 237 |
EGLint *rates, |
| 238 |
EGLint rate_size, |
| 239 |
EGLint *num_rates); |
| 240 |
}; |
| 241 |
|
| 242 |
#ifdef __cplusplus |
| 243 |
} |
| 244 |
#endif |
| 245 |
|
| 246 |
#endif /* EGLDRIVER_INCLUDED */ |