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