xref: /aosp_15_r20/external/mesa3d/src/egl/main/egldriver.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1*61046927SAndroid Build Coastguard Worker /**************************************************************************
2*61046927SAndroid Build Coastguard Worker  *
3*61046927SAndroid Build Coastguard Worker  * Copyright 2008 VMware, Inc.
4*61046927SAndroid Build Coastguard Worker  * Copyright 2009-2010 Chia-I Wu <[email protected]>
5*61046927SAndroid Build Coastguard Worker  * Copyright 2010-2011 LunarG, Inc.
6*61046927SAndroid Build Coastguard Worker  * All Rights Reserved.
7*61046927SAndroid Build Coastguard Worker  *
8*61046927SAndroid Build Coastguard Worker  * Permission is hereby granted, free of charge, to any person obtaining a
9*61046927SAndroid Build Coastguard Worker  * copy of this software and associated documentation files (the
10*61046927SAndroid Build Coastguard Worker  * "Software"), to deal in the Software without restriction, including
11*61046927SAndroid Build Coastguard Worker  * without limitation the rights to use, copy, modify, merge, publish,
12*61046927SAndroid Build Coastguard Worker  * distribute, sub license, and/or sell copies of the Software, and to
13*61046927SAndroid Build Coastguard Worker  * permit persons to whom the Software is furnished to do so, subject to
14*61046927SAndroid Build Coastguard Worker  * the following conditions:
15*61046927SAndroid Build Coastguard Worker  *
16*61046927SAndroid Build Coastguard Worker  * The above copyright notice and this permission notice (including the
17*61046927SAndroid Build Coastguard Worker  * next paragraph) shall be included in all copies or substantial portions
18*61046927SAndroid Build Coastguard Worker  * of the Software.
19*61046927SAndroid Build Coastguard Worker  *
20*61046927SAndroid Build Coastguard Worker  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21*61046927SAndroid Build Coastguard Worker  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22*61046927SAndroid Build Coastguard Worker  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
23*61046927SAndroid Build Coastguard Worker  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24*61046927SAndroid Build Coastguard Worker  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25*61046927SAndroid Build Coastguard Worker  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26*61046927SAndroid Build Coastguard Worker  * DEALINGS IN THE SOFTWARE.
27*61046927SAndroid Build Coastguard Worker  *
28*61046927SAndroid Build Coastguard Worker  **************************************************************************/
29*61046927SAndroid Build Coastguard Worker 
30*61046927SAndroid Build Coastguard Worker #ifndef EGLDRIVER_INCLUDED
31*61046927SAndroid Build Coastguard Worker #define EGLDRIVER_INCLUDED
32*61046927SAndroid Build Coastguard Worker 
33*61046927SAndroid Build Coastguard Worker #include <stdbool.h>
34*61046927SAndroid Build Coastguard Worker #include <stddef.h>
35*61046927SAndroid Build Coastguard Worker #include "egltypedefs.h"
36*61046927SAndroid Build Coastguard Worker 
37*61046927SAndroid Build Coastguard Worker #ifdef __cplusplus
38*61046927SAndroid Build Coastguard Worker extern "C" {
39*61046927SAndroid Build Coastguard Worker #endif
40*61046927SAndroid Build Coastguard Worker 
41*61046927SAndroid Build Coastguard Worker /**
42*61046927SAndroid Build Coastguard Worker  * Define an inline driver typecast function.
43*61046927SAndroid Build Coastguard Worker  *
44*61046927SAndroid Build Coastguard Worker  * Note that this macro defines a function and should not be ended with a
45*61046927SAndroid Build Coastguard Worker  * semicolon when used.
46*61046927SAndroid Build Coastguard Worker  */
47*61046927SAndroid Build Coastguard Worker #define _EGL_DRIVER_TYPECAST(drvtype, egltype, code)                           \
48*61046927SAndroid Build Coastguard Worker    static inline struct drvtype *drvtype(const egltype *obj)                   \
49*61046927SAndroid Build Coastguard Worker    {                                                                           \
50*61046927SAndroid Build Coastguard Worker       return (struct drvtype *)code;                                           \
51*61046927SAndroid Build Coastguard Worker    }
52*61046927SAndroid Build Coastguard Worker 
53*61046927SAndroid Build Coastguard Worker /**
54*61046927SAndroid Build Coastguard Worker  * Define the driver typecast functions for _EGLDisplay,
55*61046927SAndroid Build Coastguard Worker  * _EGLContext, _EGLSurface, and _EGLConfig.
56*61046927SAndroid Build Coastguard Worker  *
57*61046927SAndroid Build Coastguard Worker  * Note that this macro defines several functions and should not be ended with
58*61046927SAndroid Build Coastguard Worker  * a semicolon when used.
59*61046927SAndroid Build Coastguard Worker  */
60*61046927SAndroid Build Coastguard Worker #define _EGL_DRIVER_STANDARD_TYPECASTS(drvname)                                \
61*61046927SAndroid Build Coastguard Worker    /* note that this is not a direct cast */                                   \
62*61046927SAndroid Build Coastguard Worker    _EGL_DRIVER_TYPECAST(drvname##_display, _EGLDisplay, obj->DriverData)       \
63*61046927SAndroid Build Coastguard Worker    _EGL_DRIVER_TYPECAST(drvname##_context, _EGLContext, obj)                   \
64*61046927SAndroid Build Coastguard Worker    _EGL_DRIVER_TYPECAST(drvname##_surface, _EGLSurface, obj)                   \
65*61046927SAndroid Build Coastguard Worker    _EGL_DRIVER_TYPECAST(drvname##_config, _EGLConfig, obj)
66*61046927SAndroid Build Coastguard Worker 
67*61046927SAndroid Build Coastguard Worker /**
68*61046927SAndroid Build Coastguard Worker  * A generic function ptr type
69*61046927SAndroid Build Coastguard Worker  */
70*61046927SAndroid Build Coastguard Worker typedef void (*_EGLProc)(void);
71*61046927SAndroid Build Coastguard Worker 
72*61046927SAndroid Build Coastguard Worker struct wl_display;
73*61046927SAndroid Build Coastguard Worker struct mesa_glinterop_device_info;
74*61046927SAndroid Build Coastguard Worker struct mesa_glinterop_export_in;
75*61046927SAndroid Build Coastguard Worker struct mesa_glinterop_export_out;
76*61046927SAndroid Build Coastguard Worker struct mesa_glinterop_flush_out;
77*61046927SAndroid Build Coastguard Worker typedef struct __GLsync *GLsync;
78*61046927SAndroid Build Coastguard Worker 
79*61046927SAndroid Build Coastguard Worker /**
80*61046927SAndroid Build Coastguard Worker  * The API dispatcher jumps through these functions
81*61046927SAndroid Build Coastguard Worker  */
82*61046927SAndroid Build Coastguard Worker struct _egl_driver {
83*61046927SAndroid Build Coastguard Worker    /* driver funcs */
84*61046927SAndroid Build Coastguard Worker    EGLBoolean (*Initialize)(_EGLDisplay *disp);
85*61046927SAndroid Build Coastguard Worker    EGLBoolean (*Terminate)(_EGLDisplay *disp);
86*61046927SAndroid Build Coastguard Worker 
87*61046927SAndroid Build Coastguard Worker    /* context funcs */
88*61046927SAndroid Build Coastguard Worker    _EGLContext *(*CreateContext)(_EGLDisplay *disp, _EGLConfig *config,
89*61046927SAndroid Build Coastguard Worker                                  _EGLContext *share_list,
90*61046927SAndroid Build Coastguard Worker                                  const EGLint *attrib_list);
91*61046927SAndroid Build Coastguard Worker    EGLBoolean (*DestroyContext)(_EGLDisplay *disp, _EGLContext *ctx);
92*61046927SAndroid Build Coastguard Worker    /* this is the only function (other than Initialize) that may be called
93*61046927SAndroid Build Coastguard Worker     * with an uninitialized display
94*61046927SAndroid Build Coastguard Worker     */
95*61046927SAndroid Build Coastguard Worker    EGLBoolean (*MakeCurrent)(_EGLDisplay *disp, _EGLSurface *draw,
96*61046927SAndroid Build Coastguard Worker                              _EGLSurface *read, _EGLContext *ctx);
97*61046927SAndroid Build Coastguard Worker 
98*61046927SAndroid Build Coastguard Worker    /* surface funcs */
99*61046927SAndroid Build Coastguard Worker    _EGLSurface *(*CreateWindowSurface)(_EGLDisplay *disp, _EGLConfig *config,
100*61046927SAndroid Build Coastguard Worker                                        void *native_window,
101*61046927SAndroid Build Coastguard Worker                                        const EGLint *attrib_list);
102*61046927SAndroid Build Coastguard Worker    _EGLSurface *(*CreatePixmapSurface)(_EGLDisplay *disp, _EGLConfig *config,
103*61046927SAndroid Build Coastguard Worker                                        void *native_pixmap,
104*61046927SAndroid Build Coastguard Worker                                        const EGLint *attrib_list);
105*61046927SAndroid Build Coastguard Worker    _EGLSurface *(*CreatePbufferSurface)(_EGLDisplay *disp, _EGLConfig *config,
106*61046927SAndroid Build Coastguard Worker                                         const EGLint *attrib_list);
107*61046927SAndroid Build Coastguard Worker    EGLBoolean (*DestroySurface)(_EGLDisplay *disp, _EGLSurface *surface);
108*61046927SAndroid Build Coastguard Worker    EGLBoolean (*QuerySurface)(_EGLDisplay *disp, _EGLSurface *surface,
109*61046927SAndroid Build Coastguard Worker                               EGLint attribute, EGLint *value);
110*61046927SAndroid Build Coastguard Worker    EGLBoolean (*BindTexImage)(_EGLDisplay *disp, _EGLSurface *surface,
111*61046927SAndroid Build Coastguard Worker                               EGLint buffer);
112*61046927SAndroid Build Coastguard Worker    EGLBoolean (*ReleaseTexImage)(_EGLDisplay *disp, _EGLSurface *surface,
113*61046927SAndroid Build Coastguard Worker                                  EGLint buffer);
114*61046927SAndroid Build Coastguard Worker    EGLBoolean (*SwapInterval)(_EGLDisplay *disp, _EGLSurface *surf,
115*61046927SAndroid Build Coastguard Worker                               EGLint interval);
116*61046927SAndroid Build Coastguard Worker    EGLBoolean (*SwapBuffers)(_EGLDisplay *disp, _EGLSurface *draw);
117*61046927SAndroid Build Coastguard Worker    EGLBoolean (*CopyBuffers)(_EGLDisplay *disp, _EGLSurface *surface,
118*61046927SAndroid Build Coastguard Worker                              void *native_pixmap_target);
119*61046927SAndroid Build Coastguard Worker 
120*61046927SAndroid Build Coastguard Worker    /* for EGL_KHR_partial_update */
121*61046927SAndroid Build Coastguard Worker    EGLBoolean (*SetDamageRegion)(_EGLDisplay *disp, _EGLSurface *surface,
122*61046927SAndroid Build Coastguard Worker                                  EGLint *rects, EGLint n_rects);
123*61046927SAndroid Build Coastguard Worker 
124*61046927SAndroid Build Coastguard Worker    /* misc functions */
125*61046927SAndroid Build Coastguard Worker    EGLBoolean (*WaitClient)(_EGLDisplay *disp, _EGLContext *ctx);
126*61046927SAndroid Build Coastguard Worker    EGLBoolean (*WaitNative)(EGLint engine);
127*61046927SAndroid Build Coastguard Worker 
128*61046927SAndroid Build Coastguard Worker    /* for EGL_KHR_image_base */
129*61046927SAndroid Build Coastguard Worker    _EGLImage *(*CreateImageKHR)(_EGLDisplay *disp, _EGLContext *ctx,
130*61046927SAndroid Build Coastguard Worker                                 EGLenum target, EGLClientBuffer buffer,
131*61046927SAndroid Build Coastguard Worker                                 const EGLint *attr_list);
132*61046927SAndroid Build Coastguard Worker    EGLBoolean (*DestroyImageKHR)(_EGLDisplay *disp, _EGLImage *image);
133*61046927SAndroid Build Coastguard Worker 
134*61046927SAndroid Build Coastguard Worker    /* for EGL_KHR_reusable_sync/EGL_KHR_fence_sync */
135*61046927SAndroid Build Coastguard Worker    _EGLSync *(*CreateSyncKHR)(_EGLDisplay *disp, EGLenum type,
136*61046927SAndroid Build Coastguard Worker                               const EGLAttrib *attrib_list);
137*61046927SAndroid Build Coastguard Worker    EGLBoolean (*DestroySyncKHR)(_EGLDisplay *disp, _EGLSync *sync);
138*61046927SAndroid Build Coastguard Worker    EGLint (*ClientWaitSyncKHR)(_EGLDisplay *disp, _EGLSync *sync, EGLint flags,
139*61046927SAndroid Build Coastguard Worker                                EGLTime timeout);
140*61046927SAndroid Build Coastguard Worker    EGLint (*WaitSyncKHR)(_EGLDisplay *disp, _EGLSync *sync);
141*61046927SAndroid Build Coastguard Worker    /* for EGL_KHR_reusable_sync */
142*61046927SAndroid Build Coastguard Worker    EGLBoolean (*SignalSyncKHR)(_EGLDisplay *disp, _EGLSync *sync, EGLenum mode);
143*61046927SAndroid Build Coastguard Worker 
144*61046927SAndroid Build Coastguard Worker    /* for EGL_ANDROID_native_fence_sync */
145*61046927SAndroid Build Coastguard Worker    EGLint (*DupNativeFenceFDANDROID)(_EGLDisplay *disp, _EGLSync *sync);
146*61046927SAndroid Build Coastguard Worker 
147*61046927SAndroid Build Coastguard Worker    /* for EGL_NOK_swap_region */
148*61046927SAndroid Build Coastguard Worker    EGLBoolean (*SwapBuffersRegionNOK)(_EGLDisplay *disp, _EGLSurface *surf,
149*61046927SAndroid Build Coastguard Worker                                       EGLint numRects, const EGLint *rects);
150*61046927SAndroid Build Coastguard Worker 
151*61046927SAndroid Build Coastguard Worker    /* for EGL_MESA_drm_image */
152*61046927SAndroid Build Coastguard Worker    _EGLImage *(*CreateDRMImageMESA)(_EGLDisplay *disp, const EGLint *attr_list);
153*61046927SAndroid Build Coastguard Worker    EGLBoolean (*ExportDRMImageMESA)(_EGLDisplay *disp, _EGLImage *img,
154*61046927SAndroid Build Coastguard Worker                                     EGLint *name, EGLint *handle,
155*61046927SAndroid Build Coastguard Worker                                     EGLint *stride);
156*61046927SAndroid Build Coastguard Worker 
157*61046927SAndroid Build Coastguard Worker    /* for EGL_WL_bind_wayland_display */
158*61046927SAndroid Build Coastguard Worker    EGLBoolean (*BindWaylandDisplayWL)(_EGLDisplay *disp,
159*61046927SAndroid Build Coastguard Worker                                       struct wl_display *display);
160*61046927SAndroid Build Coastguard Worker    EGLBoolean (*UnbindWaylandDisplayWL)(_EGLDisplay *disp,
161*61046927SAndroid Build Coastguard Worker                                         struct wl_display *display);
162*61046927SAndroid Build Coastguard Worker    EGLBoolean (*QueryWaylandBufferWL)(_EGLDisplay *displ,
163*61046927SAndroid Build Coastguard Worker                                       struct wl_resource *buffer,
164*61046927SAndroid Build Coastguard Worker                                       EGLint attribute, EGLint *value);
165*61046927SAndroid Build Coastguard Worker 
166*61046927SAndroid Build Coastguard Worker    /* for EGL_WL_create_wayland_buffer_from_image */
167*61046927SAndroid Build Coastguard Worker    struct wl_buffer *(*CreateWaylandBufferFromImageWL)(_EGLDisplay *disp,
168*61046927SAndroid Build Coastguard Worker                                                        _EGLImage *img);
169*61046927SAndroid Build Coastguard Worker 
170*61046927SAndroid Build Coastguard Worker    /* for EGL_EXT_swap_buffers_with_damage */
171*61046927SAndroid Build Coastguard Worker    EGLBoolean (*SwapBuffersWithDamageEXT)(_EGLDisplay *disp,
172*61046927SAndroid Build Coastguard Worker                                           _EGLSurface *surface,
173*61046927SAndroid Build Coastguard Worker                                           const EGLint *rects, EGLint n_rects);
174*61046927SAndroid Build Coastguard Worker 
175*61046927SAndroid Build Coastguard Worker    /* for EGL_NV_post_sub_buffer */
176*61046927SAndroid Build Coastguard Worker    EGLBoolean (*PostSubBufferNV)(_EGLDisplay *disp, _EGLSurface *surface,
177*61046927SAndroid Build Coastguard Worker                                  EGLint x, EGLint y, EGLint width,
178*61046927SAndroid Build Coastguard Worker                                  EGLint height);
179*61046927SAndroid Build Coastguard Worker 
180*61046927SAndroid Build Coastguard Worker    /* for EGL_EXT_buffer_age/EGL_KHR_partial_update */
181*61046927SAndroid Build Coastguard Worker    EGLint (*QueryBufferAge)(_EGLDisplay *disp, _EGLSurface *surface);
182*61046927SAndroid Build Coastguard Worker 
183*61046927SAndroid Build Coastguard Worker    /* for EGL_CHROMIUM_sync_control */
184*61046927SAndroid Build Coastguard Worker    EGLBoolean (*GetSyncValuesCHROMIUM)(_EGLDisplay *disp, _EGLSurface *surface,
185*61046927SAndroid Build Coastguard Worker                                        EGLuint64KHR *ust, EGLuint64KHR *msc,
186*61046927SAndroid Build Coastguard Worker                                        EGLuint64KHR *sbc);
187*61046927SAndroid Build Coastguard Worker 
188*61046927SAndroid Build Coastguard Worker    EGLBoolean (*GetMscRateANGLE)(_EGLDisplay *disp, _EGLSurface *surface,
189*61046927SAndroid Build Coastguard Worker                                  EGLint *numerator, EGLint *denominator);
190*61046927SAndroid Build Coastguard Worker 
191*61046927SAndroid Build Coastguard Worker    /* for EGL_MESA_image_dma_buf_export */
192*61046927SAndroid Build Coastguard Worker    EGLBoolean (*ExportDMABUFImageQueryMESA)(_EGLDisplay *disp, _EGLImage *img,
193*61046927SAndroid Build Coastguard Worker                                             EGLint *fourcc, EGLint *nplanes,
194*61046927SAndroid Build Coastguard Worker                                             EGLuint64KHR *modifiers);
195*61046927SAndroid Build Coastguard Worker    EGLBoolean (*ExportDMABUFImageMESA)(_EGLDisplay *disp, _EGLImage *img,
196*61046927SAndroid Build Coastguard Worker                                        EGLint *fds, EGLint *strides,
197*61046927SAndroid Build Coastguard Worker                                        EGLint *offsets);
198*61046927SAndroid Build Coastguard Worker 
199*61046927SAndroid Build Coastguard Worker    /* for EGL_MESA_query_driver */
200*61046927SAndroid Build Coastguard Worker    const char *(*QueryDriverName)(_EGLDisplay *disp);
201*61046927SAndroid Build Coastguard Worker    char *(*QueryDriverConfig)(_EGLDisplay *disp);
202*61046927SAndroid Build Coastguard Worker 
203*61046927SAndroid Build Coastguard Worker    /* for OpenGL-OpenCL interop; see include/GL/mesa_glinterop.h */
204*61046927SAndroid Build Coastguard Worker    int (*GLInteropQueryDeviceInfo)(_EGLDisplay *disp, _EGLContext *ctx,
205*61046927SAndroid Build Coastguard Worker                                    struct mesa_glinterop_device_info *out);
206*61046927SAndroid Build Coastguard Worker    int (*GLInteropExportObject)(_EGLDisplay *disp, _EGLContext *ctx,
207*61046927SAndroid Build Coastguard Worker                                 struct mesa_glinterop_export_in *in,
208*61046927SAndroid Build Coastguard Worker                                 struct mesa_glinterop_export_out *out);
209*61046927SAndroid Build Coastguard Worker    int (*GLInteropFlushObjects)(_EGLDisplay *disp, _EGLContext *ctx,
210*61046927SAndroid Build Coastguard Worker                                 unsigned count,
211*61046927SAndroid Build Coastguard Worker                                 struct mesa_glinterop_export_in *in,
212*61046927SAndroid Build Coastguard Worker                                 struct mesa_glinterop_flush_out *out);
213*61046927SAndroid Build Coastguard Worker 
214*61046927SAndroid Build Coastguard Worker    /* for EGL_EXT_image_dma_buf_import_modifiers */
215*61046927SAndroid Build Coastguard Worker    EGLBoolean (*QueryDmaBufFormatsEXT)(_EGLDisplay *disp, EGLint max_formats,
216*61046927SAndroid Build Coastguard Worker                                        EGLint *formats, EGLint *num_formats);
217*61046927SAndroid Build Coastguard Worker    EGLBoolean (*QueryDmaBufModifiersEXT)(_EGLDisplay *disp, EGLint format,
218*61046927SAndroid Build Coastguard Worker                                          EGLint max_modifiers,
219*61046927SAndroid Build Coastguard Worker                                          EGLuint64KHR *modifiers,
220*61046927SAndroid Build Coastguard Worker                                          EGLBoolean *external_only,
221*61046927SAndroid Build Coastguard Worker                                          EGLint *num_modifiers);
222*61046927SAndroid Build Coastguard Worker 
223*61046927SAndroid Build Coastguard Worker    /* for EGL_ANDROID_blob_cache */
224*61046927SAndroid Build Coastguard Worker    void (*SetBlobCacheFuncsANDROID)(_EGLDisplay *disp,
225*61046927SAndroid Build Coastguard Worker                                     EGLSetBlobFuncANDROID set,
226*61046927SAndroid Build Coastguard Worker                                     EGLGetBlobFuncANDROID get);
227*61046927SAndroid Build Coastguard Worker 
228*61046927SAndroid Build Coastguard Worker    /* for EGL_EXT_surface_compression */
229*61046927SAndroid Build Coastguard Worker    EGLBoolean (*QuerySupportedCompressionRatesEXT)(_EGLDisplay *disp,
230*61046927SAndroid Build Coastguard Worker                                                    _EGLConfig *config,
231*61046927SAndroid Build Coastguard Worker                                                    const EGLAttrib *attr_list,
232*61046927SAndroid Build Coastguard Worker                                                    EGLint *rates,
233*61046927SAndroid Build Coastguard Worker                                                    EGLint rate_size,
234*61046927SAndroid Build Coastguard Worker                                                    EGLint *num_rates);
235*61046927SAndroid Build Coastguard Worker };
236*61046927SAndroid Build Coastguard Worker 
237*61046927SAndroid Build Coastguard Worker #ifdef __cplusplus
238*61046927SAndroid Build Coastguard Worker }
239*61046927SAndroid Build Coastguard Worker #endif
240*61046927SAndroid Build Coastguard Worker 
241*61046927SAndroid Build Coastguard Worker #endif /* EGLDRIVER_INCLUDED */
242