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