Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2011 Intel Corporation |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice (including the next |
| 12 | * paragraph) shall be included in all copies or substantial portions of the |
| 13 | * Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
| 19 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
| 20 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 | * DEALINGS IN THE SOFTWARE. |
| 23 | * |
| 24 | * Authors: |
| 25 | * Kristian Høgsberg <krh@bitplanet.net> |
| 26 | */ |
| 27 | |
| 28 | #ifndef EGL_DRI2_INCLUDED |
| 29 | #define EGL_DRI2_INCLUDED |
| 30 | |
Eric Engestrom | 60f9842 | 2017-06-19 00:16:21 +0100 | [diff] [blame] | 31 | #include <stdbool.h> |
Emil Velikov | bf0e4d2 | 2015-02-28 17:12:40 +0000 | [diff] [blame] | 32 | #include <stdint.h> |
| 33 | |
Kristian Høgsberg | 93aea63 | 2011-05-11 13:58:37 -0400 | [diff] [blame] | 34 | #ifdef HAVE_X11_PLATFORM |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 35 | #include <xcb/xcb.h> |
| 36 | #include <xcb/dri2.h> |
| 37 | #include <xcb/xfixes.h> |
| 38 | #include <X11/Xlib-xcb.h> |
Boyan Ding | f35198b | 2015-07-21 23:44:00 +0800 | [diff] [blame] | 39 | |
| 40 | #ifdef HAVE_DRI3 |
| 41 | #include "loader_dri3_helper.h" |
| 42 | #endif |
Kristian Høgsberg | 93aea63 | 2011-05-11 13:58:37 -0400 | [diff] [blame] | 43 | #endif |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 44 | |
Benjamin Franzke | 93aea84 | 2011-02-04 12:39:40 +0100 | [diff] [blame] | 45 | #ifdef HAVE_WAYLAND_PLATFORM |
Emil Velikov | 9fa1d82 | 2018-03-14 17:31:27 +0000 | [diff] [blame] | 46 | /* forward declarations to avoid pulling wayland headers everywhere */ |
| 47 | struct wl_egl_window; |
| 48 | struct wl_event_queue; |
| 49 | struct wl_callback; |
| 50 | struct wl_display; |
| 51 | struct wl_drm; |
| 52 | struct wl_registry; |
| 53 | struct wl_shm; |
| 54 | struct wl_surface; |
Daniel Stone | 02cc359 | 2017-06-16 18:01:23 +0100 | [diff] [blame] | 55 | struct zwp_linux_dmabuf_v1; |
Benjamin Franzke | 93aea84 | 2011-02-04 12:39:40 +0100 | [diff] [blame] | 56 | #endif |
| 57 | |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 58 | #include <GL/gl.h> |
| 59 | #include <GL/internal/dri_interface.h> |
| 60 | |
Benjamin Franzke | b2d6375 | 2011-07-02 13:41:35 +0200 | [diff] [blame] | 61 | #ifdef HAVE_DRM_PLATFORM |
Benjamin Franzke | e5fc4c8 | 2011-05-30 10:50:52 +0200 | [diff] [blame] | 62 | #include <gbm_driint.h> |
Benjamin Franzke | b2d6375 | 2011-07-02 13:41:35 +0200 | [diff] [blame] | 63 | #endif |
Benjamin Franzke | e5fc4c8 | 2011-05-30 10:50:52 +0200 | [diff] [blame] | 64 | |
Chia-I Wu | 9779f6f | 2011-08-05 14:39:18 +0900 | [diff] [blame] | 65 | #ifdef HAVE_ANDROID_PLATFORM |
| 66 | #define LOG_TAG "EGL-DRI2" |
Chia-I Wu | 75cc24c | 2011-11-25 11:59:02 +0800 | [diff] [blame] | 67 | |
Rob Herring | 0e1ff22 | 2017-03-21 13:51:19 -0500 | [diff] [blame] | 68 | #include <system/window.h> |
Chia-I Wu | 75cc24c | 2011-11-25 11:59:02 +0800 | [diff] [blame] | 69 | #include <hardware/gralloc.h> |
Chia-I Wu | 75cc24c | 2011-11-25 11:59:02 +0800 | [diff] [blame] | 70 | #endif /* HAVE_ANDROID_PLATFORM */ |
| 71 | |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 72 | #include "eglconfig.h" |
| 73 | #include "eglcontext.h" |
Emil Velikov | 0099270 | 2018-09-04 11:20:03 +0100 | [diff] [blame] | 74 | #include "egldevice.h" |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 75 | #include "egldisplay.h" |
| 76 | #include "egldriver.h" |
| 77 | #include "eglcurrent.h" |
| 78 | #include "egllog.h" |
| 79 | #include "eglsurface.h" |
| 80 | #include "eglimage.h" |
Marek Olšák | 9a0bda2 | 2015-04-10 10:56:02 +0200 | [diff] [blame] | 81 | #include "eglsync.h" |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 82 | |
Daniel Stone | 02cc359 | 2017-06-16 18:01:23 +0100 | [diff] [blame] | 83 | #include "util/u_vector.h" |
Eric Engestrom | fbf7c38 | 2018-11-27 12:27:45 +0000 | [diff] [blame] | 84 | #include "util/bitset.h" |
| 85 | |
| 86 | #define EGL_DRI2_MAX_FORMATS 8 |
Daniel Stone | 02cc359 | 2017-06-16 18:01:23 +0100 | [diff] [blame] | 87 | |
Chad Versace | eadd5e0 | 2014-01-28 17:03:03 -0800 | [diff] [blame] | 88 | struct wl_buffer; |
| 89 | |
Chad Versace | 90502b1 | 2014-01-28 11:41:46 -0800 | [diff] [blame] | 90 | struct dri2_egl_display_vtbl { |
| 91 | int (*authenticate)(_EGLDisplay *disp, uint32_t id); |
Chad Versace | 8b9298a | 2014-01-28 12:34:19 -0800 | [diff] [blame] | 92 | |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 93 | _EGLSurface* (*create_window_surface)(_EGLDriver *drv, _EGLDisplay *disp, |
Chad Versace | 0a0c881 | 2014-01-28 16:39:09 -0800 | [diff] [blame] | 94 | _EGLConfig *config, |
Chad Versace | 6d1f83e | 2014-01-07 14:54:51 -0800 | [diff] [blame] | 95 | void *native_window, |
Chad Versace | 0a0c881 | 2014-01-28 16:39:09 -0800 | [diff] [blame] | 96 | const EGLint *attrib_list); |
| 97 | |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 98 | _EGLSurface* (*create_pixmap_surface)(_EGLDriver *drv, _EGLDisplay *disp, |
Chad Versace | bc8b07a | 2014-01-28 16:45:07 -0800 | [diff] [blame] | 99 | _EGLConfig *config, |
Chad Versace | 6d1f83e | 2014-01-07 14:54:51 -0800 | [diff] [blame] | 100 | void *native_pixmap, |
Chad Versace | bc8b07a | 2014-01-28 16:45:07 -0800 | [diff] [blame] | 101 | const EGLint *attrib_list); |
| 102 | |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 103 | _EGLSurface* (*create_pbuffer_surface)(_EGLDriver *drv, _EGLDisplay *disp, |
Chad Versace | bf20076 | 2014-01-28 17:03:03 -0800 | [diff] [blame] | 104 | _EGLConfig *config, |
| 105 | const EGLint *attrib_list); |
| 106 | |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 107 | EGLBoolean (*destroy_surface)(_EGLDriver *drv, _EGLDisplay *disp, |
Chad Versace | 958dd80 | 2014-01-28 17:03:03 -0800 | [diff] [blame] | 108 | _EGLSurface *surface); |
| 109 | |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 110 | EGLBoolean (*swap_interval)(_EGLDriver *drv, _EGLDisplay *disp, |
Chad Versace | 8b9298a | 2014-01-28 12:34:19 -0800 | [diff] [blame] | 111 | _EGLSurface *surf, EGLint interval); |
Chad Versace | ad173bc | 2014-01-28 16:21:21 -0800 | [diff] [blame] | 112 | |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 113 | _EGLImage* (*create_image)(_EGLDriver *drv, _EGLDisplay *disp, |
Chad Versace | eef68a9 | 2014-01-28 17:03:03 -0800 | [diff] [blame] | 114 | _EGLContext *ctx, EGLenum target, |
| 115 | EGLClientBuffer buffer, |
| 116 | const EGLint *attr_list); |
| 117 | |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 118 | EGLBoolean (*swap_buffers)(_EGLDriver *drv, _EGLDisplay *disp, |
Chad Versace | ad173bc | 2014-01-28 16:21:21 -0800 | [diff] [blame] | 119 | _EGLSurface *surf); |
Chad Versace | d03948a | 2014-01-28 16:26:44 -0800 | [diff] [blame] | 120 | |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 121 | EGLBoolean (*swap_buffers_with_damage)(_EGLDriver *drv, _EGLDisplay *disp, |
Boyan Ding | 052b3d4 | 2015-06-13 15:36:27 +0800 | [diff] [blame] | 122 | _EGLSurface *surface, |
| 123 | const EGLint *rects, EGLint n_rects); |
Chad Versace | 3fdfbd2 | 2014-01-28 17:03:03 -0800 | [diff] [blame] | 124 | |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 125 | EGLBoolean (*swap_buffers_region)(_EGLDriver *drv, _EGLDisplay *disp, |
Chad Versace | 75d398e | 2014-01-28 17:03:03 -0800 | [diff] [blame] | 126 | _EGLSurface *surf, EGLint numRects, |
| 127 | const EGLint *rects); |
| 128 | |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 129 | EGLBoolean (*post_sub_buffer)(_EGLDriver *drv, _EGLDisplay *disp, |
Chad Versace | 688a0e8 | 2014-01-28 17:03:03 -0800 | [diff] [blame] | 130 | _EGLSurface *surf, |
| 131 | EGLint x, EGLint y, |
| 132 | EGLint width, EGLint height); |
| 133 | |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 134 | EGLBoolean (*copy_buffers)(_EGLDriver *drv, _EGLDisplay *disp, |
Chad Versace | 6d1f83e | 2014-01-07 14:54:51 -0800 | [diff] [blame] | 135 | _EGLSurface *surf, void *native_pixmap_target); |
Chad Versace | bc2cbc0 | 2014-01-28 17:03:03 -0800 | [diff] [blame] | 136 | |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 137 | EGLint (*query_buffer_age)(_EGLDriver *drv, _EGLDisplay *disp, |
Chad Versace | 3fdfbd2 | 2014-01-28 17:03:03 -0800 | [diff] [blame] | 138 | _EGLSurface *surf); |
Chad Versace | eadd5e0 | 2014-01-28 17:03:03 -0800 | [diff] [blame] | 139 | |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 140 | EGLBoolean (*query_surface)(_EGLDriver *drv, _EGLDisplay *disp, |
Haixia Shi | a7c6993 | 2016-07-28 10:51:12 -0700 | [diff] [blame] | 141 | _EGLSurface *surf, EGLint attribute, |
| 142 | EGLint *value); |
| 143 | |
Chad Versace | eadd5e0 | 2014-01-28 17:03:03 -0800 | [diff] [blame] | 144 | struct wl_buffer* (*create_wayland_buffer_from_image)( |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 145 | _EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img); |
Sarah Sharp | c524f3e | 2014-05-06 12:10:57 -0700 | [diff] [blame] | 146 | |
| 147 | EGLBoolean (*get_sync_values)(_EGLDisplay *display, _EGLSurface *surface, |
| 148 | EGLuint64KHR *ust, EGLuint64KHR *msc, |
| 149 | EGLuint64KHR *sbc); |
Boyan Ding | a25df54 | 2015-07-21 23:43:59 +0800 | [diff] [blame] | 150 | |
| 151 | __DRIdrawable *(*get_dri_drawable)(_EGLSurface *surf); |
Thomas Hellstrom | 2db9548 | 2017-08-10 15:35:39 +0200 | [diff] [blame] | 152 | |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 153 | void (*close_screen_notify)(_EGLDisplay *disp); |
Chad Versace | ed7c694 | 2018-04-30 22:35:17 -0700 | [diff] [blame] | 154 | |
| 155 | /* Used in EGL_KHR_mutable_render_buffer to update the native window's |
| 156 | * shared buffer mode. |
| 157 | */ |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 158 | bool (*set_shared_buffer_mode)(_EGLDisplay *disp, _EGLSurface *surf, |
Chad Versace | ed7c694 | 2018-04-30 22:35:17 -0700 | [diff] [blame] | 159 | bool mode); |
Chad Versace | 90502b1 | 2014-01-28 11:41:46 -0800 | [diff] [blame] | 160 | }; |
| 161 | |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 162 | struct dri2_egl_display |
| 163 | { |
Chad Versace | 90502b1 | 2014-01-28 11:41:46 -0800 | [diff] [blame] | 164 | const struct dri2_egl_display_vtbl *vtbl; |
| 165 | |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 166 | int dri2_major; |
| 167 | int dri2_minor; |
| 168 | __DRIscreen *dri_screen; |
Eric Engestrom | 60f9842 | 2017-06-19 00:16:21 +0100 | [diff] [blame] | 169 | bool own_dri_screen; |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 170 | const __DRIconfig **driver_configs; |
| 171 | void *driver; |
Emil Velikov | 5f280d0 | 2014-02-12 20:13:15 +0000 | [diff] [blame] | 172 | const __DRIcoreExtension *core; |
Boyan Ding | f35198b | 2015-07-21 23:44:00 +0800 | [diff] [blame] | 173 | const __DRIimageDriverExtension *image_driver; |
Emil Velikov | 5f280d0 | 2014-02-12 20:13:15 +0000 | [diff] [blame] | 174 | const __DRIdri2Extension *dri2; |
| 175 | const __DRIswrastExtension *swrast; |
| 176 | const __DRI2flushExtension *flush; |
Adam Jackson | c0be3aa | 2016-09-22 03:47:55 -0400 | [diff] [blame] | 177 | const __DRI2flushControlExtension *flush_control; |
Emil Velikov | 5f280d0 | 2014-02-12 20:13:15 +0000 | [diff] [blame] | 178 | const __DRItexBufferExtension *tex_buffer; |
| 179 | const __DRIimageExtension *image; |
| 180 | const __DRIrobustnessExtension *robustness; |
Grigori Goronzy | 4909519 | 2017-06-29 02:44:03 +0200 | [diff] [blame] | 181 | const __DRInoErrorExtension *no_error; |
Emil Velikov | 5f280d0 | 2014-02-12 20:13:15 +0000 | [diff] [blame] | 182 | const __DRI2configQueryExtension *config; |
Marek Olšák | 9a0bda2 | 2015-04-10 10:56:02 +0200 | [diff] [blame] | 183 | const __DRI2fenceExtension *fence; |
Harish Krupo | a4a8ebe | 2019-08-12 12:07:06 +0200 | [diff] [blame] | 184 | const __DRI2bufferDamageExtension *buffer_damage; |
Tapani Pälli | 6f5b570 | 2017-12-28 10:51:11 +0200 | [diff] [blame] | 185 | const __DRI2blobExtension *blob; |
Marek Olšák | 4f57ccd | 2015-06-10 14:45:58 +0200 | [diff] [blame] | 186 | const __DRI2rendererQueryExtension *rendererQuery; |
Marek Olšák | b6eda70 | 2016-03-03 15:59:48 +0100 | [diff] [blame] | 187 | const __DRI2interopExtension *interop; |
Veluri Mithun | 85edfc0 | 2019-01-23 22:45:42 +0530 | [diff] [blame] | 188 | const __DRIconfigOptionsExtension *configOptions; |
Chad Versace | ed7c694 | 2018-04-30 22:35:17 -0700 | [diff] [blame] | 189 | const __DRImutableRenderBufferDriverExtension *mutable_render_buffer; |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 190 | int fd; |
| 191 | |
Nicolas Boichat | 9ee683f | 2016-07-22 11:27:41 +0800 | [diff] [blame] | 192 | /* dri2_initialize/dri2_terminate increment/decrement this count, so does |
| 193 | * dri2_make_current (tracks if there are active contexts/surfaces). */ |
| 194 | int ref_count; |
| 195 | |
Eric Engestrom | 60f9842 | 2017-06-19 00:16:21 +0100 | [diff] [blame] | 196 | bool own_device; |
| 197 | bool invalidate_available; |
Eric Anholt | 7e9bd2b | 2012-09-25 14:05:30 -0700 | [diff] [blame] | 198 | int min_swap_interval; |
| 199 | int max_swap_interval; |
| 200 | int default_swap_interval; |
Benjamin Franzke | b2d6375 | 2011-07-02 13:41:35 +0200 | [diff] [blame] | 201 | #ifdef HAVE_DRM_PLATFORM |
Benjamin Franzke | e5fc4c8 | 2011-05-30 10:50:52 +0200 | [diff] [blame] | 202 | struct gbm_dri_device *gbm_dri; |
Benjamin Franzke | b2d6375 | 2011-07-02 13:41:35 +0200 | [diff] [blame] | 203 | #endif |
Benjamin Franzke | e5fc4c8 | 2011-05-30 10:50:52 +0200 | [diff] [blame] | 204 | |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 205 | char *driver_name; |
| 206 | |
Emil Velikov | f871946 | 2016-08-24 23:32:27 +0100 | [diff] [blame] | 207 | const __DRIextension **loader_extensions; |
Eric Anholt | f93533d | 2013-09-27 11:39:25 -0700 | [diff] [blame] | 208 | const __DRIextension **driver_extensions; |
Kristian Høgsberg | 93aea63 | 2011-05-11 13:58:37 -0400 | [diff] [blame] | 209 | |
| 210 | #ifdef HAVE_X11_PLATFORM |
| 211 | xcb_connection_t *conn; |
Emil Velikov | 7c6babb | 2016-11-21 13:46:51 +0000 | [diff] [blame] | 212 | xcb_screen_t *screen; |
Eric Engestrom | 60f9842 | 2017-06-19 00:16:21 +0100 | [diff] [blame] | 213 | bool swap_available; |
Boyan Ding | f35198b | 2015-07-21 23:44:00 +0800 | [diff] [blame] | 214 | #ifdef HAVE_DRI3 |
Louis-Francis Ratté-Boulianne | 069fdd5 | 2017-07-07 02:54:26 -0400 | [diff] [blame] | 215 | bool multibuffers_available; |
| 216 | int dri3_major_version; |
| 217 | int dri3_minor_version; |
Louis-Francis Ratté-Boulianne | 3160cb8 | 2017-10-06 01:26:51 -0400 | [diff] [blame] | 218 | int present_major_version; |
| 219 | int present_minor_version; |
Boyan Ding | f35198b | 2015-07-21 23:44:00 +0800 | [diff] [blame] | 220 | struct loader_dri3_extensions loader_dri3_ext; |
| 221 | #endif |
Kristian Høgsberg | 93aea63 | 2011-05-11 13:58:37 -0400 | [diff] [blame] | 222 | #endif |
| 223 | |
Benjamin Franzke | 93aea84 | 2011-02-04 12:39:40 +0100 | [diff] [blame] | 224 | #ifdef HAVE_WAYLAND_PLATFORM |
Kristian Høgsberg | c0f8c99 | 2011-04-14 10:42:41 -0400 | [diff] [blame] | 225 | struct wl_display *wl_dpy; |
Jonas Ådahl | 36b9976 | 2017-01-13 23:05:10 +0800 | [diff] [blame] | 226 | struct wl_display *wl_dpy_wrapper; |
Kristian Høgsberg | 0229e3a | 2012-10-10 22:10:42 -0400 | [diff] [blame] | 227 | struct wl_registry *wl_registry; |
Benjamin Franzke | 6b369c4 | 2011-02-21 16:22:34 +0100 | [diff] [blame] | 228 | struct wl_drm *wl_server_drm; |
Kristian Høgsberg | c0f8c99 | 2011-04-14 10:42:41 -0400 | [diff] [blame] | 229 | struct wl_drm *wl_drm; |
Axel Davy | cdcfe48 | 2015-05-01 11:11:20 +0200 | [diff] [blame] | 230 | struct wl_shm *wl_shm; |
Kristian Høgsberg | 0229e3a | 2012-10-10 22:10:42 -0400 | [diff] [blame] | 231 | struct wl_event_queue *wl_queue; |
Daniel Stone | 02cc359 | 2017-06-16 18:01:23 +0100 | [diff] [blame] | 232 | struct zwp_linux_dmabuf_v1 *wl_dmabuf; |
Daniel Stone | 4732094 | 2018-02-06 10:29:13 +0000 | [diff] [blame] | 233 | struct u_vector *wl_modifiers; |
Eric Engestrom | 60f9842 | 2017-06-19 00:16:21 +0100 | [diff] [blame] | 234 | bool authenticated; |
Eric Engestrom | fbf7c38 | 2018-11-27 12:27:45 +0000 | [diff] [blame] | 235 | BITSET_DECLARE(formats, EGL_DRI2_MAX_FORMATS); |
Kristian Høgsberg | de315f7 | 2013-02-02 12:26:12 -0500 | [diff] [blame] | 236 | uint32_t capabilities; |
Frank Binns | d6f669b | 2016-06-17 18:41:22 +0100 | [diff] [blame] | 237 | char *device_name; |
Benjamin Franzke | 93aea84 | 2011-02-04 12:39:40 +0100 | [diff] [blame] | 238 | #endif |
Boyan Ding | f35198b | 2015-07-21 23:44:00 +0800 | [diff] [blame] | 239 | |
Tomasz Figa | 859d0b0 | 2016-11-10 16:55:52 +0900 | [diff] [blame] | 240 | #ifdef HAVE_ANDROID_PLATFORM |
| 241 | const gralloc_module_t *gralloc; |
| 242 | #endif |
| 243 | |
Eric Engestrom | 60f9842 | 2017-06-19 00:16:21 +0100 | [diff] [blame] | 244 | bool is_render_node; |
Eric Engestrom | 4a1238a | 2017-06-19 00:16:51 +0100 | [diff] [blame] | 245 | bool is_different_gpu; |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 246 | }; |
| 247 | |
| 248 | struct dri2_egl_context |
| 249 | { |
| 250 | _EGLContext base; |
| 251 | __DRIcontext *dri_context; |
| 252 | }; |
| 253 | |
Benjamin Franzke | 93aea84 | 2011-02-04 12:39:40 +0100 | [diff] [blame] | 254 | #ifdef HAVE_WAYLAND_PLATFORM |
| 255 | enum wayland_buffer_type { |
| 256 | WL_BUFFER_FRONT, |
| 257 | WL_BUFFER_BACK, |
Benjamin Franzke | 0cb356d | 2011-05-06 19:13:29 +0200 | [diff] [blame] | 258 | WL_BUFFER_THIRD, |
Benjamin Franzke | 93aea84 | 2011-02-04 12:39:40 +0100 | [diff] [blame] | 259 | WL_BUFFER_COUNT |
| 260 | }; |
Benjamin Franzke | 93aea84 | 2011-02-04 12:39:40 +0100 | [diff] [blame] | 261 | #endif |
| 262 | |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 263 | struct dri2_egl_surface |
| 264 | { |
| 265 | _EGLSurface base; |
| 266 | __DRIdrawable *dri_drawable; |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 267 | __DRIbuffer buffers[5]; |
Eric Engestrom | 60f9842 | 2017-06-19 00:16:21 +0100 | [diff] [blame] | 268 | bool have_fake_front; |
Haitao Feng | f55d027 | 2011-02-16 23:05:15 -0500 | [diff] [blame] | 269 | |
Kristian Høgsberg | 93aea63 | 2011-05-11 13:58:37 -0400 | [diff] [blame] | 270 | #ifdef HAVE_X11_PLATFORM |
| 271 | xcb_drawable_t drawable; |
| 272 | xcb_xfixes_region_t region; |
Haitao Feng | f55d027 | 2011-02-16 23:05:15 -0500 | [diff] [blame] | 273 | int depth; |
| 274 | int bytes_per_pixel; |
| 275 | xcb_gcontext_t gc; |
| 276 | xcb_gcontext_t swapgc; |
Kristian Høgsberg | 93aea63 | 2011-05-11 13:58:37 -0400 | [diff] [blame] | 277 | #endif |
Haitao Feng | f55d027 | 2011-02-16 23:05:15 -0500 | [diff] [blame] | 278 | |
Benjamin Franzke | 93aea84 | 2011-02-04 12:39:40 +0100 | [diff] [blame] | 279 | #ifdef HAVE_WAYLAND_PLATFORM |
| 280 | struct wl_egl_window *wl_win; |
Benjamin Franzke | 93aea84 | 2011-02-04 12:39:40 +0100 | [diff] [blame] | 281 | int dx; |
| 282 | int dy; |
Daniel Stone | 03dd9a8 | 2017-05-05 14:49:09 +0100 | [diff] [blame] | 283 | struct wl_event_queue *wl_queue; |
| 284 | struct wl_surface *wl_surface_wrapper; |
| 285 | struct wl_display *wl_dpy_wrapper; |
| 286 | struct wl_drm *wl_drm_wrapper; |
Neil Roberts | 992a2db | 2013-11-15 13:50:50 +0000 | [diff] [blame] | 287 | struct wl_callback *throttle_callback; |
Emil Velikov | ebc68e3 | 2016-08-25 00:12:13 +0100 | [diff] [blame] | 288 | int format; |
Benjamin Franzke | 93aea84 | 2011-02-04 12:39:40 +0100 | [diff] [blame] | 289 | #endif |
Chia-I Wu | 9779f6f | 2011-08-05 14:39:18 +0900 | [diff] [blame] | 290 | |
Ander Conselvan de Oliveira | 4a976b6 | 2012-01-25 16:24:17 +0200 | [diff] [blame] | 291 | #ifdef HAVE_DRM_PLATFORM |
| 292 | struct gbm_dri_surface *gbm_surf; |
Ander Conselvan de Oliveira | 4a976b6 | 2012-01-25 16:24:17 +0200 | [diff] [blame] | 293 | #endif |
Kristian Høgsberg | 90804e8 | 2012-12-13 23:30:45 -0500 | [diff] [blame] | 294 | |
Gwan-gyeong Mun | 640b6e6 | 2017-08-05 00:16:11 +0900 | [diff] [blame] | 295 | /* EGL-owned buffers */ |
| 296 | __DRIbuffer *local_buffers[__DRI_BUFFER_COUNT]; |
| 297 | |
Kristian Høgsberg | 90804e8 | 2012-12-13 23:30:45 -0500 | [diff] [blame] | 298 | #if defined(HAVE_WAYLAND_PLATFORM) || defined(HAVE_DRM_PLATFORM) |
Kristian Høgsberg | 90804e8 | 2012-12-13 23:30:45 -0500 | [diff] [blame] | 299 | struct { |
| 300 | #ifdef HAVE_WAYLAND_PLATFORM |
| 301 | struct wl_buffer *wl_buffer; |
Juan A. Suarez Romero | 54a9622 | 2018-08-30 10:14:49 +0200 | [diff] [blame] | 302 | bool wl_release; |
Kristian Høgsberg | 664fe6d | 2013-02-02 07:40:51 -0500 | [diff] [blame] | 303 | __DRIimage *dri_image; |
Axel Davy | 4cd546d | 2015-05-01 01:16:24 +0200 | [diff] [blame] | 304 | /* for is_different_gpu case. NULL else */ |
| 305 | __DRIimage *linear_copy; |
Axel Davy | cdcfe48 | 2015-05-01 11:11:20 +0200 | [diff] [blame] | 306 | /* for swrast */ |
| 307 | void *data; |
| 308 | int data_size; |
Kristian Høgsberg | 90804e8 | 2012-12-13 23:30:45 -0500 | [diff] [blame] | 309 | #endif |
| 310 | #ifdef HAVE_DRM_PLATFORM |
| 311 | struct gbm_bo *bo; |
| 312 | #endif |
Eric Engestrom | 60f9842 | 2017-06-19 00:16:21 +0100 | [diff] [blame] | 313 | bool locked; |
Kristian Høgsberg | 90804e8 | 2012-12-13 23:30:45 -0500 | [diff] [blame] | 314 | int age; |
Neil Roberts | 992a2db | 2013-11-15 13:50:50 +0000 | [diff] [blame] | 315 | } color_buffers[4], *back, *current; |
Ander Conselvan de Oliveira | 4a976b6 | 2012-01-25 16:24:17 +0200 | [diff] [blame] | 316 | #endif |
| 317 | |
Chia-I Wu | 9779f6f | 2011-08-05 14:39:18 +0900 | [diff] [blame] | 318 | #ifdef HAVE_ANDROID_PLATFORM |
Chia-I Wu | 75cc24c | 2011-11-25 11:59:02 +0800 | [diff] [blame] | 319 | struct ANativeWindow *window; |
| 320 | struct ANativeWindowBuffer *buffer; |
Liu Zhiquan | b663753 | 2016-11-16 10:11:28 +0800 | [diff] [blame] | 321 | __DRIimage *dri_image_back; |
| 322 | __DRIimage *dri_image_front; |
Chia-I Wu | 9779f6f | 2011-08-05 14:39:18 +0900 | [diff] [blame] | 323 | |
Xiaosong Wei | 2acc69d | 2017-02-08 10:46:02 +0800 | [diff] [blame] | 324 | /* Used to record all the buffers created by ANativeWindow and their ages. |
Nataraj Deshpande | 0661c35 | 2019-07-19 08:44:13 -0700 | [diff] [blame] | 325 | * Allocate number of color_buffers based on query to android bufferqueue |
| 326 | * and save color_buffers_count. |
Xiaosong Wei | 2acc69d | 2017-02-08 10:46:02 +0800 | [diff] [blame] | 327 | */ |
Nataraj Deshpande | 0661c35 | 2019-07-19 08:44:13 -0700 | [diff] [blame] | 328 | int color_buffers_count; |
Xiaosong Wei | 2acc69d | 2017-02-08 10:46:02 +0800 | [diff] [blame] | 329 | struct { |
| 330 | struct ANativeWindowBuffer *buffer; |
| 331 | int age; |
Nataraj Deshpande | 0661c35 | 2019-07-19 08:44:13 -0700 | [diff] [blame] | 332 | } *color_buffers, *back; |
Chia-I Wu | 9779f6f | 2011-08-05 14:39:18 +0900 | [diff] [blame] | 333 | #endif |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 334 | |
Emil Velikov | d6edcce | 2019-05-16 18:01:40 +0100 | [diff] [blame] | 335 | /* surfaceless and device */ |
| 336 | __DRIimage *front; |
| 337 | unsigned int visual; |
| 338 | |
Zhongmin Wu | e013ce8 | 2017-09-15 18:32:42 +0100 | [diff] [blame] | 339 | int out_fence_fd; |
| 340 | EGLBoolean enable_out_fence; |
Gurchetan Singh | 63c5d5c | 2016-05-16 16:34:07 -0700 | [diff] [blame] | 341 | }; |
Benjamin Franzke | 93aea84 | 2011-02-04 12:39:40 +0100 | [diff] [blame] | 342 | |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 343 | struct dri2_egl_config |
| 344 | { |
| 345 | _EGLConfig base; |
Eric Engestrom | b81cfc7 | 2017-06-21 10:40:31 +0100 | [diff] [blame] | 346 | const __DRIconfig *dri_config[2][2]; |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 347 | }; |
| 348 | |
| 349 | struct dri2_egl_image |
| 350 | { |
| 351 | _EGLImage base; |
| 352 | __DRIimage *dri_image; |
| 353 | }; |
| 354 | |
Marek Olšák | 9a0bda2 | 2015-04-10 10:56:02 +0200 | [diff] [blame] | 355 | struct dri2_egl_sync { |
| 356 | _EGLSync base; |
Dongwon Kim | 7029947 | 2016-04-04 17:14:10 -0700 | [diff] [blame] | 357 | mtx_t mutex; |
| 358 | cnd_t cond; |
Marek Olšák | 9a0bda2 | 2015-04-10 10:56:02 +0200 | [diff] [blame] | 359 | int refcount; |
| 360 | void *fence; |
| 361 | }; |
| 362 | |
Neil Roberts | 992a2db | 2013-11-15 13:50:50 +0000 | [diff] [blame] | 363 | /* From xmlpool/options.h, user exposed so should be stable */ |
| 364 | #define DRI_CONF_VBLANK_NEVER 0 |
| 365 | #define DRI_CONF_VBLANK_DEF_INTERVAL_0 1 |
| 366 | #define DRI_CONF_VBLANK_DEF_INTERVAL_1 2 |
| 367 | #define DRI_CONF_VBLANK_ALWAYS_SYNC 3 |
| 368 | |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 369 | /* standard typecasts */ |
| 370 | _EGL_DRIVER_STANDARD_TYPECASTS(dri2_egl) |
| 371 | _EGL_DRIVER_TYPECAST(dri2_egl_image, _EGLImage, obj) |
Marek Olšák | 9a0bda2 | 2015-04-10 10:56:02 +0200 | [diff] [blame] | 372 | _EGL_DRIVER_TYPECAST(dri2_egl_sync, _EGLSync, obj) |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 373 | |
| 374 | extern const __DRIimageLookupExtension image_lookup_extension; |
Kristian Høgsberg | 9dc5de5 | 2011-02-02 22:21:13 -0500 | [diff] [blame] | 375 | extern const __DRIuseInvalidateExtension use_invalidate; |
Eric Anholt | 3b7b6ad | 2012-12-27 17:39:37 -0800 | [diff] [blame] | 376 | extern const __DRIbackgroundCallableExtension background_callable_extension; |
Eric Anholt | 6a8d39dc | 2019-07-23 13:18:21 -0700 | [diff] [blame] | 377 | extern const __DRIswrastLoaderExtension swrast_pbuffer_loader_extension; |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 378 | |
| 379 | EGLBoolean |
| 380 | dri2_load_driver(_EGLDisplay *disp); |
| 381 | |
Benjamin Franzke | e5fc4c8 | 2011-05-30 10:50:52 +0200 | [diff] [blame] | 382 | /* Helper for platforms not using dri2_create_screen */ |
| 383 | void |
| 384 | dri2_setup_screen(_EGLDisplay *disp); |
| 385 | |
Emil Velikov | 47b06f5 | 2017-08-05 00:25:46 +0100 | [diff] [blame] | 386 | void |
| 387 | dri2_setup_swap_interval(_EGLDisplay *disp, int max_swap_interval); |
| 388 | |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 389 | EGLBoolean |
Chia-I Wu | cf69eea | 2011-06-08 16:33:55 +0800 | [diff] [blame] | 390 | dri2_load_driver_swrast(_EGLDisplay *disp); |
| 391 | |
| 392 | EGLBoolean |
Boyan Ding | f35198b | 2015-07-21 23:44:00 +0800 | [diff] [blame] | 393 | dri2_load_driver_dri3(_EGLDisplay *disp); |
| 394 | |
| 395 | EGLBoolean |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 396 | dri2_create_screen(_EGLDisplay *disp); |
| 397 | |
Emil Velikov | 2c341f2 | 2017-05-11 16:20:04 +0100 | [diff] [blame] | 398 | EGLBoolean |
| 399 | dri2_setup_extensions(_EGLDisplay *disp); |
| 400 | |
Boyan Ding | a25df54 | 2015-07-21 23:43:59 +0800 | [diff] [blame] | 401 | __DRIdrawable * |
| 402 | dri2_surface_get_dri_drawable(_EGLSurface *surf); |
| 403 | |
Benjamin Franzke | e5fc4c8 | 2011-05-30 10:50:52 +0200 | [diff] [blame] | 404 | __DRIimage * |
| 405 | dri2_lookup_egl_image(__DRIscreen *screen, void *image, void *data); |
| 406 | |
Kevin Strasser | 7b4ed2b | 2019-01-24 16:32:48 -0800 | [diff] [blame] | 407 | void |
| 408 | dri2_get_shifts_and_sizes(const __DRIcoreExtension *core, |
| 409 | const __DRIconfig *config, int *shifts, |
| 410 | unsigned int *sizes); |
| 411 | |
Kevin Strasser | 482ed43 | 2019-01-24 16:55:33 -0800 | [diff] [blame^] | 412 | void |
| 413 | dri2_get_render_type_float(const __DRIcoreExtension *core, |
| 414 | const __DRIconfig *config, |
| 415 | bool *is_float); |
| 416 | |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 417 | struct dri2_egl_config * |
| 418 | dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id, |
Emil Velikov | ebc68e3 | 2016-08-25 00:12:13 +0100 | [diff] [blame] | 419 | EGLint surface_type, const EGLint *attr_list, |
Kevin Strasser | 7b4ed2b | 2019-01-24 16:32:48 -0800 | [diff] [blame] | 420 | const int *rgba_shifts, const unsigned int *rgba_sizes); |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 421 | |
| 422 | _EGLImage * |
| 423 | dri2_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp, |
Emil Velikov | ebc68e3 | 2016-08-25 00:12:13 +0100 | [diff] [blame] | 424 | _EGLContext *ctx, EGLenum target, |
| 425 | EGLClientBuffer buffer, const EGLint *attr_list); |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 426 | |
Emil Velikov | 38ef6f5 | 2016-05-01 12:42:53 +0100 | [diff] [blame] | 427 | _EGLImage * |
| 428 | dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx, |
Emil Velikov | ebc68e3 | 2016-08-25 00:12:13 +0100 | [diff] [blame] | 429 | EGLClientBuffer buffer, const EGLint *attr_list); |
Emil Velikov | 38ef6f5 | 2016-05-01 12:42:53 +0100 | [diff] [blame] | 430 | |
Emil Velikov | 55245fe | 2017-11-09 17:55:19 +0000 | [diff] [blame] | 431 | #ifdef HAVE_X11_PLATFORM |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 432 | EGLBoolean |
| 433 | dri2_initialize_x11(_EGLDriver *drv, _EGLDisplay *disp); |
Emil Velikov | 938fcab | 2017-11-09 18:58:52 +0000 | [diff] [blame] | 434 | void |
| 435 | dri2_teardown_x11(struct dri2_egl_display *dri2_dpy); |
Mario Kleiner | 61a0272 | 2018-06-13 06:04:13 +0200 | [diff] [blame] | 436 | unsigned int |
| 437 | dri2_x11_get_red_mask_for_depth(struct dri2_egl_display *dri2_dpy, int depth); |
Emil Velikov | 55245fe | 2017-11-09 17:55:19 +0000 | [diff] [blame] | 438 | #else |
| 439 | static inline EGLBoolean |
| 440 | dri2_initialize_x11(_EGLDriver *drv, _EGLDisplay *disp) |
| 441 | { |
| 442 | return _eglError(EGL_NOT_INITIALIZED, "X11 platform not built"); |
| 443 | } |
Emil Velikov | 938fcab | 2017-11-09 18:58:52 +0000 | [diff] [blame] | 444 | static inline void |
| 445 | dri2_teardown_x11(struct dri2_egl_display *dri2_dpy) {} |
Mario Kleiner | 61a0272 | 2018-06-13 06:04:13 +0200 | [diff] [blame] | 446 | static inline unsigned int |
| 447 | dri2_x11_get_red_mask_for_depth(struct dri2_egl_display *dri2_dpy, int depth) |
| 448 | { |
| 449 | return 0; |
| 450 | } |
Emil Velikov | 55245fe | 2017-11-09 17:55:19 +0000 | [diff] [blame] | 451 | #endif |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 452 | |
Emil Velikov | 55245fe | 2017-11-09 17:55:19 +0000 | [diff] [blame] | 453 | #ifdef HAVE_DRM_PLATFORM |
Kristian Høgsberg | 9dc5de5 | 2011-02-02 22:21:13 -0500 | [diff] [blame] | 454 | EGLBoolean |
| 455 | dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp); |
Emil Velikov | 40a01c9 | 2017-11-09 19:04:25 +0000 | [diff] [blame] | 456 | void |
| 457 | dri2_teardown_drm(struct dri2_egl_display *dri2_dpy); |
Emil Velikov | 55245fe | 2017-11-09 17:55:19 +0000 | [diff] [blame] | 458 | #else |
| 459 | static inline EGLBoolean |
| 460 | dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp) |
| 461 | { |
| 462 | return _eglError(EGL_NOT_INITIALIZED, "GBM/DRM platform not built"); |
| 463 | } |
Emil Velikov | 40a01c9 | 2017-11-09 19:04:25 +0000 | [diff] [blame] | 464 | static inline void |
| 465 | dri2_teardown_drm(struct dri2_egl_display *dri2_dpy) {} |
Emil Velikov | 55245fe | 2017-11-09 17:55:19 +0000 | [diff] [blame] | 466 | #endif |
Kristian Høgsberg | 9dc5de5 | 2011-02-02 22:21:13 -0500 | [diff] [blame] | 467 | |
Emil Velikov | 55245fe | 2017-11-09 17:55:19 +0000 | [diff] [blame] | 468 | #ifdef HAVE_WAYLAND_PLATFORM |
Benjamin Franzke | 93aea84 | 2011-02-04 12:39:40 +0100 | [diff] [blame] | 469 | EGLBoolean |
| 470 | dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp); |
Emil Velikov | 8d745ab | 2017-11-09 19:13:09 +0000 | [diff] [blame] | 471 | void |
| 472 | dri2_teardown_wayland(struct dri2_egl_display *dri2_dpy); |
Mario Kleiner | 820dfce | 2018-06-13 06:04:15 +0200 | [diff] [blame] | 473 | bool |
| 474 | dri2_wl_is_format_supported(void* user_data, uint32_t format); |
Emil Velikov | 55245fe | 2017-11-09 17:55:19 +0000 | [diff] [blame] | 475 | #else |
| 476 | static inline EGLBoolean |
| 477 | dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp) |
| 478 | { |
| 479 | return _eglError(EGL_NOT_INITIALIZED, "Wayland platform not built"); |
| 480 | } |
Emil Velikov | 8d745ab | 2017-11-09 19:13:09 +0000 | [diff] [blame] | 481 | static inline void |
| 482 | dri2_teardown_wayland(struct dri2_egl_display *dri2_dpy) {} |
Emil Velikov | 55245fe | 2017-11-09 17:55:19 +0000 | [diff] [blame] | 483 | #endif |
Benjamin Franzke | 93aea84 | 2011-02-04 12:39:40 +0100 | [diff] [blame] | 484 | |
Emil Velikov | 55245fe | 2017-11-09 17:55:19 +0000 | [diff] [blame] | 485 | #ifdef HAVE_ANDROID_PLATFORM |
Chia-I Wu | 9779f6f | 2011-08-05 14:39:18 +0900 | [diff] [blame] | 486 | EGLBoolean |
| 487 | dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp); |
Emil Velikov | 55245fe | 2017-11-09 17:55:19 +0000 | [diff] [blame] | 488 | #else |
| 489 | static inline EGLBoolean |
| 490 | dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp) |
| 491 | { |
| 492 | return _eglError(EGL_NOT_INITIALIZED, "Android platform not built"); |
| 493 | } |
| 494 | #endif |
Chia-I Wu | 9779f6f | 2011-08-05 14:39:18 +0900 | [diff] [blame] | 495 | |
Emil Velikov | 55245fe | 2017-11-09 17:55:19 +0000 | [diff] [blame] | 496 | #ifdef HAVE_SURFACELESS_PLATFORM |
Haixia Shi | 6b8accb | 2015-06-12 10:10:58 -0700 | [diff] [blame] | 497 | EGLBoolean |
| 498 | dri2_initialize_surfaceless(_EGLDriver *drv, _EGLDisplay *disp); |
Emil Velikov | 55245fe | 2017-11-09 17:55:19 +0000 | [diff] [blame] | 499 | #else |
| 500 | static inline EGLBoolean |
| 501 | dri2_initialize_surfaceless(_EGLDriver *drv, _EGLDisplay *disp) |
| 502 | { |
| 503 | return _eglError(EGL_NOT_INITIALIZED, "Surfaceless platform not built"); |
| 504 | } |
| 505 | #endif |
Haixia Shi | 6b8accb | 2015-06-12 10:10:58 -0700 | [diff] [blame] | 506 | |
Emil Velikov | d6edcce | 2019-05-16 18:01:40 +0100 | [diff] [blame] | 507 | EGLBoolean |
| 508 | dri2_initialize_device(_EGLDriver *drv, _EGLDisplay *disp); |
| 509 | static inline void |
| 510 | dri2_teardown_device(struct dri2_egl_display *dri2_dpy) { /* noop */ } |
| 511 | |
Eric Anholt | 70e8ccc | 2014-12-21 11:51:33 -0800 | [diff] [blame] | 512 | void |
| 513 | dri2_flush_drawable_for_swapbuffers(_EGLDisplay *disp, _EGLSurface *draw); |
| 514 | |
Marek Olšák | c2c2e9a | 2015-06-10 02:49:29 +0200 | [diff] [blame] | 515 | const __DRIconfig * |
| 516 | dri2_get_dri_config(struct dri2_egl_config *conf, EGLint surface_type, |
| 517 | EGLenum colorspace); |
| 518 | |
Emil Velikov | 98f5d01 | 2016-08-25 13:15:43 +0100 | [diff] [blame] | 519 | static inline void |
| 520 | dri2_set_WL_bind_wayland_display(_EGLDriver *drv, _EGLDisplay *disp) |
| 521 | { |
| 522 | #ifdef HAVE_WAYLAND_PLATFORM |
| 523 | struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); |
| 524 | |
| 525 | (void) drv; |
| 526 | |
| 527 | if (dri2_dpy->device_name && dri2_dpy->image) { |
| 528 | if (dri2_dpy->image->base.version >= 10 && |
| 529 | dri2_dpy->image->getCapabilities != NULL) { |
| 530 | int capabilities; |
| 531 | |
| 532 | capabilities = |
| 533 | dri2_dpy->image->getCapabilities(dri2_dpy->dri_screen); |
| 534 | disp->Extensions.WL_bind_wayland_display = |
| 535 | (capabilities & __DRI_IMAGE_CAP_GLOBAL_NAMES) != 0; |
| 536 | } else { |
| 537 | disp->Extensions.WL_bind_wayland_display = EGL_TRUE; |
| 538 | } |
| 539 | } |
| 540 | #endif |
| 541 | } |
| 542 | |
Emil Velikov | 3e73c02 | 2017-05-11 17:13:33 +0100 | [diff] [blame] | 543 | void |
| 544 | dri2_display_destroy(_EGLDisplay *disp); |
| 545 | |
Gwan-gyeong Mun | 640b6e6 | 2017-08-05 00:16:11 +0900 | [diff] [blame] | 546 | __DRIbuffer * |
| 547 | dri2_egl_surface_alloc_local_buffer(struct dri2_egl_surface *dri2_surf, |
| 548 | unsigned int att, unsigned int format); |
| 549 | |
| 550 | void |
| 551 | dri2_egl_surface_free_local_buffers(struct dri2_egl_surface *dri2_surf); |
| 552 | |
Zhongmin Wu | e013ce8 | 2017-09-15 18:32:42 +0100 | [diff] [blame] | 553 | EGLBoolean |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 554 | dri2_init_surface(_EGLSurface *surf, _EGLDisplay *disp, EGLint type, |
Paulo Zanoni | 04ecda3 | 2019-05-01 15:42:26 -0700 | [diff] [blame] | 555 | _EGLConfig *conf, const EGLint *attrib_list, |
| 556 | EGLBoolean enable_out_fence, void *native_surface); |
Zhongmin Wu | e013ce8 | 2017-09-15 18:32:42 +0100 | [diff] [blame] | 557 | |
| 558 | void |
| 559 | dri2_fini_surface(_EGLSurface *surf); |
| 560 | |
Emil Velikov | 2282ec0 | 2019-05-16 18:01:38 +0100 | [diff] [blame] | 561 | EGLBoolean |
| 562 | dri2_create_drawable(struct dri2_egl_display *dri2_dpy, |
| 563 | const __DRIconfig *config, |
Mathias Fröhlich | a7ecf78 | 2019-06-07 07:12:42 +0200 | [diff] [blame] | 564 | struct dri2_egl_surface *dri2_surf, |
| 565 | void *loaderPrivate); |
Emil Velikov | 2282ec0 | 2019-05-16 18:01:38 +0100 | [diff] [blame] | 566 | |
Eric Engestrom | 2de9e84 | 2018-08-16 15:22:46 +0100 | [diff] [blame] | 567 | static inline uint64_t |
| 568 | combine_u32_into_u64(uint32_t hi, uint32_t lo) |
| 569 | { |
| 570 | return (((uint64_t) hi) << 32) | (((uint64_t) lo) & 0xffffffff); |
| 571 | } |
| 572 | |
Kristian Høgsberg | 2889d96 | 2011-02-02 22:10:40 -0500 | [diff] [blame] | 573 | #endif /* EGL_DRI2_INCLUDED */ |