13464ebd5Sriastradh/* 23464ebd5Sriastradh * Copyright © 2011 Intel Corporation 33464ebd5Sriastradh * 43464ebd5Sriastradh * Permission is hereby granted, free of charge, to any person obtaining a 53464ebd5Sriastradh * copy of this software and associated documentation files (the "Software"), 63464ebd5Sriastradh * to deal in the Software without restriction, including without limitation 73464ebd5Sriastradh * the rights to use, copy, modify, merge, publish, distribute, sublicense, 83464ebd5Sriastradh * and/or sell copies of the Software, and to permit persons to whom the 93464ebd5Sriastradh * Software is furnished to do so, subject to the following conditions: 103464ebd5Sriastradh * 113464ebd5Sriastradh * The above copyright notice and this permission notice (including the next 123464ebd5Sriastradh * paragraph) shall be included in all copies or substantial portions of the 133464ebd5Sriastradh * Software. 143464ebd5Sriastradh * 153464ebd5Sriastradh * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 163464ebd5Sriastradh * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 173464ebd5Sriastradh * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 183464ebd5Sriastradh * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 193464ebd5Sriastradh * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 203464ebd5Sriastradh * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 213464ebd5Sriastradh * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 223464ebd5Sriastradh * DEALINGS IN THE SOFTWARE. 233464ebd5Sriastradh * 243464ebd5Sriastradh * Authors: 253464ebd5Sriastradh * Kristian Høgsberg <krh@bitplanet.net> 263464ebd5Sriastradh */ 273464ebd5Sriastradh 283464ebd5Sriastradh#ifndef EGL_DRI2_INCLUDED 293464ebd5Sriastradh#define EGL_DRI2_INCLUDED 303464ebd5Sriastradh 3101e04c3fSmrg#include <stdbool.h> 3201e04c3fSmrg#include <stdint.h> 3301e04c3fSmrg 343464ebd5Sriastradh#ifdef HAVE_X11_PLATFORM 353464ebd5Sriastradh#include <xcb/xcb.h> 363464ebd5Sriastradh#include <xcb/dri2.h> 373464ebd5Sriastradh#include <xcb/xfixes.h> 383464ebd5Sriastradh#include <X11/Xlib-xcb.h> 3901e04c3fSmrg 4001e04c3fSmrg#ifdef HAVE_DRI3 4101e04c3fSmrg#include "loader_dri3_helper.h" 4201e04c3fSmrg#endif 433464ebd5Sriastradh#endif 443464ebd5Sriastradh 453464ebd5Sriastradh#ifdef HAVE_WAYLAND_PLATFORM 4601e04c3fSmrg/* forward declarations to avoid pulling wayland headers everywhere */ 4701e04c3fSmrgstruct wl_egl_window; 4801e04c3fSmrgstruct wl_event_queue; 4901e04c3fSmrgstruct wl_callback; 5001e04c3fSmrgstruct wl_display; 5101e04c3fSmrgstruct wl_drm; 5201e04c3fSmrgstruct wl_registry; 5301e04c3fSmrgstruct wl_shm; 5401e04c3fSmrgstruct wl_surface; 5501e04c3fSmrgstruct zwp_linux_dmabuf_v1; 563464ebd5Sriastradh#endif 573464ebd5Sriastradh 583464ebd5Sriastradh#include <GL/gl.h> 593464ebd5Sriastradh#include <GL/internal/dri_interface.h> 603464ebd5Sriastradh 613464ebd5Sriastradh#ifdef HAVE_DRM_PLATFORM 623464ebd5Sriastradh#include <gbm_driint.h> 633464ebd5Sriastradh#endif 643464ebd5Sriastradh 65af69d88dSmrg#ifdef HAVE_ANDROID_PLATFORM 66af69d88dSmrg#define LOG_TAG "EGL-DRI2" 67af69d88dSmrg 68af69d88dSmrg#include <hardware/gralloc.h> 697ec681f3Smrg 707ec681f3Smrg#if ANDROID_API_LEVEL >= 26 717ec681f3Smrg#include <vndk/window.h> 727ec681f3Smrg#else 737ec681f3Smrg#include <system/window.h> 747ec681f3Smrg#endif 757ec681f3Smrg 76af69d88dSmrg#endif /* HAVE_ANDROID_PLATFORM */ 77af69d88dSmrg 783464ebd5Sriastradh#include "eglconfig.h" 793464ebd5Sriastradh#include "eglcontext.h" 8001e04c3fSmrg#include "egldevice.h" 813464ebd5Sriastradh#include "egldisplay.h" 823464ebd5Sriastradh#include "egldriver.h" 833464ebd5Sriastradh#include "eglcurrent.h" 843464ebd5Sriastradh#include "egllog.h" 853464ebd5Sriastradh#include "eglsurface.h" 863464ebd5Sriastradh#include "eglimage.h" 8701e04c3fSmrg#include "eglsync.h" 883464ebd5Sriastradh 8901e04c3fSmrg#include "util/u_vector.h" 907ec681f3Smrg#include "util/bitset.h" 917ec681f3Smrg 927ec681f3Smrg#define EGL_DRI2_MAX_FORMATS 11 933464ebd5Sriastradh 94af69d88dSmrgstruct wl_buffer; 95af69d88dSmrg 96af69d88dSmrgstruct dri2_egl_display_vtbl { 977ec681f3Smrg /* mandatory on Wayland, unused otherwise */ 98af69d88dSmrg int (*authenticate)(_EGLDisplay *disp, uint32_t id); 99af69d88dSmrg 1007ec681f3Smrg /* mandatory */ 1017ec681f3Smrg _EGLSurface* (*create_window_surface)(_EGLDisplay *disp, _EGLConfig *config, 102af69d88dSmrg void *native_window, 103af69d88dSmrg const EGLint *attrib_list); 104af69d88dSmrg 1057ec681f3Smrg /* optional */ 1067ec681f3Smrg _EGLSurface* (*create_pixmap_surface)(_EGLDisplay *disp, _EGLConfig *config, 107af69d88dSmrg void *native_pixmap, 108af69d88dSmrg const EGLint *attrib_list); 109af69d88dSmrg 1107ec681f3Smrg /* optional */ 1117ec681f3Smrg _EGLSurface* (*create_pbuffer_surface)(_EGLDisplay *disp, _EGLConfig *config, 112af69d88dSmrg const EGLint *attrib_list); 113af69d88dSmrg 1147ec681f3Smrg /* mandatory */ 1157ec681f3Smrg EGLBoolean (*destroy_surface)(_EGLDisplay *disp, _EGLSurface *surface); 116af69d88dSmrg 1177ec681f3Smrg /* optional */ 1187ec681f3Smrg EGLBoolean (*swap_interval)(_EGLDisplay *disp, _EGLSurface *surf, 1197ec681f3Smrg EGLint interval); 120af69d88dSmrg 1217ec681f3Smrg /* mandatory */ 1227ec681f3Smrg _EGLImage* (*create_image)(_EGLDisplay *disp, _EGLContext *ctx, 1237ec681f3Smrg EGLenum target, EGLClientBuffer buffer, 124af69d88dSmrg const EGLint *attr_list); 125af69d88dSmrg 1267ec681f3Smrg /* mandatory */ 1277ec681f3Smrg EGLBoolean (*swap_buffers)(_EGLDisplay *disp, _EGLSurface *surf); 128af69d88dSmrg 1297ec681f3Smrg /* optional - falls back to .swap_buffers */ 1307ec681f3Smrg EGLBoolean (*swap_buffers_with_damage)(_EGLDisplay *disp, _EGLSurface *surface, 13101e04c3fSmrg const EGLint *rects, EGLint n_rects); 13201e04c3fSmrg 1337ec681f3Smrg /* optional */ 1347ec681f3Smrg EGLBoolean (*swap_buffers_region)(_EGLDisplay *disp, _EGLSurface *surf, 1357ec681f3Smrg EGLint numRects, const EGLint *rects); 136af69d88dSmrg 1377ec681f3Smrg /* optional */ 1387ec681f3Smrg EGLBoolean (*post_sub_buffer)(_EGLDisplay *disp, _EGLSurface *surf, 139af69d88dSmrg EGLint x, EGLint y, 140af69d88dSmrg EGLint width, EGLint height); 141af69d88dSmrg 1427ec681f3Smrg /* optional */ 1437ec681f3Smrg EGLBoolean (*copy_buffers)(_EGLDisplay *disp, _EGLSurface *surf, 1447ec681f3Smrg void *native_pixmap_target); 145af69d88dSmrg 1467ec681f3Smrg /* optional */ 1477ec681f3Smrg EGLint (*query_buffer_age)(_EGLDisplay *disp, _EGLSurface *surf); 148af69d88dSmrg 1497ec681f3Smrg /* optional */ 1507ec681f3Smrg EGLBoolean (*query_surface)(_EGLDisplay *disp, _EGLSurface *surf, 1517ec681f3Smrg EGLint attribute, EGLint *value); 15201e04c3fSmrg 1537ec681f3Smrg /* optional */ 1547ec681f3Smrg struct wl_buffer* (*create_wayland_buffer_from_image)(_EGLDisplay *disp, 1557ec681f3Smrg _EGLImage *img); 156af69d88dSmrg 1577ec681f3Smrg /* optional */ 158af69d88dSmrg EGLBoolean (*get_sync_values)(_EGLDisplay *display, _EGLSurface *surface, 159af69d88dSmrg EGLuint64KHR *ust, EGLuint64KHR *msc, 160af69d88dSmrg EGLuint64KHR *sbc); 16101e04c3fSmrg 1627ec681f3Smrg /* mandatory */ 16301e04c3fSmrg __DRIdrawable *(*get_dri_drawable)(_EGLSurface *surf); 16401e04c3fSmrg 1657ec681f3Smrg /* optional */ 1667e102996Smaya void (*close_screen_notify)(_EGLDisplay *disp); 16701e04c3fSmrg 16801e04c3fSmrg /* Used in EGL_KHR_mutable_render_buffer to update the native window's 16901e04c3fSmrg * shared buffer mode. 1707ec681f3Smrg * optional 17101e04c3fSmrg */ 1727e102996Smaya bool (*set_shared_buffer_mode)(_EGLDisplay *disp, _EGLSurface *surf, 17301e04c3fSmrg bool mode); 174af69d88dSmrg}; 175af69d88dSmrg 1763464ebd5Sriastradhstruct dri2_egl_display 1773464ebd5Sriastradh{ 178af69d88dSmrg const struct dri2_egl_display_vtbl *vtbl; 179af69d88dSmrg 1803464ebd5Sriastradh int dri2_major; 1813464ebd5Sriastradh int dri2_minor; 1823464ebd5Sriastradh __DRIscreen *dri_screen; 18301e04c3fSmrg bool own_dri_screen; 1843464ebd5Sriastradh const __DRIconfig **driver_configs; 1853464ebd5Sriastradh void *driver; 186af69d88dSmrg const __DRIcoreExtension *core; 18701e04c3fSmrg const __DRIimageDriverExtension *image_driver; 188af69d88dSmrg const __DRIdri2Extension *dri2; 189af69d88dSmrg const __DRIswrastExtension *swrast; 190af69d88dSmrg const __DRI2flushExtension *flush; 19101e04c3fSmrg const __DRI2flushControlExtension *flush_control; 192af69d88dSmrg const __DRItexBufferExtension *tex_buffer; 193af69d88dSmrg const __DRIimageExtension *image; 194af69d88dSmrg const __DRIrobustnessExtension *robustness; 19501e04c3fSmrg const __DRInoErrorExtension *no_error; 196af69d88dSmrg const __DRI2configQueryExtension *config; 19701e04c3fSmrg const __DRI2fenceExtension *fence; 1987ec681f3Smrg const __DRI2bufferDamageExtension *buffer_damage; 19901e04c3fSmrg const __DRI2blobExtension *blob; 20001e04c3fSmrg const __DRI2rendererQueryExtension *rendererQuery; 20101e04c3fSmrg const __DRI2interopExtension *interop; 2027e102996Smaya const __DRIconfigOptionsExtension *configOptions; 20301e04c3fSmrg const __DRImutableRenderBufferDriverExtension *mutable_render_buffer; 2043464ebd5Sriastradh int fd; 2053464ebd5Sriastradh 20601e04c3fSmrg /* dri2_initialize/dri2_terminate increment/decrement this count, so does 20701e04c3fSmrg * dri2_make_current (tracks if there are active contexts/surfaces). */ 20801e04c3fSmrg int ref_count; 20901e04c3fSmrg 21001e04c3fSmrg bool own_device; 21101e04c3fSmrg bool invalidate_available; 212af69d88dSmrg int min_swap_interval; 213af69d88dSmrg int max_swap_interval; 214af69d88dSmrg int default_swap_interval; 2153464ebd5Sriastradh#ifdef HAVE_DRM_PLATFORM 2163464ebd5Sriastradh struct gbm_dri_device *gbm_dri; 2173464ebd5Sriastradh#endif 2183464ebd5Sriastradh 2193464ebd5Sriastradh char *driver_name; 2203464ebd5Sriastradh 22101e04c3fSmrg const __DRIextension **loader_extensions; 222af69d88dSmrg const __DRIextension **driver_extensions; 2233464ebd5Sriastradh 2243464ebd5Sriastradh#ifdef HAVE_X11_PLATFORM 2253464ebd5Sriastradh xcb_connection_t *conn; 22601e04c3fSmrg xcb_screen_t *screen; 22701e04c3fSmrg bool swap_available; 22801e04c3fSmrg#ifdef HAVE_DRI3 22901e04c3fSmrg bool multibuffers_available; 23001e04c3fSmrg int dri3_major_version; 23101e04c3fSmrg int dri3_minor_version; 23201e04c3fSmrg int present_major_version; 23301e04c3fSmrg int present_minor_version; 23401e04c3fSmrg struct loader_dri3_extensions loader_dri3_ext; 23501e04c3fSmrg#endif 2363464ebd5Sriastradh#endif 2373464ebd5Sriastradh 2383464ebd5Sriastradh#ifdef HAVE_WAYLAND_PLATFORM 2393464ebd5Sriastradh struct wl_display *wl_dpy; 24001e04c3fSmrg struct wl_display *wl_dpy_wrapper; 241af69d88dSmrg struct wl_registry *wl_registry; 2423464ebd5Sriastradh struct wl_drm *wl_server_drm; 2433464ebd5Sriastradh struct wl_drm *wl_drm; 24401e04c3fSmrg struct wl_shm *wl_shm; 245af69d88dSmrg struct wl_event_queue *wl_queue; 24601e04c3fSmrg struct zwp_linux_dmabuf_v1 *wl_dmabuf; 24701e04c3fSmrg struct u_vector *wl_modifiers; 24801e04c3fSmrg bool authenticated; 2497ec681f3Smrg BITSET_DECLARE(formats, EGL_DRI2_MAX_FORMATS); 250af69d88dSmrg uint32_t capabilities; 25101e04c3fSmrg char *device_name; 25201e04c3fSmrg#endif 25301e04c3fSmrg 25401e04c3fSmrg#ifdef HAVE_ANDROID_PLATFORM 25501e04c3fSmrg const gralloc_module_t *gralloc; 2567ec681f3Smrg /* gralloc vendor usage bit for front rendering */ 2577ec681f3Smrg uint32_t front_rendering_usage; 2583464ebd5Sriastradh#endif 25901e04c3fSmrg 26001e04c3fSmrg bool is_render_node; 26101e04c3fSmrg bool is_different_gpu; 2623464ebd5Sriastradh}; 2633464ebd5Sriastradh 2643464ebd5Sriastradhstruct dri2_egl_context 2653464ebd5Sriastradh{ 2663464ebd5Sriastradh _EGLContext base; 2673464ebd5Sriastradh __DRIcontext *dri_context; 2683464ebd5Sriastradh}; 2693464ebd5Sriastradh 2703464ebd5Sriastradh#ifdef HAVE_WAYLAND_PLATFORM 2713464ebd5Sriastradhenum wayland_buffer_type { 2723464ebd5Sriastradh WL_BUFFER_FRONT, 2733464ebd5Sriastradh WL_BUFFER_BACK, 2743464ebd5Sriastradh WL_BUFFER_THIRD, 2753464ebd5Sriastradh WL_BUFFER_COUNT 2763464ebd5Sriastradh}; 2773464ebd5Sriastradh#endif 2783464ebd5Sriastradh 2793464ebd5Sriastradhstruct dri2_egl_surface 2803464ebd5Sriastradh{ 2813464ebd5Sriastradh _EGLSurface base; 2823464ebd5Sriastradh __DRIdrawable *dri_drawable; 2833464ebd5Sriastradh __DRIbuffer buffers[5]; 28401e04c3fSmrg bool have_fake_front; 2853464ebd5Sriastradh 2863464ebd5Sriastradh#ifdef HAVE_X11_PLATFORM 2873464ebd5Sriastradh xcb_drawable_t drawable; 2883464ebd5Sriastradh xcb_xfixes_region_t region; 2893464ebd5Sriastradh int depth; 2903464ebd5Sriastradh int bytes_per_pixel; 2913464ebd5Sriastradh xcb_gcontext_t gc; 2923464ebd5Sriastradh xcb_gcontext_t swapgc; 2933464ebd5Sriastradh#endif 2943464ebd5Sriastradh 2953464ebd5Sriastradh#ifdef HAVE_WAYLAND_PLATFORM 2963464ebd5Sriastradh struct wl_egl_window *wl_win; 2973464ebd5Sriastradh int dx; 2983464ebd5Sriastradh int dy; 29901e04c3fSmrg struct wl_event_queue *wl_queue; 30001e04c3fSmrg struct wl_surface *wl_surface_wrapper; 30101e04c3fSmrg struct wl_display *wl_dpy_wrapper; 30201e04c3fSmrg struct wl_drm *wl_drm_wrapper; 303af69d88dSmrg struct wl_callback *throttle_callback; 30401e04c3fSmrg int format; 3057ec681f3Smrg bool resized; 306af69d88dSmrg#endif 307af69d88dSmrg 308af69d88dSmrg#ifdef HAVE_DRM_PLATFORM 309af69d88dSmrg struct gbm_dri_surface *gbm_surf; 310af69d88dSmrg#endif 311af69d88dSmrg 31201e04c3fSmrg /* EGL-owned buffers */ 31301e04c3fSmrg __DRIbuffer *local_buffers[__DRI_BUFFER_COUNT]; 31401e04c3fSmrg 315af69d88dSmrg#if defined(HAVE_WAYLAND_PLATFORM) || defined(HAVE_DRM_PLATFORM) 316af69d88dSmrg struct { 317af69d88dSmrg#ifdef HAVE_WAYLAND_PLATFORM 318af69d88dSmrg struct wl_buffer *wl_buffer; 31901e04c3fSmrg bool wl_release; 320af69d88dSmrg __DRIimage *dri_image; 32101e04c3fSmrg /* for is_different_gpu case. NULL else */ 32201e04c3fSmrg __DRIimage *linear_copy; 32301e04c3fSmrg /* for swrast */ 32401e04c3fSmrg void *data; 32501e04c3fSmrg int data_size; 3263464ebd5Sriastradh#endif 327af69d88dSmrg#ifdef HAVE_DRM_PLATFORM 328af69d88dSmrg struct gbm_bo *bo; 329af69d88dSmrg#endif 33001e04c3fSmrg bool locked; 331af69d88dSmrg int age; 332af69d88dSmrg } color_buffers[4], *back, *current; 333af69d88dSmrg#endif 334af69d88dSmrg 335af69d88dSmrg#ifdef HAVE_ANDROID_PLATFORM 336af69d88dSmrg struct ANativeWindow *window; 337af69d88dSmrg struct ANativeWindowBuffer *buffer; 33801e04c3fSmrg __DRIimage *dri_image_back; 33901e04c3fSmrg __DRIimage *dri_image_front; 3403464ebd5Sriastradh 34101e04c3fSmrg /* Used to record all the buffers created by ANativeWindow and their ages. 3427e102996Smaya * Allocate number of color_buffers based on query to android bufferqueue 3437e102996Smaya * and save color_buffers_count. 34401e04c3fSmrg */ 3457e102996Smaya int color_buffers_count; 34601e04c3fSmrg struct { 34701e04c3fSmrg struct ANativeWindowBuffer *buffer; 34801e04c3fSmrg int age; 3497e102996Smaya } *color_buffers, *back; 3507ec681f3Smrg uint32_t gralloc_usage; 351af69d88dSmrg#endif 3523464ebd5Sriastradh 3537ec681f3Smrg /* surfaceless and device */ 3547ec681f3Smrg __DRIimage *front; 3557ec681f3Smrg unsigned int visual; 3567ec681f3Smrg 35701e04c3fSmrg int out_fence_fd; 35801e04c3fSmrg EGLBoolean enable_out_fence; 3597ec681f3Smrg 3607ec681f3Smrg /* swrast device */ 3617ec681f3Smrg char *swrast_device_buffer; 36201e04c3fSmrg}; 3633464ebd5Sriastradh 3643464ebd5Sriastradhstruct dri2_egl_config 3653464ebd5Sriastradh{ 3663464ebd5Sriastradh _EGLConfig base; 36701e04c3fSmrg const __DRIconfig *dri_config[2][2]; 3683464ebd5Sriastradh}; 3693464ebd5Sriastradh 3703464ebd5Sriastradhstruct dri2_egl_image 3713464ebd5Sriastradh{ 3723464ebd5Sriastradh _EGLImage base; 3733464ebd5Sriastradh __DRIimage *dri_image; 3743464ebd5Sriastradh}; 3753464ebd5Sriastradh 37601e04c3fSmrgstruct dri2_egl_sync { 37701e04c3fSmrg _EGLSync base; 37801e04c3fSmrg mtx_t mutex; 37901e04c3fSmrg cnd_t cond; 38001e04c3fSmrg int refcount; 38101e04c3fSmrg void *fence; 38201e04c3fSmrg}; 38301e04c3fSmrg 3847ec681f3Smrg/* From driconf.h, user exposed so should be stable */ 385af69d88dSmrg#define DRI_CONF_VBLANK_NEVER 0 386af69d88dSmrg#define DRI_CONF_VBLANK_DEF_INTERVAL_0 1 387af69d88dSmrg#define DRI_CONF_VBLANK_DEF_INTERVAL_1 2 388af69d88dSmrg#define DRI_CONF_VBLANK_ALWAYS_SYNC 3 389af69d88dSmrg 3903464ebd5Sriastradh/* standard typecasts */ 3913464ebd5Sriastradh_EGL_DRIVER_STANDARD_TYPECASTS(dri2_egl) 3923464ebd5Sriastradh_EGL_DRIVER_TYPECAST(dri2_egl_image, _EGLImage, obj) 39301e04c3fSmrg_EGL_DRIVER_TYPECAST(dri2_egl_sync, _EGLSync, obj) 3943464ebd5Sriastradh 3953464ebd5Sriastradhextern const __DRIimageLookupExtension image_lookup_extension; 3963464ebd5Sriastradhextern const __DRIuseInvalidateExtension use_invalidate; 39701e04c3fSmrgextern const __DRIbackgroundCallableExtension background_callable_extension; 3987ec681f3Smrgextern const __DRIswrastLoaderExtension swrast_pbuffer_loader_extension; 3993464ebd5Sriastradh 4003464ebd5SriastradhEGLBoolean 4013464ebd5Sriastradhdri2_load_driver(_EGLDisplay *disp); 4023464ebd5Sriastradh 4033464ebd5Sriastradh/* Helper for platforms not using dri2_create_screen */ 4043464ebd5Sriastradhvoid 4053464ebd5Sriastradhdri2_setup_screen(_EGLDisplay *disp); 4063464ebd5Sriastradh 40701e04c3fSmrgvoid 40801e04c3fSmrgdri2_setup_swap_interval(_EGLDisplay *disp, int max_swap_interval); 40901e04c3fSmrg 4103464ebd5SriastradhEGLBoolean 4113464ebd5Sriastradhdri2_load_driver_swrast(_EGLDisplay *disp); 4123464ebd5Sriastradh 41301e04c3fSmrgEGLBoolean 41401e04c3fSmrgdri2_load_driver_dri3(_EGLDisplay *disp); 41501e04c3fSmrg 4163464ebd5SriastradhEGLBoolean 4173464ebd5Sriastradhdri2_create_screen(_EGLDisplay *disp); 4183464ebd5Sriastradh 41901e04c3fSmrgEGLBoolean 42001e04c3fSmrgdri2_setup_extensions(_EGLDisplay *disp); 42101e04c3fSmrg 42201e04c3fSmrg__DRIdrawable * 42301e04c3fSmrgdri2_surface_get_dri_drawable(_EGLSurface *surf); 42401e04c3fSmrg 4257ec681f3SmrgGLboolean 4267ec681f3Smrgdri2_validate_egl_image(void *image, void *data); 4277ec681f3Smrg 4287ec681f3Smrg__DRIimage * 4297ec681f3Smrgdri2_lookup_egl_image_validated(void *image, void *data); 4307ec681f3Smrg 4313464ebd5Sriastradh__DRIimage * 4323464ebd5Sriastradhdri2_lookup_egl_image(__DRIscreen *screen, void *image, void *data); 4333464ebd5Sriastradh 4347ec681f3Smrgvoid 4357ec681f3Smrgdri2_get_shifts_and_sizes(const __DRIcoreExtension *core, 4367ec681f3Smrg const __DRIconfig *config, int *shifts, 4377ec681f3Smrg unsigned int *sizes); 4387ec681f3Smrg 4397ec681f3Smrgvoid 4407ec681f3Smrgdri2_get_render_type_float(const __DRIcoreExtension *core, 4417ec681f3Smrg const __DRIconfig *config, 4427ec681f3Smrg bool *is_float); 4437ec681f3Smrg 4447ec681f3Smrgunsigned int 4457ec681f3Smrgdri2_image_format_for_pbuffer_config(struct dri2_egl_display *dri2_dpy, 4467ec681f3Smrg const __DRIconfig *config); 4477ec681f3Smrg 4483464ebd5Sriastradhstruct dri2_egl_config * 4493464ebd5Sriastradhdri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id, 45001e04c3fSmrg EGLint surface_type, const EGLint *attr_list, 4517ec681f3Smrg const int *rgba_shifts, const unsigned int *rgba_sizes); 4527ec681f3Smrg 4537ec681f3SmrgEGLBoolean 4547ec681f3Smrgdri2_add_pbuffer_configs_for_visuals(_EGLDisplay *disp); 4553464ebd5Sriastradh 4563464ebd5Sriastradh_EGLImage * 4577ec681f3Smrgdri2_create_image_khr(_EGLDisplay *disp, _EGLContext *ctx, EGLenum target, 45801e04c3fSmrg EGLClientBuffer buffer, const EGLint *attr_list); 45901e04c3fSmrg 46001e04c3fSmrg_EGLImage * 46101e04c3fSmrgdri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx, 46201e04c3fSmrg EGLClientBuffer buffer, const EGLint *attr_list); 4633464ebd5Sriastradh 4647ec681f3Smrg_EGLImage * 4657ec681f3Smrgdri2_create_image_from_dri(_EGLDisplay *disp, __DRIimage *dri_image); 4667ec681f3Smrg 46701e04c3fSmrg#ifdef HAVE_X11_PLATFORM 4683464ebd5SriastradhEGLBoolean 4697ec681f3Smrgdri2_initialize_x11(_EGLDisplay *disp); 47001e04c3fSmrgvoid 47101e04c3fSmrgdri2_teardown_x11(struct dri2_egl_display *dri2_dpy); 47201e04c3fSmrgunsigned int 47301e04c3fSmrgdri2_x11_get_red_mask_for_depth(struct dri2_egl_display *dri2_dpy, int depth); 47401e04c3fSmrg#else 47501e04c3fSmrgstatic inline EGLBoolean 4767ec681f3Smrgdri2_initialize_x11(_EGLDisplay *disp) 47701e04c3fSmrg{ 47801e04c3fSmrg return _eglError(EGL_NOT_INITIALIZED, "X11 platform not built"); 47901e04c3fSmrg} 48001e04c3fSmrgstatic inline void 48101e04c3fSmrgdri2_teardown_x11(struct dri2_egl_display *dri2_dpy) {} 48201e04c3fSmrgstatic inline unsigned int 48301e04c3fSmrgdri2_x11_get_red_mask_for_depth(struct dri2_egl_display *dri2_dpy, int depth) 48401e04c3fSmrg{ 48501e04c3fSmrg return 0; 48601e04c3fSmrg} 48701e04c3fSmrg#endif 4883464ebd5Sriastradh 48901e04c3fSmrg#ifdef HAVE_DRM_PLATFORM 4903464ebd5SriastradhEGLBoolean 4917ec681f3Smrgdri2_initialize_drm(_EGLDisplay *disp); 49201e04c3fSmrgvoid 49301e04c3fSmrgdri2_teardown_drm(struct dri2_egl_display *dri2_dpy); 49401e04c3fSmrg#else 49501e04c3fSmrgstatic inline EGLBoolean 4967ec681f3Smrgdri2_initialize_drm(_EGLDisplay *disp) 49701e04c3fSmrg{ 49801e04c3fSmrg return _eglError(EGL_NOT_INITIALIZED, "GBM/DRM platform not built"); 49901e04c3fSmrg} 50001e04c3fSmrgstatic inline void 50101e04c3fSmrgdri2_teardown_drm(struct dri2_egl_display *dri2_dpy) {} 50201e04c3fSmrg#endif 5033464ebd5Sriastradh 50401e04c3fSmrg#ifdef HAVE_WAYLAND_PLATFORM 5053464ebd5SriastradhEGLBoolean 5067ec681f3Smrgdri2_initialize_wayland(_EGLDisplay *disp); 50701e04c3fSmrgvoid 50801e04c3fSmrgdri2_teardown_wayland(struct dri2_egl_display *dri2_dpy); 50901e04c3fSmrgbool 51001e04c3fSmrgdri2_wl_is_format_supported(void* user_data, uint32_t format); 51101e04c3fSmrg#else 51201e04c3fSmrgstatic inline EGLBoolean 5137ec681f3Smrgdri2_initialize_wayland(_EGLDisplay *disp) 51401e04c3fSmrg{ 51501e04c3fSmrg return _eglError(EGL_NOT_INITIALIZED, "Wayland platform not built"); 51601e04c3fSmrg} 51701e04c3fSmrgstatic inline void 51801e04c3fSmrgdri2_teardown_wayland(struct dri2_egl_display *dri2_dpy) {} 51901e04c3fSmrg#endif 5203464ebd5Sriastradh 52101e04c3fSmrg#ifdef HAVE_ANDROID_PLATFORM 522af69d88dSmrgEGLBoolean 5237ec681f3Smrgdri2_initialize_android(_EGLDisplay *disp); 52401e04c3fSmrg#else 52501e04c3fSmrgstatic inline EGLBoolean 5267ec681f3Smrgdri2_initialize_android(_EGLDisplay *disp) 52701e04c3fSmrg{ 52801e04c3fSmrg return _eglError(EGL_NOT_INITIALIZED, "Android platform not built"); 52901e04c3fSmrg} 53001e04c3fSmrg#endif 53101e04c3fSmrg 53201e04c3fSmrgEGLBoolean 5337ec681f3Smrgdri2_initialize_surfaceless(_EGLDisplay *disp); 5347ec681f3Smrg 5357ec681f3SmrgEGLBoolean 5367ec681f3Smrgdri2_initialize_device(_EGLDisplay *disp); 5377ec681f3Smrgstatic inline void 5387ec681f3Smrgdri2_teardown_device(struct dri2_egl_display *dri2_dpy) { /* noop */ } 53901e04c3fSmrg 54001e04c3fSmrgvoid 54101e04c3fSmrgdri2_flush_drawable_for_swapbuffers(_EGLDisplay *disp, _EGLSurface *draw); 54201e04c3fSmrg 54301e04c3fSmrgconst __DRIconfig * 54401e04c3fSmrgdri2_get_dri_config(struct dri2_egl_config *conf, EGLint surface_type, 54501e04c3fSmrg EGLenum colorspace); 54601e04c3fSmrg 54701e04c3fSmrgstatic inline void 5487ec681f3Smrgdri2_set_WL_bind_wayland_display(_EGLDisplay *disp) 54901e04c3fSmrg{ 55001e04c3fSmrg#ifdef HAVE_WAYLAND_PLATFORM 55101e04c3fSmrg struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); 55201e04c3fSmrg 55301e04c3fSmrg if (dri2_dpy->device_name && dri2_dpy->image) { 55401e04c3fSmrg if (dri2_dpy->image->base.version >= 10 && 55501e04c3fSmrg dri2_dpy->image->getCapabilities != NULL) { 55601e04c3fSmrg int capabilities; 55701e04c3fSmrg 55801e04c3fSmrg capabilities = 55901e04c3fSmrg dri2_dpy->image->getCapabilities(dri2_dpy->dri_screen); 56001e04c3fSmrg disp->Extensions.WL_bind_wayland_display = 56101e04c3fSmrg (capabilities & __DRI_IMAGE_CAP_GLOBAL_NAMES) != 0; 56201e04c3fSmrg } else { 56301e04c3fSmrg disp->Extensions.WL_bind_wayland_display = EGL_TRUE; 56401e04c3fSmrg } 56501e04c3fSmrg } 56601e04c3fSmrg#endif 56701e04c3fSmrg} 56801e04c3fSmrg 56901e04c3fSmrgvoid 57001e04c3fSmrgdri2_display_destroy(_EGLDisplay *disp); 57101e04c3fSmrg 57201e04c3fSmrg__DRIbuffer * 57301e04c3fSmrgdri2_egl_surface_alloc_local_buffer(struct dri2_egl_surface *dri2_surf, 57401e04c3fSmrg unsigned int att, unsigned int format); 57501e04c3fSmrg 57601e04c3fSmrgvoid 57701e04c3fSmrgdri2_egl_surface_free_local_buffers(struct dri2_egl_surface *dri2_surf); 57801e04c3fSmrg 57901e04c3fSmrgEGLBoolean 5807e102996Smayadri2_init_surface(_EGLSurface *surf, _EGLDisplay *disp, EGLint type, 5817ec681f3Smrg _EGLConfig *conf, const EGLint *attrib_list, 5827ec681f3Smrg EGLBoolean enable_out_fence, void *native_surface); 58301e04c3fSmrg 58401e04c3fSmrgvoid 58501e04c3fSmrgdri2_fini_surface(_EGLSurface *surf); 58601e04c3fSmrg 5877e102996SmayaEGLBoolean 5887e102996Smayadri2_create_drawable(struct dri2_egl_display *dri2_dpy, 5897e102996Smaya const __DRIconfig *config, 5907ec681f3Smrg struct dri2_egl_surface *dri2_surf, 5917ec681f3Smrg void *loaderPrivate); 5927e102996Smaya 59301e04c3fSmrgstatic inline uint64_t 59401e04c3fSmrgcombine_u32_into_u64(uint32_t hi, uint32_t lo) 59501e04c3fSmrg{ 59601e04c3fSmrg return (((uint64_t) hi) << 32) | (((uint64_t) lo) & 0xffffffff); 59701e04c3fSmrg} 5983464ebd5Sriastradh 5993464ebd5Sriastradh#endif /* EGL_DRI2_INCLUDED */ 600