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