2 * Copyright © 2011 Intel Corporation
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:
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
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.
25 * Kristian Høgsberg <krh@bitplanet.net>
34 #include <sys/types.h>
40 #include "egl_dri2_fallbacks.h"
43 static struct gbm_bo
*
44 lock_front_buffer(struct gbm_surface
*_surf
)
46 struct gbm_dri_surface
*surf
= (struct gbm_dri_surface
*) _surf
;
47 struct dri2_egl_surface
*dri2_surf
= surf
->dri_private
;
48 struct gbm_dri_device
*device
= (struct gbm_dri_device
*) _surf
->gbm
;
51 if (dri2_surf
->current
== NULL
) {
52 _eglError(EGL_BAD_SURFACE
, "no front buffer");
56 bo
= dri2_surf
->current
->bo
;
59 dri2_surf
->current
->locked
= true;
60 dri2_surf
->current
= NULL
;
67 release_buffer(struct gbm_surface
*_surf
, struct gbm_bo
*bo
)
69 struct gbm_dri_surface
*surf
= (struct gbm_dri_surface
*) _surf
;
70 struct dri2_egl_surface
*dri2_surf
= surf
->dri_private
;
72 for (unsigned i
= 0; i
< ARRAY_SIZE(dri2_surf
->color_buffers
); i
++) {
73 if (dri2_surf
->color_buffers
[i
].bo
== bo
) {
74 dri2_surf
->color_buffers
[i
].locked
= false;
81 has_free_buffers(struct gbm_surface
*_surf
)
83 struct gbm_dri_surface
*surf
= (struct gbm_dri_surface
*) _surf
;
84 struct dri2_egl_surface
*dri2_surf
= surf
->dri_private
;
86 for (unsigned i
= 0; i
< ARRAY_SIZE(dri2_surf
->color_buffers
); i
++)
87 if (!dri2_surf
->color_buffers
[i
].locked
)
94 dri2_drm_create_window_surface(_EGLDriver
*drv
, _EGLDisplay
*disp
,
95 _EGLConfig
*conf
, void *native_surface
,
96 const EGLint
*attrib_list
)
98 struct dri2_egl_display
*dri2_dpy
= dri2_egl_display(disp
);
99 struct dri2_egl_config
*dri2_conf
= dri2_egl_config(conf
);
100 struct dri2_egl_surface
*dri2_surf
;
101 struct gbm_surface
*surface
= native_surface
;
102 struct gbm_dri_surface
*surf
;
103 const __DRIconfig
*config
;
107 dri2_surf
= calloc(1, sizeof *dri2_surf
);
109 _eglError(EGL_BAD_ALLOC
, "dri2_create_surface");
113 if (!_eglInitSurface(&dri2_surf
->base
, disp
, EGL_WINDOW_BIT
, conf
, attrib_list
))
116 surf
= gbm_dri_surface(surface
);
117 dri2_surf
->gbm_surf
= surf
;
118 dri2_surf
->base
.Width
= surf
->base
.width
;
119 dri2_surf
->base
.Height
= surf
->base
.height
;
120 surf
->dri_private
= dri2_surf
;
122 config
= dri2_get_dri_config(dri2_conf
, EGL_WINDOW_BIT
,
123 dri2_surf
->base
.GLColorspace
);
125 if (dri2_dpy
->dri2
) {
126 dri2_surf
->dri_drawable
=
127 dri2_dpy
->dri2
->createNewDrawable(dri2_dpy
->dri_screen
, config
,
128 dri2_surf
->gbm_surf
);
131 assert(dri2_dpy
->swrast
!= NULL
);
133 dri2_surf
->dri_drawable
=
134 dri2_dpy
->swrast
->createNewDrawable(dri2_dpy
->dri_screen
, config
,
135 dri2_surf
->gbm_surf
);
138 if (dri2_surf
->dri_drawable
== NULL
) {
139 _eglError(EGL_BAD_ALLOC
, "createNewDrawable()");
143 return &dri2_surf
->base
;
152 dri2_drm_create_pixmap_surface(_EGLDriver
*drv
, _EGLDisplay
*disp
,
153 _EGLConfig
*conf
, void *native_window
,
154 const EGLint
*attrib_list
)
156 /* From the EGL_MESA_platform_gbm spec, version 5:
158 * It is not valid to call eglCreatePlatformPixmapSurfaceEXT with a <dpy>
159 * that belongs to the GBM platform. Any such call fails and generates
162 _eglError(EGL_BAD_PARAMETER
, "cannot create EGL pixmap surfaces on GBM");
167 dri2_drm_destroy_surface(_EGLDriver
*drv
, _EGLDisplay
*disp
, _EGLSurface
*surf
)
169 struct dri2_egl_display
*dri2_dpy
= dri2_egl_display(disp
);
170 struct dri2_egl_surface
*dri2_surf
= dri2_egl_surface(surf
);
172 dri2_dpy
->core
->destroyDrawable(dri2_surf
->dri_drawable
);
174 for (unsigned i
= 0; i
< ARRAY_SIZE(dri2_surf
->color_buffers
); i
++) {
175 if (dri2_surf
->color_buffers
[i
].bo
)
176 gbm_bo_destroy(dri2_surf
->color_buffers
[i
].bo
);
179 dri2_egl_surface_free_local_buffers(dri2_surf
);
187 get_back_bo(struct dri2_egl_surface
*dri2_surf
)
189 struct dri2_egl_display
*dri2_dpy
=
190 dri2_egl_display(dri2_surf
->base
.Resource
.Display
);
191 struct gbm_dri_surface
*surf
= dri2_surf
->gbm_surf
;
194 if (dri2_surf
->back
== NULL
) {
195 for (unsigned i
= 0; i
< ARRAY_SIZE(dri2_surf
->color_buffers
); i
++) {
196 if (!dri2_surf
->color_buffers
[i
].locked
&&
197 dri2_surf
->color_buffers
[i
].age
>= age
) {
198 dri2_surf
->back
= &dri2_surf
->color_buffers
[i
];
199 age
= dri2_surf
->color_buffers
[i
].age
;
204 if (dri2_surf
->back
== NULL
)
206 if (dri2_surf
->back
->bo
== NULL
) {
207 if (surf
->base
.modifiers
)
208 dri2_surf
->back
->bo
= gbm_bo_create_with_modifiers(&dri2_dpy
->gbm_dri
->base
,
212 surf
->base
.modifiers
,
215 dri2_surf
->back
->bo
= gbm_bo_create(&dri2_dpy
->gbm_dri
->base
,
222 if (dri2_surf
->back
->bo
== NULL
)
229 get_swrast_front_bo(struct dri2_egl_surface
*dri2_surf
)
231 struct dri2_egl_display
*dri2_dpy
=
232 dri2_egl_display(dri2_surf
->base
.Resource
.Display
);
233 struct gbm_dri_surface
*surf
= dri2_surf
->gbm_surf
;
235 if (dri2_surf
->current
== NULL
) {
236 assert(!dri2_surf
->color_buffers
[0].locked
);
237 dri2_surf
->current
= &dri2_surf
->color_buffers
[0];
240 if (dri2_surf
->current
->bo
== NULL
)
241 dri2_surf
->current
->bo
= gbm_bo_create(&dri2_dpy
->gbm_dri
->base
,
242 surf
->base
.width
, surf
->base
.height
,
243 surf
->base
.format
, surf
->base
.flags
);
244 if (dri2_surf
->current
->bo
== NULL
)
251 back_bo_to_dri_buffer(struct dri2_egl_surface
*dri2_surf
, __DRIbuffer
*buffer
)
253 struct dri2_egl_display
*dri2_dpy
=
254 dri2_egl_display(dri2_surf
->base
.Resource
.Display
);
255 struct gbm_dri_bo
*bo
;
258 bo
= (struct gbm_dri_bo
*) dri2_surf
->back
->bo
;
260 dri2_dpy
->image
->queryImage(bo
->image
, __DRI_IMAGE_ATTRIB_NAME
, &name
);
261 dri2_dpy
->image
->queryImage(bo
->image
, __DRI_IMAGE_ATTRIB_STRIDE
, &pitch
);
263 buffer
->attachment
= __DRI_BUFFER_BACK_LEFT
;
265 buffer
->pitch
= pitch
;
271 dri2_drm_get_buffers_with_format(__DRIdrawable
*driDrawable
,
272 int *width
, int *height
,
273 unsigned int *attachments
, int count
,
274 int *out_count
, void *loaderPrivate
)
276 struct dri2_egl_surface
*dri2_surf
= loaderPrivate
;
279 for (i
= 0, j
= 0; i
< 2 * count
; i
+= 2, j
++) {
282 assert(attachments
[i
] < __DRI_BUFFER_COUNT
);
283 assert(j
< ARRAY_SIZE(dri2_surf
->buffers
));
285 switch (attachments
[i
]) {
286 case __DRI_BUFFER_BACK_LEFT
:
287 if (get_back_bo(dri2_surf
) < 0) {
288 _eglError(EGL_BAD_ALLOC
, "failed to allocate color buffer");
291 back_bo_to_dri_buffer(dri2_surf
, &dri2_surf
->buffers
[j
]);
294 local
= dri2_egl_surface_alloc_local_buffer(dri2_surf
, attachments
[i
],
298 _eglError(EGL_BAD_ALLOC
, "failed to allocate local buffer");
301 dri2_surf
->buffers
[j
] = *local
;
310 *width
= dri2_surf
->base
.Width
;
311 *height
= dri2_surf
->base
.Height
;
313 return dri2_surf
->buffers
;
317 dri2_drm_get_buffers(__DRIdrawable
* driDrawable
,
318 int *width
, int *height
,
319 unsigned int *attachments
, int count
,
320 int *out_count
, void *loaderPrivate
)
322 unsigned int *attachments_with_format
;
324 const unsigned int format
= 32;
326 attachments_with_format
= calloc(count
, 2 * sizeof(unsigned int));
327 if (!attachments_with_format
) {
332 for (int i
= 0; i
< count
; ++i
) {
333 attachments_with_format
[2*i
] = attachments
[i
];
334 attachments_with_format
[2*i
+ 1] = format
;
338 dri2_drm_get_buffers_with_format(driDrawable
,
340 attachments_with_format
, count
,
341 out_count
, loaderPrivate
);
343 free(attachments_with_format
);
349 dri2_drm_image_get_buffers(__DRIdrawable
*driDrawable
,
353 uint32_t buffer_mask
,
354 struct __DRIimageList
*buffers
)
356 struct dri2_egl_surface
*dri2_surf
= loaderPrivate
;
357 struct gbm_dri_bo
*bo
;
359 if (get_back_bo(dri2_surf
) < 0)
362 bo
= (struct gbm_dri_bo
*) dri2_surf
->back
->bo
;
363 buffers
->image_mask
= __DRI_IMAGE_BUFFER_BACK
;
364 buffers
->back
= bo
->image
;
370 dri2_drm_flush_front_buffer(__DRIdrawable
* driDrawable
, void *loaderPrivate
)
373 (void) loaderPrivate
;
377 dri2_drm_swap_buffers(_EGLDriver
*drv
, _EGLDisplay
*disp
, _EGLSurface
*draw
)
379 struct dri2_egl_display
*dri2_dpy
= dri2_egl_display(disp
);
380 struct dri2_egl_surface
*dri2_surf
= dri2_egl_surface(draw
);
382 if (!dri2_dpy
->flush
) {
383 dri2_dpy
->core
->swapBuffers(dri2_surf
->dri_drawable
);
387 if (dri2_surf
->base
.Type
== EGL_WINDOW_BIT
) {
388 if (dri2_surf
->current
)
389 _eglError(EGL_BAD_SURFACE
, "dri2_swap_buffers");
390 for (unsigned i
= 0; i
< ARRAY_SIZE(dri2_surf
->color_buffers
); i
++)
391 if (dri2_surf
->color_buffers
[i
].age
> 0)
392 dri2_surf
->color_buffers
[i
].age
++;
394 /* Make sure we have a back buffer in case we're swapping without
396 if (get_back_bo(dri2_surf
) < 0)
397 return _eglError(EGL_BAD_ALLOC
, "dri2_swap_buffers");
399 dri2_surf
->current
= dri2_surf
->back
;
400 dri2_surf
->current
->age
= 1;
401 dri2_surf
->back
= NULL
;
404 dri2_flush_drawable_for_swapbuffers(disp
, draw
);
405 dri2_dpy
->flush
->invalidate(dri2_surf
->dri_drawable
);
411 dri2_drm_query_buffer_age(_EGLDriver
*drv
,
412 _EGLDisplay
*disp
, _EGLSurface
*surface
)
414 struct dri2_egl_surface
*dri2_surf
= dri2_egl_surface(surface
);
416 if (get_back_bo(dri2_surf
) < 0) {
417 _eglError(EGL_BAD_ALLOC
, "dri2_query_buffer_age");
421 return dri2_surf
->back
->age
;
425 dri2_drm_create_image_khr_pixmap(_EGLDisplay
*disp
, _EGLContext
*ctx
,
426 EGLClientBuffer buffer
, const EGLint
*attr_list
)
428 struct dri2_egl_display
*dri2_dpy
= dri2_egl_display(disp
);
429 struct gbm_dri_bo
*dri_bo
= gbm_dri_bo((struct gbm_bo
*) buffer
);
430 struct dri2_egl_image
*dri2_img
;
432 dri2_img
= malloc(sizeof *dri2_img
);
434 _eglError(EGL_BAD_ALLOC
, "dri2_create_image_khr_pixmap");
438 _eglInitImage(&dri2_img
->base
, disp
);
440 dri2_img
->dri_image
= dri2_dpy
->image
->dupImage(dri_bo
->image
, dri2_img
);
441 if (dri2_img
->dri_image
== NULL
) {
443 _eglError(EGL_BAD_ALLOC
, "dri2_create_image_khr_pixmap");
447 return &dri2_img
->base
;
451 dri2_drm_create_image_khr(_EGLDriver
*drv
, _EGLDisplay
*disp
,
452 _EGLContext
*ctx
, EGLenum target
,
453 EGLClientBuffer buffer
, const EGLint
*attr_list
)
458 case EGL_NATIVE_PIXMAP_KHR
:
459 return dri2_drm_create_image_khr_pixmap(disp
, ctx
, buffer
, attr_list
);
461 return dri2_create_image_khr(drv
, disp
, ctx
, target
, buffer
, attr_list
);
466 dri2_drm_authenticate(_EGLDisplay
*disp
, uint32_t id
)
468 struct dri2_egl_display
*dri2_dpy
= dri2_egl_display(disp
);
470 return drmAuthMagic(dri2_dpy
->fd
, id
);
474 swrast_put_image2(__DRIdrawable
*driDrawable
,
484 struct dri2_egl_surface
*dri2_surf
= loaderPrivate
;
486 struct gbm_dri_bo
*bo
;
488 int x_bytes
, width_bytes
;
491 if (op
!= __DRI_SWRAST_IMAGE_OP_DRAW
&&
492 op
!= __DRI_SWRAST_IMAGE_OP_SWAP
)
495 if (get_swrast_front_bo(dri2_surf
) < 0)
498 bo
= gbm_dri_bo(dri2_surf
->current
->bo
);
500 bpp
= gbm_bo_get_bpp(&bo
->base
);
504 x_bytes
= x
* (bpp
>> 3);
505 width_bytes
= width
* (bpp
>> 3);
507 if (gbm_dri_bo_map_dumb(bo
) == NULL
)
510 internal_stride
= bo
->base
.stride
;
512 dst
= bo
->map
+ x_bytes
+ (y
* internal_stride
);
515 for (int i
= 0; i
< height
; i
++) {
516 memcpy(dst
, src
, width_bytes
);
517 dst
+= internal_stride
;
521 gbm_dri_bo_unmap_dumb(bo
);
525 swrast_get_image(__DRIdrawable
*driDrawable
,
533 struct dri2_egl_surface
*dri2_surf
= loaderPrivate
;
534 int internal_stride
, stride
;
535 struct gbm_dri_bo
*bo
;
537 int x_bytes
, width_bytes
;
540 if (get_swrast_front_bo(dri2_surf
) < 0)
543 bo
= gbm_dri_bo(dri2_surf
->current
->bo
);
545 bpp
= gbm_bo_get_bpp(&bo
->base
);
549 x_bytes
= x
* (bpp
>> 3);
550 width_bytes
= width
* (bpp
>> 3);
552 internal_stride
= bo
->base
.stride
;
553 stride
= width_bytes
;
555 if (gbm_dri_bo_map_dumb(bo
) == NULL
)
559 src
= bo
->map
+ x_bytes
+ (y
* internal_stride
);
561 for (int i
= 0; i
< height
; i
++) {
562 memcpy(dst
, src
, width_bytes
);
564 src
+= internal_stride
;
567 gbm_dri_bo_unmap_dumb(bo
);
571 drm_add_configs_for_visuals(_EGLDriver
*drv
, _EGLDisplay
*disp
)
573 struct dri2_egl_display
*dri2_dpy
= dri2_egl_display(disp
);
574 static const struct {
576 unsigned int red_mask
;
577 unsigned int alpha_mask
;
579 { GBM_FORMAT_XRGB2101010
, 0x3ff00000, 0x00000000 },
580 { GBM_FORMAT_ARGB2101010
, 0x3ff00000, 0xc0000000 },
581 { GBM_FORMAT_XRGB8888
, 0x00ff0000, 0x00000000 },
582 { GBM_FORMAT_ARGB8888
, 0x00ff0000, 0xff000000 },
583 { GBM_FORMAT_RGB565
, 0x0000f800, 0x00000000 },
586 unsigned int format_count
[ARRAY_SIZE(visuals
)] = { 0 };
587 unsigned int config_count
= 0;
589 for (unsigned i
= 0; dri2_dpy
->driver_configs
[i
]; i
++) {
590 unsigned int red
, alpha
;
592 dri2_dpy
->core
->getConfigAttrib(dri2_dpy
->driver_configs
[i
],
593 __DRI_ATTRIB_RED_MASK
, &red
);
594 dri2_dpy
->core
->getConfigAttrib(dri2_dpy
->driver_configs
[i
],
595 __DRI_ATTRIB_ALPHA_MASK
, &alpha
);
597 for (unsigned j
= 0; j
< ARRAY_SIZE(visuals
); j
++) {
598 struct dri2_egl_config
*dri2_conf
;
600 if (visuals
[j
].red_mask
!= red
|| visuals
[j
].alpha_mask
!= alpha
)
603 const EGLint attr_list
[] = {
604 EGL_NATIVE_VISUAL_ID
, visuals
[j
].format
,
608 dri2_conf
= dri2_add_config(disp
, dri2_dpy
->driver_configs
[i
],
609 config_count
+ 1, EGL_WINDOW_BIT
, attr_list
, NULL
);
611 if (dri2_conf
->base
.ConfigID
== config_count
+ 1)
618 for (unsigned i
= 0; i
< ARRAY_SIZE(format_count
); i
++) {
619 if (!format_count
[i
]) {
620 _eglLog(_EGL_DEBUG
, "No DRI config supports native format 0x%x",
625 return (config_count
!= 0);
628 static const struct dri2_egl_display_vtbl dri2_drm_display_vtbl
= {
629 .authenticate
= dri2_drm_authenticate
,
630 .create_window_surface
= dri2_drm_create_window_surface
,
631 .create_pixmap_surface
= dri2_drm_create_pixmap_surface
,
632 .create_pbuffer_surface
= dri2_fallback_create_pbuffer_surface
,
633 .destroy_surface
= dri2_drm_destroy_surface
,
634 .create_image
= dri2_drm_create_image_khr
,
635 .swap_interval
= dri2_fallback_swap_interval
,
636 .swap_buffers
= dri2_drm_swap_buffers
,
637 .swap_buffers_with_damage
= dri2_fallback_swap_buffers_with_damage
,
638 .swap_buffers_region
= dri2_fallback_swap_buffers_region
,
639 .set_damage_region
= dri2_fallback_set_damage_region
,
640 .post_sub_buffer
= dri2_fallback_post_sub_buffer
,
641 .copy_buffers
= dri2_fallback_copy_buffers
,
642 .query_buffer_age
= dri2_drm_query_buffer_age
,
643 .create_wayland_buffer_from_image
= dri2_fallback_create_wayland_buffer_from_image
,
644 .get_sync_values
= dri2_fallback_get_sync_values
,
645 .get_dri_drawable
= dri2_surface_get_dri_drawable
,
649 dri2_initialize_drm(_EGLDriver
*drv
, _EGLDisplay
*disp
)
651 struct dri2_egl_display
*dri2_dpy
;
652 struct gbm_device
*gbm
;
655 loader_set_logger(_eglLog
);
657 dri2_dpy
= calloc(1, sizeof *dri2_dpy
);
659 return _eglError(EGL_BAD_ALLOC
, "eglInitialize");
662 disp
->DriverData
= (void *) dri2_dpy
;
664 gbm
= disp
->PlatformDisplay
;
667 int n
= snprintf(buf
, sizeof(buf
), DRM_DEV_NAME
, DRM_DIR_NAME
, 0);
668 if (n
!= -1 && n
< sizeof(buf
))
669 dri2_dpy
->fd
= loader_open_device(buf
);
670 if (dri2_dpy
->fd
< 0)
671 dri2_dpy
->fd
= loader_open_device("/dev/dri/card0");
672 gbm
= gbm_create_device(dri2_dpy
->fd
);
674 err
= "DRI2: failed to create gbm device";
677 dri2_dpy
->own_device
= true;
679 dri2_dpy
->fd
= fcntl(gbm_device_get_fd(gbm
), F_DUPFD_CLOEXEC
, 3);
680 if (dri2_dpy
->fd
< 0) {
681 err
= "DRI2: failed to fcntl() existing gbm device";
686 if (strcmp(gbm_device_get_backend_name(gbm
), "drm") != 0) {
687 err
= "DRI2: gbm device using incorrect/incompatible backend";
691 dri2_dpy
->gbm_dri
= gbm_dri_device(gbm
);
692 dri2_dpy
->driver_name
= strdup(dri2_dpy
->gbm_dri
->driver_name
);
694 dri2_dpy
->dri_screen
= dri2_dpy
->gbm_dri
->screen
;
695 dri2_dpy
->core
= dri2_dpy
->gbm_dri
->core
;
696 dri2_dpy
->dri2
= dri2_dpy
->gbm_dri
->dri2
;
697 dri2_dpy
->swrast
= dri2_dpy
->gbm_dri
->swrast
;
698 dri2_dpy
->driver_configs
= dri2_dpy
->gbm_dri
->driver_configs
;
700 dri2_dpy
->gbm_dri
->lookup_image
= dri2_lookup_egl_image
;
701 dri2_dpy
->gbm_dri
->lookup_user_data
= disp
;
703 dri2_dpy
->gbm_dri
->get_buffers
= dri2_drm_get_buffers
;
704 dri2_dpy
->gbm_dri
->flush_front_buffer
= dri2_drm_flush_front_buffer
;
705 dri2_dpy
->gbm_dri
->get_buffers_with_format
= dri2_drm_get_buffers_with_format
;
706 dri2_dpy
->gbm_dri
->image_get_buffers
= dri2_drm_image_get_buffers
;
707 dri2_dpy
->gbm_dri
->swrast_put_image2
= swrast_put_image2
;
708 dri2_dpy
->gbm_dri
->swrast_get_image
= swrast_get_image
;
710 dri2_dpy
->gbm_dri
->base
.surface_lock_front_buffer
= lock_front_buffer
;
711 dri2_dpy
->gbm_dri
->base
.surface_release_buffer
= release_buffer
;
712 dri2_dpy
->gbm_dri
->base
.surface_has_free_buffers
= has_free_buffers
;
714 if (!dri2_setup_extensions(disp
)) {
715 err
= "DRI2: failed to find required DRI extensions";
719 dri2_setup_screen(disp
);
721 if (!drm_add_configs_for_visuals(drv
, disp
)) {
722 err
= "DRI2: failed to add configs";
726 disp
->Extensions
.KHR_image_pixmap
= EGL_TRUE
;
728 disp
->Extensions
.EXT_buffer_age
= EGL_TRUE
;
730 #ifdef HAVE_WAYLAND_PLATFORM
731 dri2_dpy
->device_name
= loader_get_device_name_for_fd(dri2_dpy
->fd
);
733 dri2_set_WL_bind_wayland_display(drv
, disp
);
735 /* Fill vtbl last to prevent accidentally calling virtual function during
738 dri2_dpy
->vtbl
= &dri2_drm_display_vtbl
;
743 dri2_display_destroy(disp
);
744 return _eglError(EGL_NOT_INITIALIZED
, err
);