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 /** 80 * The API dispatcher jumps through these functions 81 */ 82 struct _egl_driver { 83 /* driver funcs */ 84 EGLBoolean (*Initialize)(_EGLDisplay *disp); 85 EGLBoolean (*Terminate)(_EGLDisplay *disp); 86 87 /* context funcs */ 88 _EGLContext *(*CreateContext)(_EGLDisplay *disp, _EGLConfig *config, 89 _EGLContext *share_list, 90 const EGLint *attrib_list); 91 EGLBoolean (*DestroyContext)(_EGLDisplay *disp, _EGLContext *ctx); 92 /* this is the only function (other than Initialize) that may be called 93 * with an uninitialized display 94 */ 95 EGLBoolean (*MakeCurrent)(_EGLDisplay *disp, _EGLSurface *draw, 96 _EGLSurface *read, _EGLContext *ctx); 97 98 /* surface funcs */ 99 _EGLSurface *(*CreateWindowSurface)(_EGLDisplay *disp, _EGLConfig *config, 100 void *native_window, 101 const EGLint *attrib_list); 102 _EGLSurface *(*CreatePixmapSurface)(_EGLDisplay *disp, _EGLConfig *config, 103 void *native_pixmap, 104 const EGLint *attrib_list); 105 _EGLSurface *(*CreatePbufferSurface)(_EGLDisplay *disp, _EGLConfig *config, 106 const EGLint *attrib_list); 107 EGLBoolean (*DestroySurface)(_EGLDisplay *disp, _EGLSurface *surface); 108 EGLBoolean (*QuerySurface)(_EGLDisplay *disp, _EGLSurface *surface, 109 EGLint attribute, EGLint *value); 110 EGLBoolean (*BindTexImage)(_EGLDisplay *disp, _EGLSurface *surface, 111 EGLint buffer); 112 EGLBoolean (*ReleaseTexImage)(_EGLDisplay *disp, _EGLSurface *surface, 113 EGLint buffer); 114 EGLBoolean (*SwapInterval)(_EGLDisplay *disp, _EGLSurface *surf, 115 EGLint interval); 116 EGLBoolean (*SwapBuffers)(_EGLDisplay *disp, _EGLSurface *draw); 117 EGLBoolean (*CopyBuffers)(_EGLDisplay *disp, _EGLSurface *surface, 118 void *native_pixmap_target); 119 120 /* for EGL_KHR_partial_update */ 121 EGLBoolean (*SetDamageRegion)(_EGLDisplay *disp, _EGLSurface *surface, 122 EGLint *rects, EGLint n_rects); 123 124 /* misc functions */ 125 EGLBoolean (*WaitClient)(_EGLDisplay *disp, _EGLContext *ctx); 126 EGLBoolean (*WaitNative)(EGLint engine); 127 128 /* for EGL_KHR_image_base */ 129 _EGLImage *(*CreateImageKHR)(_EGLDisplay *disp, _EGLContext *ctx, 130 EGLenum target, EGLClientBuffer buffer, 131 const EGLint *attr_list); 132 EGLBoolean (*DestroyImageKHR)(_EGLDisplay *disp, _EGLImage *image); 133 134 /* for EGL_KHR_reusable_sync/EGL_KHR_fence_sync */ 135 _EGLSync *(*CreateSyncKHR)(_EGLDisplay *disp, EGLenum type, 136 const EGLAttrib *attrib_list); 137 EGLBoolean (*DestroySyncKHR)(_EGLDisplay *disp, _EGLSync *sync); 138 EGLint (*ClientWaitSyncKHR)(_EGLDisplay *disp, _EGLSync *sync, EGLint flags, 139 EGLTime timeout); 140 EGLint (*WaitSyncKHR)(_EGLDisplay *disp, _EGLSync *sync); 141 /* for EGL_KHR_reusable_sync */ 142 EGLBoolean (*SignalSyncKHR)(_EGLDisplay *disp, _EGLSync *sync, EGLenum mode); 143 144 /* for EGL_ANDROID_native_fence_sync */ 145 EGLint (*DupNativeFenceFDANDROID)(_EGLDisplay *disp, _EGLSync *sync); 146 147 /* for EGL_NOK_swap_region */ 148 EGLBoolean (*SwapBuffersRegionNOK)(_EGLDisplay *disp, _EGLSurface *surf, 149 EGLint numRects, const EGLint *rects); 150 151 /* for EGL_MESA_drm_image */ 152 _EGLImage *(*CreateDRMImageMESA)(_EGLDisplay *disp, const EGLint *attr_list); 153 EGLBoolean (*ExportDRMImageMESA)(_EGLDisplay *disp, _EGLImage *img, 154 EGLint *name, EGLint *handle, 155 EGLint *stride); 156 157 /* for EGL_WL_bind_wayland_display */ 158 EGLBoolean (*BindWaylandDisplayWL)(_EGLDisplay *disp, 159 struct wl_display *display); 160 EGLBoolean (*UnbindWaylandDisplayWL)(_EGLDisplay *disp, 161 struct wl_display *display); 162 EGLBoolean (*QueryWaylandBufferWL)(_EGLDisplay *displ, 163 struct wl_resource *buffer, 164 EGLint attribute, EGLint *value); 165 166 /* for EGL_WL_create_wayland_buffer_from_image */ 167 struct wl_buffer *(*CreateWaylandBufferFromImageWL)(_EGLDisplay *disp, 168 _EGLImage *img); 169 170 /* for EGL_EXT_swap_buffers_with_damage */ 171 EGLBoolean (*SwapBuffersWithDamageEXT)(_EGLDisplay *disp, 172 _EGLSurface *surface, 173 const EGLint *rects, EGLint n_rects); 174 175 /* for EGL_NV_post_sub_buffer */ 176 EGLBoolean (*PostSubBufferNV)(_EGLDisplay *disp, _EGLSurface *surface, 177 EGLint x, EGLint y, EGLint width, 178 EGLint height); 179 180 /* for EGL_EXT_buffer_age/EGL_KHR_partial_update */ 181 EGLint (*QueryBufferAge)(_EGLDisplay *disp, _EGLSurface *surface); 182 183 /* for EGL_CHROMIUM_sync_control */ 184 EGLBoolean (*GetSyncValuesCHROMIUM)(_EGLDisplay *disp, _EGLSurface *surface, 185 EGLuint64KHR *ust, EGLuint64KHR *msc, 186 EGLuint64KHR *sbc); 187 188 EGLBoolean (*GetMscRateANGLE)(_EGLDisplay *disp, _EGLSurface *surface, 189 EGLint *numerator, EGLint *denominator); 190 191 /* for EGL_MESA_image_dma_buf_export */ 192 EGLBoolean (*ExportDMABUFImageQueryMESA)(_EGLDisplay *disp, _EGLImage *img, 193 EGLint *fourcc, EGLint *nplanes, 194 EGLuint64KHR *modifiers); 195 EGLBoolean (*ExportDMABUFImageMESA)(_EGLDisplay *disp, _EGLImage *img, 196 EGLint *fds, EGLint *strides, 197 EGLint *offsets); 198 199 /* for EGL_MESA_query_driver */ 200 const char *(*QueryDriverName)(_EGLDisplay *disp); 201 char *(*QueryDriverConfig)(_EGLDisplay *disp); 202 203 /* for OpenGL-OpenCL interop; see include/GL/mesa_glinterop.h */ 204 int (*GLInteropQueryDeviceInfo)(_EGLDisplay *disp, _EGLContext *ctx, 205 struct mesa_glinterop_device_info *out); 206 int (*GLInteropExportObject)(_EGLDisplay *disp, _EGLContext *ctx, 207 struct mesa_glinterop_export_in *in, 208 struct mesa_glinterop_export_out *out); 209 int (*GLInteropFlushObjects)(_EGLDisplay *disp, _EGLContext *ctx, 210 unsigned count, 211 struct mesa_glinterop_export_in *in, 212 struct mesa_glinterop_flush_out *out); 213 214 /* for EGL_EXT_image_dma_buf_import_modifiers */ 215 EGLBoolean (*QueryDmaBufFormatsEXT)(_EGLDisplay *disp, EGLint max_formats, 216 EGLint *formats, EGLint *num_formats); 217 EGLBoolean (*QueryDmaBufModifiersEXT)(_EGLDisplay *disp, EGLint format, 218 EGLint max_modifiers, 219 EGLuint64KHR *modifiers, 220 EGLBoolean *external_only, 221 EGLint *num_modifiers); 222 223 /* for EGL_ANDROID_blob_cache */ 224 void (*SetBlobCacheFuncsANDROID)(_EGLDisplay *disp, 225 EGLSetBlobFuncANDROID set, 226 EGLGetBlobFuncANDROID get); 227 228 /* for EGL_EXT_surface_compression */ 229 EGLBoolean (*QuerySupportedCompressionRatesEXT)(_EGLDisplay *disp, 230 _EGLConfig *config, 231 const EGLAttrib *attr_list, 232 EGLint *rates, 233 EGLint rate_size, 234 EGLint *num_rates); 235 }; 236 237 #ifdef __cplusplus 238 } 239 #endif 240 241 #endif /* EGLDRIVER_INCLUDED */ 242