13464ebd5Sriastradh/************************************************************************** 23464ebd5Sriastradh * 3af69d88dSmrg * Copyright 2008 VMware, Inc. 43464ebd5Sriastradh * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> 53464ebd5Sriastradh * Copyright 2010-2011 LunarG, Inc. 63464ebd5Sriastradh * All Rights Reserved. 73464ebd5Sriastradh * 83464ebd5Sriastradh * Permission is hereby granted, free of charge, to any person obtaining a 93464ebd5Sriastradh * copy of this software and associated documentation files (the 103464ebd5Sriastradh * "Software"), to deal in the Software without restriction, including 113464ebd5Sriastradh * without limitation the rights to use, copy, modify, merge, publish, 123464ebd5Sriastradh * distribute, sub license, and/or sell copies of the Software, and to 133464ebd5Sriastradh * permit persons to whom the Software is furnished to do so, subject to 143464ebd5Sriastradh * the following conditions: 153464ebd5Sriastradh * 163464ebd5Sriastradh * The above copyright notice and this permission notice (including the 173464ebd5Sriastradh * next paragraph) shall be included in all copies or substantial portions 183464ebd5Sriastradh * of the Software. 193464ebd5Sriastradh * 203464ebd5Sriastradh * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 213464ebd5Sriastradh * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 223464ebd5Sriastradh * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 233464ebd5Sriastradh * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 243464ebd5Sriastradh * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 253464ebd5Sriastradh * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 263464ebd5Sriastradh * DEALINGS IN THE SOFTWARE. 273464ebd5Sriastradh * 283464ebd5Sriastradh **************************************************************************/ 293464ebd5Sriastradh 303464ebd5Sriastradh 314a49301eSmrg#ifndef EGLDRIVER_INCLUDED 324a49301eSmrg#define EGLDRIVER_INCLUDED 334a49301eSmrg 344a49301eSmrg 3501e04c3fSmrg#include "c99_compat.h" 3601e04c3fSmrg 374a49301eSmrg#include "egltypedefs.h" 387ec681f3Smrg#include <stdbool.h> 393464ebd5Sriastradh#include <stddef.h> 404a49301eSmrg 4101e04c3fSmrg 4201e04c3fSmrg#ifdef __cplusplus 4301e04c3fSmrgextern "C" { 4401e04c3fSmrg#endif 4501e04c3fSmrg 46cdc920a0Smrg/** 47cdc920a0Smrg * Define an inline driver typecast function. 48cdc920a0Smrg * 49cdc920a0Smrg * Note that this macro defines a function and should not be ended with a 50cdc920a0Smrg * semicolon when used. 51cdc920a0Smrg */ 52cdc920a0Smrg#define _EGL_DRIVER_TYPECAST(drvtype, egltype, code) \ 5301e04c3fSmrg static inline struct drvtype *drvtype(const egltype *obj) \ 54cdc920a0Smrg { return (struct drvtype *) code; } 55cdc920a0Smrg 56cdc920a0Smrg 57cdc920a0Smrg/** 587ec681f3Smrg * Define the driver typecast functions for _EGLDisplay, 59cdc920a0Smrg * _EGLContext, _EGLSurface, and _EGLConfig. 60cdc920a0Smrg * 61cdc920a0Smrg * Note that this macro defines several functions and should not be ended with 62cdc920a0Smrg * a semicolon when used. 63cdc920a0Smrg */ 64cdc920a0Smrg#define _EGL_DRIVER_STANDARD_TYPECASTS(drvname) \ 65cdc920a0Smrg /* note that this is not a direct cast */ \ 66cdc920a0Smrg _EGL_DRIVER_TYPECAST(drvname ## _display, _EGLDisplay, obj->DriverData) \ 67cdc920a0Smrg _EGL_DRIVER_TYPECAST(drvname ## _context, _EGLContext, obj) \ 68cdc920a0Smrg _EGL_DRIVER_TYPECAST(drvname ## _surface, _EGLSurface, obj) \ 69cdc920a0Smrg _EGL_DRIVER_TYPECAST(drvname ## _config, _EGLConfig, obj) 70cdc920a0Smrg 717ec681f3Smrg/** 727ec681f3Smrg * A generic function ptr type 737ec681f3Smrg */ 747ec681f3Smrgtypedef void (*_EGLProc)(void); 757ec681f3Smrg 767ec681f3Smrgstruct wl_display; 777ec681f3Smrgstruct mesa_glinterop_device_info; 787ec681f3Smrgstruct mesa_glinterop_export_in; 797ec681f3Smrgstruct mesa_glinterop_export_out; 80cdc920a0Smrg 814a49301eSmrg/** 827ec681f3Smrg * The API dispatcher jumps through these functions 834a49301eSmrg */ 844a49301eSmrgstruct _egl_driver 854a49301eSmrg{ 867ec681f3Smrg /* driver funcs */ 877ec681f3Smrg EGLBoolean (*Initialize)(_EGLDisplay *disp); 887ec681f3Smrg EGLBoolean (*Terminate)(_EGLDisplay *disp); 897ec681f3Smrg 907ec681f3Smrg /* context funcs */ 917ec681f3Smrg _EGLContext *(*CreateContext)(_EGLDisplay *disp, _EGLConfig *config, 927ec681f3Smrg _EGLContext *share_list, const EGLint *attrib_list); 937ec681f3Smrg EGLBoolean (*DestroyContext)(_EGLDisplay *disp, _EGLContext *ctx); 947ec681f3Smrg /* this is the only function (other than Initialize) that may be called 957ec681f3Smrg * with an uninitialized display 967ec681f3Smrg */ 977ec681f3Smrg EGLBoolean (*MakeCurrent)(_EGLDisplay *disp, 987ec681f3Smrg _EGLSurface *draw, _EGLSurface *read, 997ec681f3Smrg _EGLContext *ctx); 1007ec681f3Smrg 1017ec681f3Smrg /* surface funcs */ 1027ec681f3Smrg _EGLSurface *(*CreateWindowSurface)(_EGLDisplay *disp, _EGLConfig *config, 1037ec681f3Smrg void *native_window, const EGLint *attrib_list); 1047ec681f3Smrg _EGLSurface *(*CreatePixmapSurface)(_EGLDisplay *disp, _EGLConfig *config, 1057ec681f3Smrg void *native_pixmap, const EGLint *attrib_list); 1067ec681f3Smrg _EGLSurface *(*CreatePbufferSurface)(_EGLDisplay *disp, _EGLConfig *config, 1077ec681f3Smrg const EGLint *attrib_list); 1087ec681f3Smrg EGLBoolean (*DestroySurface)(_EGLDisplay *disp, _EGLSurface *surface); 1097ec681f3Smrg EGLBoolean (*QuerySurface)(_EGLDisplay *disp, _EGLSurface *surface, 1107ec681f3Smrg EGLint attribute, EGLint *value); 1117ec681f3Smrg EGLBoolean (*BindTexImage)(_EGLDisplay *disp, _EGLSurface *surface, 1127ec681f3Smrg EGLint buffer); 1137ec681f3Smrg EGLBoolean (*ReleaseTexImage)(_EGLDisplay *disp, _EGLSurface *surface, 1147ec681f3Smrg EGLint buffer); 1157ec681f3Smrg EGLBoolean (*SwapInterval)(_EGLDisplay *disp, _EGLSurface *surf, 1167ec681f3Smrg EGLint interval); 1177ec681f3Smrg EGLBoolean (*SwapBuffers)(_EGLDisplay *disp, _EGLSurface *draw); 1187ec681f3Smrg EGLBoolean (*CopyBuffers)(_EGLDisplay *disp, _EGLSurface *surface, 1197ec681f3Smrg void *native_pixmap_target); 1207ec681f3Smrg 1217ec681f3Smrg /* for EGL_KHR_partial_update */ 1227ec681f3Smrg EGLBoolean (*SetDamageRegion)(_EGLDisplay *disp, _EGLSurface *surface, 1237ec681f3Smrg EGLint *rects, EGLint n_rects); 1247ec681f3Smrg 1257ec681f3Smrg /* misc functions */ 1267ec681f3Smrg EGLBoolean (*WaitClient)(_EGLDisplay *disp, _EGLContext *ctx); 1277ec681f3Smrg EGLBoolean (*WaitNative)(EGLint engine); 1287ec681f3Smrg 1297ec681f3Smrg /* this function may be called from multiple threads at the same time */ 1307ec681f3Smrg _EGLProc (*GetProcAddress)(const char *procname); 1317ec681f3Smrg 1327ec681f3Smrg /* for EGL_KHR_image_base */ 1337ec681f3Smrg _EGLImage *(*CreateImageKHR)(_EGLDisplay *disp, _EGLContext *ctx, 1347ec681f3Smrg EGLenum target, EGLClientBuffer buffer, 1357ec681f3Smrg const EGLint *attr_list); 1367ec681f3Smrg EGLBoolean (*DestroyImageKHR)(_EGLDisplay *disp, _EGLImage *image); 1377ec681f3Smrg 1387ec681f3Smrg /* for EGL_KHR_reusable_sync/EGL_KHR_fence_sync */ 1397ec681f3Smrg _EGLSync *(*CreateSyncKHR)(_EGLDisplay *disp, EGLenum type, 1407ec681f3Smrg const EGLAttrib *attrib_list); 1417ec681f3Smrg EGLBoolean (*DestroySyncKHR)(_EGLDisplay *disp, _EGLSync *sync); 1427ec681f3Smrg EGLint (*ClientWaitSyncKHR)(_EGLDisplay *disp, _EGLSync *sync, 1437ec681f3Smrg EGLint flags, EGLTime timeout); 1447ec681f3Smrg EGLint (*WaitSyncKHR)(_EGLDisplay *disp, _EGLSync *sync); 1457ec681f3Smrg /* for EGL_KHR_reusable_sync */ 1467ec681f3Smrg EGLBoolean (*SignalSyncKHR)(_EGLDisplay *disp, _EGLSync *sync, EGLenum mode); 1477ec681f3Smrg 1487ec681f3Smrg /* for EGL_ANDROID_native_fence_sync */ 1497ec681f3Smrg EGLint (*DupNativeFenceFDANDROID)(_EGLDisplay *disp, _EGLSync *sync); 1507ec681f3Smrg 1517ec681f3Smrg /* for EGL_NOK_swap_region */ 1527ec681f3Smrg EGLBoolean (*SwapBuffersRegionNOK)(_EGLDisplay *disp, _EGLSurface *surf, 1537ec681f3Smrg EGLint numRects, const EGLint *rects); 1547ec681f3Smrg 1557ec681f3Smrg /* for EGL_MESA_drm_image */ 1567ec681f3Smrg _EGLImage *(*CreateDRMImageMESA)(_EGLDisplay *disp, const EGLint *attr_list); 1577ec681f3Smrg EGLBoolean (*ExportDRMImageMESA)(_EGLDisplay *disp, _EGLImage *img, 1587ec681f3Smrg EGLint *name, EGLint *handle, 1597ec681f3Smrg EGLint *stride); 1607ec681f3Smrg 1617ec681f3Smrg /* for EGL_WL_bind_wayland_display */ 1627ec681f3Smrg EGLBoolean (*BindWaylandDisplayWL)(_EGLDisplay *disp, struct wl_display *display); 1637ec681f3Smrg EGLBoolean (*UnbindWaylandDisplayWL)(_EGLDisplay *disp, struct wl_display *display); 1647ec681f3Smrg EGLBoolean (*QueryWaylandBufferWL)(_EGLDisplay *displ, struct wl_resource *buffer, 1657ec681f3Smrg EGLint attribute, EGLint *value); 1667ec681f3Smrg 1677ec681f3Smrg /* for EGL_WL_create_wayland_buffer_from_image */ 1687ec681f3Smrg struct wl_buffer *(*CreateWaylandBufferFromImageWL)(_EGLDisplay *disp, _EGLImage *img); 1697ec681f3Smrg 1707ec681f3Smrg /* for EGL_EXT_swap_buffers_with_damage */ 1717ec681f3Smrg EGLBoolean (*SwapBuffersWithDamageEXT)(_EGLDisplay *disp, _EGLSurface *surface, 1727ec681f3Smrg const EGLint *rects, EGLint n_rects); 1737ec681f3Smrg 1747ec681f3Smrg /* for EGL_NV_post_sub_buffer */ 1757ec681f3Smrg EGLBoolean (*PostSubBufferNV)(_EGLDisplay *disp, _EGLSurface *surface, 1767ec681f3Smrg EGLint x, EGLint y, EGLint width, EGLint height); 1777ec681f3Smrg 1787ec681f3Smrg /* for EGL_EXT_buffer_age/EGL_KHR_partial_update */ 1797ec681f3Smrg EGLint (*QueryBufferAge)(_EGLDisplay *disp, _EGLSurface *surface); 1807ec681f3Smrg 1817ec681f3Smrg /* for EGL_CHROMIUM_sync_control */ 1827ec681f3Smrg EGLBoolean (*GetSyncValuesCHROMIUM)(_EGLDisplay *disp, _EGLSurface *surface, 1837ec681f3Smrg EGLuint64KHR *ust, EGLuint64KHR *msc, 1847ec681f3Smrg EGLuint64KHR *sbc); 1857ec681f3Smrg 1867ec681f3Smrg /* for EGL_MESA_image_dma_buf_export */ 1877ec681f3Smrg EGLBoolean (*ExportDMABUFImageQueryMESA)(_EGLDisplay *disp, _EGLImage *img, 1887ec681f3Smrg EGLint *fourcc, EGLint *nplanes, 1897ec681f3Smrg EGLuint64KHR *modifiers); 1907ec681f3Smrg EGLBoolean (*ExportDMABUFImageMESA)(_EGLDisplay *disp, _EGLImage *img, 1917ec681f3Smrg EGLint *fds, EGLint *strides, 1927ec681f3Smrg EGLint *offsets); 1937ec681f3Smrg 1947ec681f3Smrg /* for EGL_MESA_query_driver */ 1957ec681f3Smrg const char *(*QueryDriverName)(_EGLDisplay *disp); 1967ec681f3Smrg char *(*QueryDriverConfig)(_EGLDisplay *disp); 1977ec681f3Smrg 1987ec681f3Smrg /* for OpenGL-OpenCL interop; see include/GL/mesa_glinterop.h */ 1997ec681f3Smrg int (*GLInteropQueryDeviceInfo)(_EGLDisplay *disp, _EGLContext *ctx, 2007ec681f3Smrg struct mesa_glinterop_device_info *out); 2017ec681f3Smrg int (*GLInteropExportObject)(_EGLDisplay *disp, _EGLContext *ctx, 2027ec681f3Smrg struct mesa_glinterop_export_in *in, 2037ec681f3Smrg struct mesa_glinterop_export_out *out); 2047ec681f3Smrg 2057ec681f3Smrg /* for EGL_EXT_image_dma_buf_import_modifiers */ 2067ec681f3Smrg EGLBoolean (*QueryDmaBufFormatsEXT)(_EGLDisplay *disp, 2077ec681f3Smrg EGLint max_formats, EGLint *formats, 2087ec681f3Smrg EGLint *num_formats); 2097ec681f3Smrg EGLBoolean (*QueryDmaBufModifiersEXT)(_EGLDisplay *disp, EGLint format, 2107ec681f3Smrg EGLint max_modifiers, EGLuint64KHR *modifiers, 2117ec681f3Smrg EGLBoolean *external_only, 2127ec681f3Smrg EGLint *num_modifiers); 2137ec681f3Smrg 2147ec681f3Smrg /* for EGL_ANDROID_blob_cache */ 2157ec681f3Smrg void (*SetBlobCacheFuncsANDROID)(_EGLDisplay *disp, 2167ec681f3Smrg EGLSetBlobFuncANDROID set, 2177ec681f3Smrg EGLGetBlobFuncANDROID get); 2184a49301eSmrg}; 2194a49301eSmrg 2204a49301eSmrg 22101e04c3fSmrg#ifdef __cplusplus 22201e04c3fSmrg} 22301e04c3fSmrg#endif 22401e04c3fSmrg 22501e04c3fSmrg 2264a49301eSmrg#endif /* EGLDRIVER_INCLUDED */ 227