egl: image_dma_buf_export - use KHR 64-bit type
[mesa.git] / src / egl / main / eglapi.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 EGLAPI_INCLUDED
32 #define EGLAPI_INCLUDED
33
34 /**
35 * A generic function ptr type
36 */
37 typedef void (*_EGLProc)(void);
38
39
40 /**
41 * Typedefs for all EGL API entrypoint functions.
42 */
43
44 /* driver funcs */
45 typedef EGLBoolean (*Initialize_t)(_EGLDriver *, _EGLDisplay *dpy);
46 typedef EGLBoolean (*Terminate_t)(_EGLDriver *, _EGLDisplay *dpy);
47
48 /* config funcs */
49 typedef EGLBoolean (*GetConfigs_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
50 typedef EGLBoolean (*ChooseConfig_t)(_EGLDriver *drv, _EGLDisplay *dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
51 typedef EGLBoolean (*GetConfigAttrib_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, EGLint attribute, EGLint *value);
52
53 /* context funcs */
54 typedef _EGLContext *(*CreateContext_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, _EGLContext *share_list, const EGLint *attrib_list);
55 typedef EGLBoolean (*DestroyContext_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx);
56 /* this is the only function (other than Initialize) that may be called with an uninitialized display */
57 typedef EGLBoolean (*MakeCurrent_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw, _EGLSurface *read, _EGLContext *ctx);
58 typedef EGLBoolean (*QueryContext_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, EGLint attribute, EGLint *value);
59
60 /* surface funcs */
61 typedef _EGLSurface *(*CreateWindowSurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, void *native_window, const EGLint *attrib_list);
62 typedef _EGLSurface *(*CreatePixmapSurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, void *native_pixmap, const EGLint *attrib_list);
63 typedef _EGLSurface *(*CreatePbufferSurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, const EGLint *attrib_list);
64 typedef EGLBoolean (*DestroySurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface);
65 typedef EGLBoolean (*QuerySurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint attribute, EGLint *value);
66 typedef EGLBoolean (*SurfaceAttrib_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint attribute, EGLint value);
67 typedef EGLBoolean (*BindTexImage_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint buffer);
68 typedef EGLBoolean (*ReleaseTexImage_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint buffer);
69 typedef EGLBoolean (*SwapInterval_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint interval);
70 typedef EGLBoolean (*SwapBuffers_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw);
71 typedef EGLBoolean (*CopyBuffers_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, void *native_pixmap_target);
72
73 /* misc funcs */
74 typedef EGLBoolean (*WaitClient_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx);
75 typedef EGLBoolean (*WaitNative_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLint engine);
76
77 /* this function may be called from multiple threads at the same time */
78 typedef _EGLProc (*GetProcAddress_t)(_EGLDriver *drv, const char *procname);
79
80
81
82 #ifdef EGL_MESA_screen_surface
83 typedef EGLBoolean (*ChooseModeMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLScreen *screen, const EGLint *attrib_list, EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes);
84 typedef EGLBoolean (*GetModesMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLScreen *screen, EGLModeMESA *modes, EGLint mode_size, EGLint *num_mode);
85 typedef EGLBoolean (*GetModeAttribMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLMode *mode, EGLint attribute, EGLint *value);
86 typedef EGLBoolean (*CopyContextMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *source, _EGLContext *dest, EGLint mask);
87 typedef EGLBoolean (*GetScreensMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLScreenMESA *screens, EGLint max_screens, EGLint *num_screens);
88 typedef _EGLSurface *(*CreateScreenSurfaceMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, const EGLint *attrib_list);
89 typedef EGLBoolean (*ShowScreenSurfaceMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLScreen *screen, _EGLSurface *surface, _EGLMode *mode);
90 typedef EGLBoolean (*ScreenPositionMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLScreen *screen, EGLint x, EGLint y);
91 typedef EGLBoolean (*QueryScreenMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLScreen *screen, EGLint attribute, EGLint *value);
92 typedef EGLBoolean (*QueryScreenSurfaceMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLScreen *screen, _EGLSurface **surface);
93 typedef EGLBoolean (*QueryScreenModeMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLScreen *screen, _EGLMode **mode);
94 typedef const char * (*QueryModeStringMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLMode *mode);
95 #endif /* EGL_MESA_screen_surface */
96
97
98 typedef _EGLSurface *(*CreatePbufferFromClientBuffer_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLenum buftype, EGLClientBuffer buffer, _EGLConfig *config, const EGLint *attrib_list);
99
100
101 typedef _EGLImage *(*CreateImageKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attr_list);
102 typedef EGLBoolean (*DestroyImageKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *image);
103
104
105 typedef _EGLSync *(*CreateSyncKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLenum type, const EGLint *attrib_list, const EGLAttribKHR *attrib_list64);
106 typedef EGLBoolean (*DestroySyncKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync);
107 typedef EGLint (*ClientWaitSyncKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync, EGLint flags, EGLTimeKHR timeout);
108 typedef EGLint (*WaitSyncKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync);
109 typedef EGLBoolean (*SignalSyncKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync, EGLenum mode);
110 typedef EGLBoolean (*GetSyncAttribKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync, EGLint attribute, EGLint *value);
111
112
113 #ifdef EGL_NOK_swap_region
114 typedef EGLBoolean (*SwapBuffersRegionNOK_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, EGLint numRects, const EGLint *rects);
115 #endif
116
117 #ifdef EGL_MESA_drm_image
118 typedef _EGLImage *(*CreateDRMImageMESA_t)(_EGLDriver *drv, _EGLDisplay *disp, const EGLint *attr_list);
119 typedef EGLBoolean (*ExportDRMImageMESA_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img, EGLint *name, EGLint *handle, EGLint *stride);
120 #endif
121
122 #ifdef EGL_WL_bind_wayland_display
123 struct wl_display;
124 typedef EGLBoolean (*BindWaylandDisplayWL_t)(_EGLDriver *drv, _EGLDisplay *disp, struct wl_display *display);
125 typedef EGLBoolean (*UnbindWaylandDisplayWL_t)(_EGLDriver *drv, _EGLDisplay *disp, struct wl_display *display);
126 typedef EGLBoolean (*QueryWaylandBufferWL_t)(_EGLDriver *drv, _EGLDisplay *displ, struct wl_resource *buffer, EGLint attribute, EGLint *value);
127 #endif
128
129 #ifdef EGL_WL_create_wayland_buffer_from_image
130 typedef struct wl_buffer * (*CreateWaylandBufferFromImageWL_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img);
131 #endif
132
133 typedef EGLBoolean (*PostSubBufferNV_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surface, EGLint x, EGLint y, EGLint width, EGLint height);
134
135 typedef EGLint (*QueryBufferAge_t)(_EGLDriver *drv,
136 _EGLDisplay *dpy, _EGLSurface *surface);
137
138 #ifdef EGL_EXT_swap_buffers_with_damage
139 typedef EGLBoolean (*SwapBuffersWithDamageEXT_t) (_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, const EGLint *rects, EGLint n_rects);
140 #endif
141
142 typedef EGLBoolean (*GetSyncValuesCHROMIUM_t) (_EGLDisplay *dpy, _EGLSurface *surface, EGLuint64KHR *ust, EGLuint64KHR *msc, EGLuint64KHR *sbc);
143
144 #ifdef EGL_MESA_image_dma_buf_export
145 typedef EGLBoolean (*ExportDMABUFImageQueryMESA_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img, EGLint *fourcc, EGLint *nplanes, EGLuint64KHR *modifiers);
146 typedef EGLBoolean (*ExportDMABUFImageMESA_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img, EGLint *fds, EGLint *strides, EGLint *offsets);
147 #endif
148
149 /**
150 * The API dispatcher jumps through these functions
151 */
152 struct _egl_api
153 {
154 Initialize_t Initialize;
155 Terminate_t Terminate;
156
157 GetConfigs_t GetConfigs;
158 ChooseConfig_t ChooseConfig;
159 GetConfigAttrib_t GetConfigAttrib;
160
161 CreateContext_t CreateContext;
162 DestroyContext_t DestroyContext;
163 MakeCurrent_t MakeCurrent;
164 QueryContext_t QueryContext;
165
166 CreateWindowSurface_t CreateWindowSurface;
167 CreatePixmapSurface_t CreatePixmapSurface;
168 CreatePbufferSurface_t CreatePbufferSurface;
169 DestroySurface_t DestroySurface;
170 QuerySurface_t QuerySurface;
171 SurfaceAttrib_t SurfaceAttrib;
172 BindTexImage_t BindTexImage;
173 ReleaseTexImage_t ReleaseTexImage;
174 SwapInterval_t SwapInterval;
175 SwapBuffers_t SwapBuffers;
176 CopyBuffers_t CopyBuffers;
177
178 WaitClient_t WaitClient;
179 WaitNative_t WaitNative;
180 GetProcAddress_t GetProcAddress;
181
182 #ifdef EGL_MESA_screen_surface
183 ChooseModeMESA_t ChooseModeMESA;
184 GetModesMESA_t GetModesMESA;
185 GetModeAttribMESA_t GetModeAttribMESA;
186 CopyContextMESA_t CopyContextMESA;
187 GetScreensMESA_t GetScreensMESA;
188 CreateScreenSurfaceMESA_t CreateScreenSurfaceMESA;
189 ShowScreenSurfaceMESA_t ShowScreenSurfaceMESA;
190 ScreenPositionMESA_t ScreenPositionMESA;
191 QueryScreenMESA_t QueryScreenMESA;
192 QueryScreenSurfaceMESA_t QueryScreenSurfaceMESA;
193 QueryScreenModeMESA_t QueryScreenModeMESA;
194 QueryModeStringMESA_t QueryModeStringMESA;
195 #endif /* EGL_MESA_screen_surface */
196
197 CreatePbufferFromClientBuffer_t CreatePbufferFromClientBuffer;
198
199 CreateImageKHR_t CreateImageKHR;
200 DestroyImageKHR_t DestroyImageKHR;
201
202 CreateSyncKHR_t CreateSyncKHR;
203 DestroySyncKHR_t DestroySyncKHR;
204 ClientWaitSyncKHR_t ClientWaitSyncKHR;
205 WaitSyncKHR_t WaitSyncKHR;
206 SignalSyncKHR_t SignalSyncKHR;
207 GetSyncAttribKHR_t GetSyncAttribKHR;
208
209 #ifdef EGL_NOK_swap_region
210 SwapBuffersRegionNOK_t SwapBuffersRegionNOK;
211 #endif
212
213 #ifdef EGL_MESA_drm_image
214 CreateDRMImageMESA_t CreateDRMImageMESA;
215 ExportDRMImageMESA_t ExportDRMImageMESA;
216 #endif
217
218 #ifdef EGL_WL_bind_wayland_display
219 BindWaylandDisplayWL_t BindWaylandDisplayWL;
220 UnbindWaylandDisplayWL_t UnbindWaylandDisplayWL;
221 QueryWaylandBufferWL_t QueryWaylandBufferWL;
222 #endif
223
224 #ifdef EGL_WL_create_wayland_buffer_from_image
225 CreateWaylandBufferFromImageWL_t CreateWaylandBufferFromImageWL;
226 #endif
227
228 #ifdef EGL_EXT_swap_buffers_with_damage
229 SwapBuffersWithDamageEXT_t SwapBuffersWithDamageEXT;
230 #endif /* EGL_EXT_swap_buffers_with_damage */
231
232 PostSubBufferNV_t PostSubBufferNV;
233
234 QueryBufferAge_t QueryBufferAge;
235 GetSyncValuesCHROMIUM_t GetSyncValuesCHROMIUM;
236
237 #ifdef EGL_MESA_image_dma_buf_export
238 ExportDMABUFImageQueryMESA_t ExportDMABUFImageQueryMESA;
239 ExportDMABUFImageMESA_t ExportDMABUFImageMESA;
240 #endif
241 };
242
243 #endif /* EGLAPI_INCLUDED */