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