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
31 #include <stdbool.h>
32 #include <stdint.h>
33
34 #ifdef HAVE_X11_PLATFORM
35 #include <X11/Xlib-xcb.h>
36 #include <xcb/dri2.h>
37 #include <xcb/randr.h>
38 #include <xcb/xcb.h>
39 #include <xcb/xfixes.h>
40
41 #include "loader_dri_helper.h"
42 #ifdef HAVE_DRI3
43 #include "loader_dri3_helper.h"
44 #endif
45 #endif
46
47 #ifdef HAVE_WAYLAND_PLATFORM
48 /* forward declarations to avoid pulling wayland headers everywhere */
49 struct wl_egl_window;
50 struct wl_event_queue;
51 struct wl_callback;
52 struct wl_display;
53 struct wl_drm;
54 struct wl_registry;
55 struct wl_shm;
56 struct wl_surface;
57 struct zwp_linux_dmabuf_v1;
58 struct zwp_linux_dmabuf_feedback_v1;
59 #endif
60
61 #include <GL/gl.h>
62 #include <GL/internal/dri_interface.h>
63 #include <GL/internal/mesa_interface.h>
64 #include "kopper_interface.h"
65
66 #ifdef HAVE_DRM_PLATFORM
67 #include <gbm_driint.h>
68 #endif
69
70 #ifdef HAVE_ANDROID_PLATFORM
71 #define LOG_TAG "EGL-DRI2"
72
73 #include <hardware/gralloc.h>
74
75 #include "util/u_gralloc/u_gralloc.h"
76
77 #if ANDROID_API_LEVEL >= 26
78 #include <vndk/window.h>
79 #else
80 #include <system/window.h>
81 #endif
82
83 #endif /* HAVE_ANDROID_PLATFORM */
84
85 #include "eglconfig.h"
86 #include "eglcontext.h"
87 #include "eglcurrent.h"
88 #include "egldevice.h"
89 #include "egldisplay.h"
90 #include "egldriver.h"
91 #include "eglimage.h"
92 #include "egllog.h"
93 #include "eglsurface.h"
94 #include "eglsync.h"
95
96 #include "util/bitset.h"
97 #include "util/u_dynarray.h"
98 #include "util/u_vector.h"
99 #include "util/format/u_format.h"
100
101 struct wl_buffer;
102
103 struct dri2_egl_display_vtbl {
104 /* mandatory on Wayland, unused otherwise */
105 int (*authenticate)(_EGLDisplay *disp, uint32_t id);
106
107 /* mandatory */
108 _EGLSurface *(*create_window_surface)(_EGLDisplay *disp, _EGLConfig *config,
109 void *native_window,
110 const EGLint *attrib_list);
111
112 /* optional */
113 _EGLSurface *(*create_pixmap_surface)(_EGLDisplay *disp, _EGLConfig *config,
114 void *native_pixmap,
115 const EGLint *attrib_list);
116
117 /* optional */
118 _EGLSurface *(*create_pbuffer_surface)(_EGLDisplay *disp, _EGLConfig *config,
119 const EGLint *attrib_list);
120
121 /* mandatory */
122 EGLBoolean (*destroy_surface)(_EGLDisplay *disp, _EGLSurface *surface);
123
124 /* optional */
125 EGLBoolean (*swap_interval)(_EGLDisplay *disp, _EGLSurface *surf,
126 EGLint interval);
127
128 /* mandatory */
129 _EGLImage *(*create_image)(_EGLDisplay *disp, _EGLContext *ctx,
130 EGLenum target, EGLClientBuffer buffer,
131 const EGLint *attr_list);
132
133 /* mandatory */
134 EGLBoolean (*swap_buffers)(_EGLDisplay *disp, _EGLSurface *surf);
135
136 /* optional - falls back to .swap_buffers */
137 EGLBoolean (*swap_buffers_with_damage)(_EGLDisplay *disp,
138 _EGLSurface *surface,
139 const EGLint *rects, EGLint n_rects);
140
141 /* optional */
142 EGLBoolean (*swap_buffers_region)(_EGLDisplay *disp, _EGLSurface *surf,
143 EGLint numRects, const EGLint *rects);
144
145 /* optional */
146 EGLBoolean (*post_sub_buffer)(_EGLDisplay *disp, _EGLSurface *surf, EGLint x,
147 EGLint y, EGLint width, EGLint height);
148
149 /* optional */
150 EGLBoolean (*copy_buffers)(_EGLDisplay *disp, _EGLSurface *surf,
151 void *native_pixmap_target);
152
153 /* optional */
154 EGLint (*query_buffer_age)(_EGLDisplay *disp, _EGLSurface *surf);
155
156 /* optional */
157 EGLBoolean (*query_surface)(_EGLDisplay *disp, _EGLSurface *surf,
158 EGLint attribute, EGLint *value);
159
160 /* optional */
161 struct wl_buffer *(*create_wayland_buffer_from_image)(_EGLDisplay *disp,
162 _EGLImage *img);
163
164 /* optional */
165 EGLBoolean (*get_sync_values)(_EGLDisplay *display, _EGLSurface *surface,
166 EGLuint64KHR *ust, EGLuint64KHR *msc,
167 EGLuint64KHR *sbc);
168
169 /* optional */
170 EGLBoolean (*get_msc_rate)(_EGLDisplay *display, _EGLSurface *surface,
171 EGLint *numerator, EGLint *denominator);
172
173 /* mandatory */
174 __DRIdrawable *(*get_dri_drawable)(_EGLSurface *surf);
175
176 /* optional */
177 void (*close_screen_notify)(_EGLDisplay *disp);
178
179 /* Used in EGL_KHR_mutable_render_buffer to update the native window's
180 * shared buffer mode.
181 * optional
182 */
183 bool (*set_shared_buffer_mode)(_EGLDisplay *disp, _EGLSurface *surf,
184 bool mode);
185 };
186
187 #ifdef HAVE_WAYLAND_PLATFORM
188 struct dri2_wl_formats {
189 unsigned int num_formats;
190
191 /* Bitmap referencing dri2_wl_visuals */
192 unsigned int *formats_bitmap;
193
194 /* Array of vectors. Contains one modifier vector per format */
195 struct u_vector *modifiers;
196 };
197
198 struct dmabuf_feedback_format_table {
199 unsigned int size;
200 struct {
201 uint32_t format;
202 uint32_t padding; /* unused */
203 uint64_t modifier;
204 } *data;
205 };
206
207 struct dmabuf_feedback_tranche {
208 dev_t target_device;
209 uint32_t flags;
210 struct dri2_wl_formats formats;
211 };
212
213 struct dmabuf_feedback {
214 dev_t main_device;
215 struct dmabuf_feedback_format_table format_table;
216 struct util_dynarray tranches;
217 struct dmabuf_feedback_tranche pending_tranche;
218 };
219 #endif
220
221 enum dri2_egl_driver_fail {
222 DRI2_EGL_DRIVER_LOADED = 0,
223 DRI2_EGL_DRIVER_FAILED = 1,
224 DRI2_EGL_DRIVER_PREFER_ZINK = 2,
225 };
226
227 struct dri2_egl_display {
228 const struct dri2_egl_display_vtbl *vtbl;
229
230 mtx_t lock;
231
232 int dri2_major;
233 int dri2_minor;
234 __DRIscreen *dri_screen_render_gpu;
235 /* dri_screen_display_gpu holds display GPU in case of prime gpu offloading
236 * else dri_screen_render_gpu and dri_screen_display_gpu is same. In case of
237 * prime gpu offloading, if display and render driver names are different
238 * (potentially not compatible), dri_screen_display_gpu will be NULL but
239 * fd_display_gpu will still hold fd for display driver.
240 */
241 __DRIscreen *dri_screen_display_gpu;
242 bool own_dri_screen;
243 const __DRIconfig **driver_configs;
244 void *driver;
245 const __DRIcoreExtension *core;
246 const __DRImesaCoreExtension *mesa;
247 const __DRIimageDriverExtension *image_driver;
248 const __DRIdri2Extension *dri2;
249 const __DRIswrastExtension *swrast;
250 const __DRIkopperExtension *kopper;
251 const __DRI2flushExtension *flush;
252 const __DRI2flushControlExtension *flush_control;
253 const __DRItexBufferExtension *tex_buffer;
254 const __DRIimageExtension *image;
255 const __DRI2configQueryExtension *config;
256 const __DRI2fenceExtension *fence;
257 const __DRI2bufferDamageExtension *buffer_damage;
258 const __DRI2blobExtension *blob;
259 const __DRI2interopExtension *interop;
260 const __DRIconfigOptionsExtension *configOptions;
261 const __DRImutableRenderBufferDriverExtension *mutable_render_buffer;
262 /* fd of the GPU used for rendering. */
263 int fd_render_gpu;
264 /* fd of the GPU used for display. If the same GPU is used for display
265 * and rendering, then fd_render_gpu == fd_display_gpu (no need to use
266 * os_same_file_description).
267 */
268 int fd_display_gpu;
269
270 /* dri2_initialize/dri2_terminate increment/decrement this count, so does
271 * dri2_make_current (tracks if there are active contexts/surfaces). */
272 int ref_count;
273
274 bool own_device;
275 bool invalidate_available;
276 int min_swap_interval;
277 int max_swap_interval;
278 int default_swap_interval;
279 #ifdef HAVE_DRM_PLATFORM
280 struct gbm_dri_device *gbm_dri;
281 #endif
282
283 char *driver_name;
284
285 const __DRIextension **loader_extensions;
286 const __DRIextension **driver_extensions;
287
288 #ifdef HAVE_X11_PLATFORM
289 xcb_connection_t *conn;
290 xcb_screen_t *screen;
291 bool swap_available;
292 #ifdef HAVE_DRI3
293 bool multibuffers_available;
294 int dri3_major_version;
295 int dri3_minor_version;
296 int present_major_version;
297 int present_minor_version;
298 struct loader_dri3_extensions loader_dri3_ext;
299 struct loader_screen_resources screen_resources;
300 #endif
301 #endif
302
303 #ifdef HAVE_WAYLAND_PLATFORM
304 struct wl_display *wl_dpy;
305 struct wl_display *wl_dpy_wrapper;
306 struct wl_registry *wl_registry;
307 struct wl_drm *wl_server_drm;
308 struct wl_drm *wl_drm;
309 uint32_t wl_drm_version, wl_drm_name;
310 struct wl_shm *wl_shm;
311 struct wl_event_queue *wl_queue;
312 struct zwp_linux_dmabuf_v1 *wl_dmabuf;
313 struct dri2_wl_formats formats;
314 struct zwp_linux_dmabuf_feedback_v1 *wl_dmabuf_feedback;
315 struct dmabuf_feedback_format_table format_table;
316 bool authenticated;
317 uint32_t capabilities;
318 char *device_name;
319 bool is_render_node;
320 #endif
321
322 #ifdef HAVE_ANDROID_PLATFORM
323 struct u_gralloc *gralloc;
324 /* gralloc vendor usage bit for front rendering */
325 uint32_t front_rendering_usage;
326 #endif
327 };
328
329 struct dri2_egl_context {
330 _EGLContext base;
331 __DRIcontext *dri_context;
332 };
333
334 struct dri2_egl_surface {
335 _EGLSurface base;
336 __DRIdrawable *dri_drawable;
337 __DRIbuffer buffers[5];
338 bool have_fake_front;
339
340 #ifdef HAVE_X11_PLATFORM
341 xcb_drawable_t drawable;
342 xcb_xfixes_region_t region;
343 int depth;
344 int bytes_per_pixel;
345 xcb_gcontext_t gc;
346 xcb_gcontext_t swapgc;
347 #endif
348
349 #ifdef HAVE_WAYLAND_PLATFORM
350 struct wl_egl_window *wl_win;
351 int dx;
352 int dy;
353 struct wl_event_queue *wl_queue;
354 struct wl_surface *wl_surface_wrapper;
355 struct wl_display *wl_dpy_wrapper;
356 struct wl_drm *wl_drm_wrapper;
357 struct wl_callback *throttle_callback;
358 struct zwp_linux_dmabuf_feedback_v1 *wl_dmabuf_feedback;
359 struct dmabuf_feedback dmabuf_feedback, pending_dmabuf_feedback;
360 bool compositor_using_another_device;
361 int format;
362 bool resized;
363 bool received_dmabuf_feedback;
364 #endif
365
366 #ifdef HAVE_DRM_PLATFORM
367 struct gbm_dri_surface *gbm_surf;
368 #endif
369
370 /* EGL-owned buffers */
371 __DRIbuffer *local_buffers[__DRI_BUFFER_COUNT];
372
373 #if defined(HAVE_WAYLAND_PLATFORM) || defined(HAVE_DRM_PLATFORM)
374 struct {
375 #ifdef HAVE_WAYLAND_PLATFORM
376 struct wl_buffer *wl_buffer;
377 bool wl_release;
378 __DRIimage *dri_image;
379 /* for is_different_gpu case. NULL else */
380 __DRIimage *linear_copy;
381 /* for swrast */
382 void *data;
383 int data_size;
384 #endif
385 #ifdef HAVE_DRM_PLATFORM
386 struct gbm_bo *bo;
387 #endif
388 bool locked;
389 int age;
390 } color_buffers[4], *back, *current;
391 #endif
392
393 #ifdef HAVE_ANDROID_PLATFORM
394 struct ANativeWindow *window;
395 struct ANativeWindowBuffer *buffer;
396
397 /* in-fence associated with buffer, -1 once passed down to dri layer: */
398 int in_fence_fd;
399
400 __DRIimage *dri_image_back;
401 __DRIimage *dri_image_front;
402
403 /* Used to record all the buffers created by ANativeWindow and their ages.
404 * Allocate number of color_buffers based on query to android bufferqueue
405 * and save color_buffers_count.
406 */
407 int color_buffers_count;
408 struct {
409 struct ANativeWindowBuffer *buffer;
410 int age;
411 } *color_buffers, *back;
412 uint32_t gralloc_usage;
413 #endif
414
415 /* surfaceless and device */
416 __DRIimage *front;
417 enum pipe_format visual;
418
419 int out_fence_fd;
420 EGLBoolean enable_out_fence;
421
422 /* swrast device */
423 char *swrast_device_buffer;
424 };
425
426 struct dri2_egl_config {
427 _EGLConfig base;
428 const __DRIconfig *dri_config[2][2];
429 };
430
431 struct dri2_egl_image {
432 _EGLImage base;
433 __DRIimage *dri_image;
434 };
435
436 struct dri2_egl_sync {
437 _EGLSync base;
438 mtx_t mutex;
439 cnd_t cond;
440 int refcount;
441 void *fence;
442 };
443
444 /* standard typecasts */
445 _EGL_DRIVER_STANDARD_TYPECASTS(dri2_egl)
_EGL_DRIVER_TYPECAST(dri2_egl_image,_EGLImage,obj)446 _EGL_DRIVER_TYPECAST(dri2_egl_image, _EGLImage, obj)
447 _EGL_DRIVER_TYPECAST(dri2_egl_sync, _EGLSync, obj)
448
449 static inline struct dri2_egl_display *
450 dri2_egl_display_lock(_EGLDisplay *disp)
451 {
452 struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
453
454 if (dri2_dpy)
455 mtx_lock(&dri2_dpy->lock);
456
457 return dri2_dpy;
458 }
459
460 static inline EGLBoolean
dri2_egl_error_unlock(struct dri2_egl_display * dri2_dpy,EGLint err,const char * msg)461 dri2_egl_error_unlock(struct dri2_egl_display *dri2_dpy, EGLint err,
462 const char *msg)
463 {
464 mtx_unlock(&dri2_dpy->lock);
465 return _eglError(err, msg);
466 }
467
468 extern const __DRIimageLookupExtension image_lookup_extension;
469 extern const __DRIuseInvalidateExtension use_invalidate;
470 extern const __DRIbackgroundCallableExtension background_callable_extension;
471 extern const __DRIswrastLoaderExtension swrast_pbuffer_loader_extension;
472
473 EGLBoolean
474 dri2_load_driver(_EGLDisplay *disp);
475
476 /* Helper for platforms not using dri2_create_screen */
477 void
478 dri2_setup_screen(_EGLDisplay *disp);
479
480 void
481 dri2_setup_swap_interval(_EGLDisplay *disp, int max_swap_interval);
482
483 EGLBoolean
484 dri2_load_driver_swrast(_EGLDisplay *disp);
485
486 EGLBoolean
487 dri2_load_driver_dri3(_EGLDisplay *disp);
488
489 EGLBoolean
490 dri2_create_screen(_EGLDisplay *disp);
491
492 EGLBoolean
493 dri2_setup_extensions(_EGLDisplay *disp);
494
495 EGLBoolean
496 dri2_setup_device(_EGLDisplay *disp, EGLBoolean software);
497
498 __DRIdrawable *
499 dri2_surface_get_dri_drawable(_EGLSurface *surf);
500
501 GLboolean
502 dri2_validate_egl_image(void *image, void *data);
503
504 __DRIimage *
505 dri2_lookup_egl_image_validated(void *image, void *data);
506
507 __DRIimage *
508 dri2_lookup_egl_image(__DRIscreen *screen, void *image, void *data);
509
510 void
511 dri2_get_shifts_and_sizes(const __DRIcoreExtension *core,
512 const __DRIconfig *config, int *shifts,
513 unsigned int *sizes);
514
515 void
516 dri2_get_render_type_float(const __DRIcoreExtension *core,
517 const __DRIconfig *config, bool *is_float);
518
519 enum pipe_format
520 dri2_image_format_for_pbuffer_config(struct dri2_egl_display *dri2_dpy,
521 const __DRIconfig *config);
522
523 struct dri2_egl_config *
524 dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config,
525 EGLint surface_type, const EGLint *attr_list);
526
527 void
528 dri2_add_pbuffer_configs_for_visuals(_EGLDisplay *disp);
529
530 _EGLImage *
531 dri2_create_image_khr(_EGLDisplay *disp, _EGLContext *ctx, EGLenum target,
532 EGLClientBuffer buffer, const EGLint *attr_list);
533
534 _EGLImage *
535 dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx,
536 EGLClientBuffer buffer, const EGLint *attr_list);
537
538 _EGLImage *
539 dri2_create_image_from_dri(_EGLDisplay *disp, __DRIimage *dri_image);
540
541 #ifdef HAVE_X11_PLATFORM
542 EGLBoolean
543 dri2_initialize_x11(_EGLDisplay *disp);
544 void
545 dri2_teardown_x11(struct dri2_egl_display *dri2_dpy);
546 unsigned int
547 dri2_x11_get_red_mask_for_depth(struct dri2_egl_display *dri2_dpy, int depth);
548 #else
549 static inline EGLBoolean
dri2_initialize_x11(_EGLDisplay * disp)550 dri2_initialize_x11(_EGLDisplay *disp)
551 {
552 return _eglError(EGL_NOT_INITIALIZED, "X11 platform not built");
553 }
554 static inline void
dri2_teardown_x11(struct dri2_egl_display * dri2_dpy)555 dri2_teardown_x11(struct dri2_egl_display *dri2_dpy)
556 {
557 }
558 static inline unsigned int
dri2_x11_get_red_mask_for_depth(struct dri2_egl_display * dri2_dpy,int depth)559 dri2_x11_get_red_mask_for_depth(struct dri2_egl_display *dri2_dpy, int depth)
560 {
561 return 0;
562 }
563 #endif
564
565 #ifdef HAVE_DRM_PLATFORM
566 EGLBoolean
567 dri2_initialize_drm(_EGLDisplay *disp);
568 void
569 dri2_teardown_drm(struct dri2_egl_display *dri2_dpy);
570 #else
571 static inline EGLBoolean
dri2_initialize_drm(_EGLDisplay * disp)572 dri2_initialize_drm(_EGLDisplay *disp)
573 {
574 return _eglError(EGL_NOT_INITIALIZED, "GBM/DRM platform not built");
575 }
576 static inline void
dri2_teardown_drm(struct dri2_egl_display * dri2_dpy)577 dri2_teardown_drm(struct dri2_egl_display *dri2_dpy)
578 {
579 }
580 #endif
581
582 #ifdef HAVE_WAYLAND_PLATFORM
583 EGLBoolean
584 dri2_initialize_wayland(_EGLDisplay *disp);
585 void
586 dri2_teardown_wayland(struct dri2_egl_display *dri2_dpy);
587 bool
588 dri2_wl_is_format_supported(void *user_data, uint32_t format);
589 #else
590 static inline EGLBoolean
dri2_initialize_wayland(_EGLDisplay * disp)591 dri2_initialize_wayland(_EGLDisplay *disp)
592 {
593 return _eglError(EGL_NOT_INITIALIZED, "Wayland platform not built");
594 }
595 static inline void
dri2_teardown_wayland(struct dri2_egl_display * dri2_dpy)596 dri2_teardown_wayland(struct dri2_egl_display *dri2_dpy)
597 {
598 }
599 #endif
600
601 #ifdef HAVE_ANDROID_PLATFORM
602 EGLBoolean
603 dri2_initialize_android(_EGLDisplay *disp);
604 #else
605 static inline EGLBoolean
dri2_initialize_android(_EGLDisplay * disp)606 dri2_initialize_android(_EGLDisplay *disp)
607 {
608 return _eglError(EGL_NOT_INITIALIZED, "Android platform not built");
609 }
610 #endif
611
612 EGLBoolean
613 dri2_initialize_surfaceless(_EGLDisplay *disp);
614
615 EGLBoolean
616 dri2_initialize_device(_EGLDisplay *disp);
617 static inline void
dri2_teardown_device(struct dri2_egl_display * dri2_dpy)618 dri2_teardown_device(struct dri2_egl_display *dri2_dpy)
619 { /* noop */
620 }
621
622 void
623 dri2_flush_drawable_for_swapbuffers_flags(
624 _EGLDisplay *disp, _EGLSurface *draw,
625 enum __DRI2throttleReason throttle_reason);
626 void
627 dri2_flush_drawable_for_swapbuffers(_EGLDisplay *disp, _EGLSurface *draw);
628
629 const __DRIconfig *
630 dri2_get_dri_config(struct dri2_egl_config *conf, EGLint surface_type,
631 EGLenum colorspace);
632
633 static inline void
dri2_set_WL_bind_wayland_display(_EGLDisplay * disp)634 dri2_set_WL_bind_wayland_display(_EGLDisplay *disp)
635 {
636 #ifdef HAVE_WAYLAND_PLATFORM
637 struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
638
639 if (dri2_dpy->device_name && dri2_dpy->image) {
640 if (dri2_dpy->image->base.version >= 10 &&
641 dri2_dpy->image->getCapabilities != NULL) {
642 int capabilities;
643
644 capabilities =
645 dri2_dpy->image->getCapabilities(dri2_dpy->dri_screen_render_gpu);
646 disp->Extensions.WL_bind_wayland_display =
647 (capabilities & __DRI_IMAGE_CAP_GLOBAL_NAMES) != 0;
648 } else {
649 disp->Extensions.WL_bind_wayland_display = EGL_TRUE;
650 }
651 }
652 #endif
653 }
654
655 void
656 dri2_display_destroy(_EGLDisplay *disp);
657
658 struct dri2_egl_display *
659 dri2_display_create(void);
660
661 __DRIbuffer *
662 dri2_egl_surface_alloc_local_buffer(struct dri2_egl_surface *dri2_surf,
663 unsigned int att, unsigned int format);
664
665 void
666 dri2_egl_surface_free_local_buffers(struct dri2_egl_surface *dri2_surf);
667
668 EGLBoolean
669 dri2_init_surface(_EGLSurface *surf, _EGLDisplay *disp, EGLint type,
670 _EGLConfig *conf, const EGLint *attrib_list,
671 EGLBoolean enable_out_fence, void *native_surface);
672
673 void
674 dri2_fini_surface(_EGLSurface *surf);
675
676 EGLBoolean
677 dri2_create_drawable(struct dri2_egl_display *dri2_dpy,
678 const __DRIconfig *config,
679 struct dri2_egl_surface *dri2_surf, void *loaderPrivate);
680
681 static inline uint64_t
combine_u32_into_u64(uint32_t hi,uint32_t lo)682 combine_u32_into_u64(uint32_t hi, uint32_t lo)
683 {
684 return (((uint64_t)hi) << 32) | (((uint64_t)lo) & 0xffffffff);
685 }
686
687 #endif /* EGL_DRI2_INCLUDED */
688