2 * Mesa 3-D graphics library
5 * Copyright (C) 2010-2011 Chia-I Wu <olvaffe@gmail.com>
6 * Copyright (C) 2010-2011 LunarG Inc.
8 * Based on platform_x11, which has
10 * Copyright © 2011 Intel Corporation
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 * DEALINGS IN THE SOFTWARE.
34 #if ANDROID_VERSION >= 0x402
35 #include <sync/sync.h>
38 /* for droid_get_pci_id */
41 #include <radeon_drm.h>
44 #include "gralloc_drm.h"
47 get_format_bpp(int native
)
52 case HAL_PIXEL_FORMAT_RGBA_8888
:
53 case HAL_PIXEL_FORMAT_RGBX_8888
:
54 case HAL_PIXEL_FORMAT_BGRA_8888
:
57 case HAL_PIXEL_FORMAT_RGB_888
:
60 case HAL_PIXEL_FORMAT_RGB_565
:
61 case HAL_PIXEL_FORMAT_RGBA_5551
:
62 case HAL_PIXEL_FORMAT_RGBA_4444
:
74 get_native_buffer_name(struct ANativeWindowBuffer
*buf
)
76 return gralloc_drm_get_gem_handle(buf
->handle
);
80 droid_window_dequeue_buffer(struct dri2_egl_surface
*dri2_surf
)
82 #if ANDROID_VERSION >= 0x0402
85 if (dri2_surf
->window
->dequeueBuffer(dri2_surf
->window
, &dri2_surf
->buffer
,
89 /* If access to the buffer is controlled by a sync fence, then block on the
92 * It may be more performant to postpone blocking until there is an
93 * immediate need to write to the buffer. But doing so would require adding
94 * hooks to the DRI2 loader.
96 * From the ANativeWindow::dequeueBuffer documentation:
98 * The libsync fence file descriptor returned in the int pointed to by
99 * the fenceFd argument will refer to the fence that must signal
100 * before the dequeued buffer may be written to. A value of -1
101 * indicates that the caller may access the buffer immediately without
102 * waiting on a fence. If a valid file descriptor is returned (i.e.
103 * any value except -1) then the caller is responsible for closing the
107 /* From the SYNC_IOC_WAIT documentation in <linux/sync.h>:
109 * Waits indefinitely if timeout < 0.
112 sync_wait(fence_fd
, timeout
);
116 dri2_surf
->buffer
->common
.incRef(&dri2_surf
->buffer
->common
);
118 if (dri2_surf
->window
->dequeueBuffer(dri2_surf
->window
, &dri2_surf
->buffer
))
121 dri2_surf
->buffer
->common
.incRef(&dri2_surf
->buffer
->common
);
122 dri2_surf
->window
->lockBuffer(dri2_surf
->window
, dri2_surf
->buffer
);
129 droid_window_enqueue_buffer(struct dri2_egl_surface
*dri2_surf
)
131 #if ANDROID_VERSION >= 0x0402
132 /* Queue the buffer without a sync fence. This informs the ANativeWindow
133 * that it may access the buffer immediately.
135 * From ANativeWindow::dequeueBuffer:
137 * The fenceFd argument specifies a libsync fence file descriptor for
138 * a fence that must signal before the buffer can be accessed. If
139 * the buffer can be accessed immediately then a value of -1 should
140 * be used. The caller must not use the file descriptor after it
141 * is passed to queueBuffer, and the ANativeWindow implementation
142 * is responsible for closing it.
145 dri2_surf
->window
->queueBuffer(dri2_surf
->window
, dri2_surf
->buffer
,
148 dri2_surf
->window
->queueBuffer(dri2_surf
->window
, dri2_surf
->buffer
);
151 dri2_surf
->buffer
->common
.decRef(&dri2_surf
->buffer
->common
);
152 dri2_surf
->buffer
= NULL
;
158 droid_window_cancel_buffer(struct dri2_egl_surface
*dri2_surf
)
160 /* no cancel buffer? */
161 droid_window_enqueue_buffer(dri2_surf
);
165 droid_alloc_local_buffer(struct dri2_egl_surface
*dri2_surf
,
166 unsigned int att
, unsigned int format
)
168 struct dri2_egl_display
*dri2_dpy
=
169 dri2_egl_display(dri2_surf
->base
.Resource
.Display
);
171 if (att
>= ARRAY_SIZE(dri2_surf
->local_buffers
))
174 if (!dri2_surf
->local_buffers
[att
]) {
175 dri2_surf
->local_buffers
[att
] =
176 dri2_dpy
->dri2
->allocateBuffer(dri2_dpy
->dri_screen
, att
, format
,
177 dri2_surf
->base
.Width
, dri2_surf
->base
.Height
);
180 return dri2_surf
->local_buffers
[att
];
184 droid_free_local_buffers(struct dri2_egl_surface
*dri2_surf
)
186 struct dri2_egl_display
*dri2_dpy
=
187 dri2_egl_display(dri2_surf
->base
.Resource
.Display
);
190 for (i
= 0; i
< ARRAY_SIZE(dri2_surf
->local_buffers
); i
++) {
191 if (dri2_surf
->local_buffers
[i
]) {
192 dri2_dpy
->dri2
->releaseBuffer(dri2_dpy
->dri_screen
,
193 dri2_surf
->local_buffers
[i
]);
194 dri2_surf
->local_buffers
[i
] = NULL
;
200 droid_create_surface(_EGLDriver
*drv
, _EGLDisplay
*disp
, EGLint type
,
201 _EGLConfig
*conf
, EGLNativeWindowType window
,
202 const EGLint
*attrib_list
)
204 struct dri2_egl_display
*dri2_dpy
= dri2_egl_display(disp
);
205 struct dri2_egl_config
*dri2_conf
= dri2_egl_config(conf
);
206 struct dri2_egl_surface
*dri2_surf
;
207 dri2_surf
= calloc(1, sizeof *dri2_surf
);
209 _eglError(EGL_BAD_ALLOC
, "droid_create_surface");
213 if (!_eglInitSurface(&dri2_surf
->base
, disp
, type
, conf
, attrib_list
))
214 goto cleanup_surface
;
216 if (type
== EGL_WINDOW_BIT
) {
219 if (!window
|| window
->common
.magic
!= ANDROID_NATIVE_WINDOW_MAGIC
) {
220 _eglError(EGL_BAD_NATIVE_WINDOW
, "droid_create_surface");
221 goto cleanup_surface
;
223 if (window
->query(window
, NATIVE_WINDOW_FORMAT
, &format
)) {
224 _eglError(EGL_BAD_NATIVE_WINDOW
, "droid_create_surface");
225 goto cleanup_surface
;
228 if (format
!= dri2_conf
->base
.NativeVisualID
) {
229 _eglLog(_EGL_WARNING
, "Native format mismatch: 0x%x != 0x%x",
230 format
, dri2_conf
->base
.NativeVisualID
);
233 window
->query(window
, NATIVE_WINDOW_WIDTH
, &dri2_surf
->base
.Width
);
234 window
->query(window
, NATIVE_WINDOW_HEIGHT
, &dri2_surf
->base
.Height
);
237 dri2_surf
->dri_drawable
=
238 (*dri2_dpy
->dri2
->createNewDrawable
)(dri2_dpy
->dri_screen
,
239 dri2_conf
->dri_double_config
,
241 if (dri2_surf
->dri_drawable
== NULL
) {
242 _eglError(EGL_BAD_ALLOC
, "dri2->createNewDrawable");
243 goto cleanup_surface
;
247 window
->common
.incRef(&window
->common
);
248 dri2_surf
->window
= window
;
251 return &dri2_surf
->base
;
260 droid_create_window_surface(_EGLDriver
*drv
, _EGLDisplay
*disp
,
261 _EGLConfig
*conf
, EGLNativeWindowType window
,
262 const EGLint
*attrib_list
)
264 return droid_create_surface(drv
, disp
, EGL_WINDOW_BIT
, conf
,
265 window
, attrib_list
);
269 droid_create_pixmap_surface(_EGLDriver
*drv
, _EGLDisplay
*disp
,
270 _EGLConfig
*conf
, EGLNativePixmapType pixmap
,
271 const EGLint
*attrib_list
)
277 droid_create_pbuffer_surface(_EGLDriver
*drv
, _EGLDisplay
*disp
,
278 _EGLConfig
*conf
, const EGLint
*attrib_list
)
280 return droid_create_surface(drv
, disp
, EGL_PBUFFER_BIT
, conf
,
285 droid_destroy_surface(_EGLDriver
*drv
, _EGLDisplay
*disp
, _EGLSurface
*surf
)
287 struct dri2_egl_display
*dri2_dpy
= dri2_egl_display(disp
);
288 struct dri2_egl_surface
*dri2_surf
= dri2_egl_surface(surf
);
290 if (!_eglPutSurface(surf
))
293 droid_free_local_buffers(dri2_surf
);
295 if (dri2_surf
->base
.Type
== EGL_WINDOW_BIT
) {
296 if (dri2_surf
->buffer
)
297 droid_window_cancel_buffer(dri2_surf
);
299 dri2_surf
->window
->common
.decRef(&dri2_surf
->window
->common
);
302 (*dri2_dpy
->core
->destroyDrawable
)(dri2_surf
->dri_drawable
);
310 droid_swap_buffers(_EGLDriver
*drv
, _EGLDisplay
*disp
, _EGLSurface
*draw
)
312 struct dri2_egl_driver
*dri2_drv
= dri2_egl_driver(drv
);
313 struct dri2_egl_display
*dri2_dpy
= dri2_egl_display(disp
);
314 struct dri2_egl_surface
*dri2_surf
= dri2_egl_surface(draw
);
317 if (dri2_surf
->base
.Type
!= EGL_WINDOW_BIT
)
320 if (dri2_drv
->glFlush
) {
321 ctx
= _eglGetCurrentContext();
322 if (ctx
&& ctx
->DrawSurface
== &dri2_surf
->base
)
326 (*dri2_dpy
->flush
->flush
)(dri2_surf
->dri_drawable
);
328 if (dri2_surf
->buffer
)
329 droid_window_enqueue_buffer(dri2_surf
);
331 (*dri2_dpy
->flush
->invalidate
)(dri2_surf
->dri_drawable
);
337 dri2_create_image_android_native_buffer(_EGLDisplay
*disp
,
338 struct ANativeWindowBuffer
*buf
)
340 struct dri2_egl_display
*dri2_dpy
= dri2_egl_display(disp
);
341 struct dri2_egl_image
*dri2_img
;
345 if (!buf
|| buf
->common
.magic
!= ANDROID_NATIVE_BUFFER_MAGIC
||
346 buf
->common
.version
!= sizeof(*buf
)) {
347 _eglError(EGL_BAD_PARAMETER
, "eglCreateEGLImageKHR");
351 name
= get_native_buffer_name(buf
);
353 _eglError(EGL_BAD_PARAMETER
, "eglCreateEGLImageKHR");
357 /* see the table in droid_add_configs_for_visuals */
358 switch (buf
->format
) {
359 case HAL_PIXEL_FORMAT_BGRA_8888
:
360 format
= __DRI_IMAGE_FORMAT_ARGB8888
;
362 case HAL_PIXEL_FORMAT_RGB_565
:
363 format
= __DRI_IMAGE_FORMAT_RGB565
;
365 case HAL_PIXEL_FORMAT_RGBA_8888
:
366 format
= __DRI_IMAGE_FORMAT_ABGR8888
;
368 case HAL_PIXEL_FORMAT_RGBX_8888
:
369 format
= __DRI_IMAGE_FORMAT_XBGR8888
;
371 case HAL_PIXEL_FORMAT_RGB_888
:
372 case HAL_PIXEL_FORMAT_RGBA_5551
:
373 case HAL_PIXEL_FORMAT_RGBA_4444
:
376 _eglLog(_EGL_WARNING
, "unsupported native buffer format 0x%x", buf
->format
);
381 dri2_img
= calloc(1, sizeof(*dri2_img
));
383 _eglError(EGL_BAD_ALLOC
, "droid_create_image_mesa_drm");
387 if (!_eglInitImage(&dri2_img
->base
, disp
)) {
392 dri2_img
->dri_image
=
393 dri2_dpy
->image
->createImageFromName(dri2_dpy
->dri_screen
,
400 if (!dri2_img
->dri_image
) {
402 _eglError(EGL_BAD_ALLOC
, "droid_create_image_mesa_drm");
406 return &dri2_img
->base
;
410 droid_create_image_khr(_EGLDriver
*drv
, _EGLDisplay
*disp
,
411 _EGLContext
*ctx
, EGLenum target
,
412 EGLClientBuffer buffer
, const EGLint
*attr_list
)
415 case EGL_NATIVE_BUFFER_ANDROID
:
416 return dri2_create_image_android_native_buffer(disp
,
417 (struct ANativeWindowBuffer
*) buffer
);
419 return dri2_create_image_khr(drv
, disp
, ctx
, target
, buffer
, attr_list
);
424 droid_init_driver_functions(_EGLDriver
*drv
)
426 drv
->API
.CreateWindowSurface
= droid_create_window_surface
;
427 drv
->API
.CreatePixmapSurface
= droid_create_pixmap_surface
;
428 drv
->API
.CreatePbufferSurface
= droid_create_pbuffer_surface
;
429 drv
->API
.DestroySurface
= droid_destroy_surface
;
430 drv
->API
.SwapBuffers
= droid_swap_buffers
;
432 drv
->API
.CreateImageKHR
= droid_create_image_khr
;
436 droid_flush_front_buffer(__DRIdrawable
* driDrawable
, void *loaderPrivate
)
441 droid_get_buffers_parse_attachments(struct dri2_egl_surface
*dri2_surf
,
442 unsigned int *attachments
, int count
)
444 int num_buffers
= 0, i
;
446 /* fill dri2_surf->buffers */
447 for (i
= 0; i
< count
* 2; i
+= 2) {
448 __DRIbuffer
*buf
, *local
;
450 assert(num_buffers
< ARRAY_SIZE(dri2_surf
->buffers
));
451 buf
= &dri2_surf
->buffers
[num_buffers
];
453 switch (attachments
[i
]) {
454 case __DRI_BUFFER_BACK_LEFT
:
455 if (dri2_surf
->base
.Type
== EGL_WINDOW_BIT
) {
456 buf
->attachment
= attachments
[i
];
457 buf
->name
= get_native_buffer_name(dri2_surf
->buffer
);
458 buf
->cpp
= get_format_bpp(dri2_surf
->buffer
->format
);
459 buf
->pitch
= dri2_surf
->buffer
->stride
* buf
->cpp
;
467 /* fall through for pbuffers */
468 case __DRI_BUFFER_DEPTH
:
469 case __DRI_BUFFER_STENCIL
:
470 case __DRI_BUFFER_ACCUM
:
471 case __DRI_BUFFER_DEPTH_STENCIL
:
472 case __DRI_BUFFER_HIZ
:
473 local
= droid_alloc_local_buffer(dri2_surf
,
474 attachments
[i
], attachments
[i
+ 1]);
481 case __DRI_BUFFER_FRONT_LEFT
:
482 case __DRI_BUFFER_FRONT_RIGHT
:
483 case __DRI_BUFFER_FAKE_FRONT_LEFT
:
484 case __DRI_BUFFER_FAKE_FRONT_RIGHT
:
485 case __DRI_BUFFER_BACK_RIGHT
:
487 /* no front or right buffers */
496 droid_get_buffers_with_format(__DRIdrawable
* driDrawable
,
497 int *width
, int *height
,
498 unsigned int *attachments
, int count
,
499 int *out_count
, void *loaderPrivate
)
501 struct dri2_egl_surface
*dri2_surf
= loaderPrivate
;
502 struct dri2_egl_display
*dri2_dpy
=
503 dri2_egl_display(dri2_surf
->base
.Resource
.Display
);
506 if (dri2_surf
->base
.Type
== EGL_WINDOW_BIT
) {
507 /* try to dequeue the next back buffer */
508 if (!dri2_surf
->buffer
&& !droid_window_dequeue_buffer(dri2_surf
))
511 /* free outdated buffers and update the surface size */
512 if (dri2_surf
->base
.Width
!= dri2_surf
->buffer
->width
||
513 dri2_surf
->base
.Height
!= dri2_surf
->buffer
->height
) {
514 droid_free_local_buffers(dri2_surf
);
515 dri2_surf
->base
.Width
= dri2_surf
->buffer
->width
;
516 dri2_surf
->base
.Height
= dri2_surf
->buffer
->height
;
520 dri2_surf
->buffer_count
=
521 droid_get_buffers_parse_attachments(dri2_surf
, attachments
, count
);
524 *width
= dri2_surf
->base
.Width
;
526 *height
= dri2_surf
->base
.Height
;
528 *out_count
= dri2_surf
->buffer_count
;;
530 return dri2_surf
->buffers
;
534 droid_add_configs_for_visuals(_EGLDriver
*drv
, _EGLDisplay
*dpy
)
536 struct dri2_egl_display
*dri2_dpy
= dri2_egl_display(dpy
);
540 unsigned int rgba_masks
[4];
542 { HAL_PIXEL_FORMAT_RGBA_8888
, 32, { 0xff, 0xff00, 0xff0000, 0xff000000 } },
543 { HAL_PIXEL_FORMAT_RGBX_8888
, 32, { 0xff, 0xff00, 0xff0000, 0x0 } },
544 { HAL_PIXEL_FORMAT_RGB_888
, 24, { 0xff, 0xff00, 0xff0000, 0x0 } },
545 { HAL_PIXEL_FORMAT_RGB_565
, 16, { 0xf800, 0x7e0, 0x1f, 0x0 } },
546 { HAL_PIXEL_FORMAT_BGRA_8888
, 32, { 0xff0000, 0xff00, 0xff, 0xff000000 } },
547 { 0, 0, { 0, 0, 0, 0 } }
552 for (i
= 0; visuals
[i
].format
; i
++) {
553 int format_count
= 0;
555 for (j
= 0; dri2_dpy
->driver_configs
[j
]; j
++) {
556 const EGLint surface_type
= EGL_WINDOW_BIT
| EGL_PBUFFER_BIT
;
557 struct dri2_egl_config
*dri2_conf
;
558 unsigned int double_buffered
= 0;
560 dri2_dpy
->core
->getConfigAttrib(dri2_dpy
->driver_configs
[j
],
561 __DRI_ATTRIB_DOUBLE_BUFFER
, &double_buffered
);
563 /* support only double buffered configs */
564 if (!double_buffered
)
567 dri2_conf
= dri2_add_config(dpy
, dri2_dpy
->driver_configs
[j
],
568 count
+ 1, visuals
[i
].size
, surface_type
, NULL
,
569 visuals
[i
].rgba_masks
);
571 dri2_conf
->base
.NativeVisualID
= visuals
[i
].format
;
572 dri2_conf
->base
.NativeVisualType
= visuals
[i
].format
;
579 _eglLog(_EGL_DEBUG
, "No DRI config supports native format 0x%x",
584 /* post-process configs */
585 for (i
= 0; i
< dpy
->Configs
->Size
; i
++) {
586 struct dri2_egl_config
*dri2_conf
= dri2_egl_config(dpy
->Configs
->Elements
[i
]);
588 /* there is no front buffer so no OpenGL */
589 dri2_conf
->base
.RenderableType
&= ~EGL_OPENGL_BIT
;
590 dri2_conf
->base
.Conformant
&= ~EGL_OPENGL_BIT
;
597 droid_get_pci_id(int fd
, int *vendor_id
, int *chip_id
)
599 drmVersionPtr version
;
603 version
= drmGetVersion(fd
);
605 _eglLog(_EGL_WARNING
, "invalid drm fd");
608 if (!version
->name
) {
609 _eglLog(_EGL_WARNING
, "unable to determine the driver name");
610 drmFreeVersion(version
);
614 if (strcmp(version
->name
, "i915") == 0) {
615 struct drm_i915_getparam gp
;
620 memset(&gp
, 0, sizeof(gp
));
621 gp
.param
= I915_PARAM_CHIPSET_ID
;
623 ret
= drmCommandWriteRead(fd
, DRM_I915_GETPARAM
, &gp
, sizeof(gp
));
625 _eglLog(_EGL_WARNING
, "failed to get param for i915");
629 else if (strcmp(version
->name
, "radeon") == 0) {
630 struct drm_radeon_info info
;
635 memset(&info
, 0, sizeof(info
));
636 info
.request
= RADEON_INFO_DEVICE_ID
;
637 info
.value
= (unsigned long) chip_id
;
638 ret
= drmCommandWriteRead(fd
, DRM_RADEON_INFO
, &info
, sizeof(info
));
640 _eglLog(_EGL_WARNING
, "failed to get info for radeon");
644 else if (strcmp(version
->name
, "nouveau") == 0) {
649 else if (strcmp(version
->name
, "vmwgfx") == 0) {
655 drmFreeVersion(version
);
657 return (*chip_id
>= 0);
660 #define DRIVER_MAP_DRI2_ONLY
661 #include "pci_ids/pci_id_driver_map.h"
663 droid_get_driver_name(int fd
)
665 int vendor_id
= -1, chip_id
= -1;
669 if (!droid_get_pci_id(fd
, &vendor_id
, &chip_id
))
672 for (idx
= 0; driver_map
[idx
].driver
; idx
++) {
673 if (vendor_id
!= driver_map
[idx
].vendor_id
)
676 if (driver_map
[idx
].num_chips_ids
== -1)
679 for (i
= 0; i
< driver_map
[idx
].num_chips_ids
; i
++) {
680 if (driver_map
[idx
].chip_ids
[i
] == chip_id
)
683 if (i
< driver_map
[idx
].num_chips_ids
)
687 _eglLog(_EGL_INFO
, "pci id for fd %d: %04x:%04x, driver %s",
688 fd
, vendor_id
, chip_id
, driver_map
[idx
].driver
);
690 return driver_map
[idx
].driver
;
694 droid_open_device(void)
696 const hw_module_t
*mod
;
699 err
= hw_get_module(GRALLOC_HARDWARE_MODULE_ID
, &mod
);
701 const gralloc_module_t
*gr
= (gralloc_module_t
*) mod
;
705 err
= gr
->perform(gr
, GRALLOC_MODULE_PERFORM_GET_DRM_FD
, &fd
);
708 _eglLog(_EGL_WARNING
, "fail to get drm fd");
712 return (fd
>= 0) ? dup(fd
) : -1;
715 /* support versions < JellyBean */
727 droid_log(EGLint level
, const char *msg
)
740 LOG_FATAL("%s", msg
);
748 dri2_initialize_android(_EGLDriver
*drv
, _EGLDisplay
*dpy
)
750 struct dri2_egl_display
*dri2_dpy
;
753 _eglSetLogProc(droid_log
);
755 dri2_dpy
= calloc(1, sizeof(*dri2_dpy
));
757 return _eglError(EGL_BAD_ALLOC
, "eglInitialize");
759 dpy
->DriverData
= (void *) dri2_dpy
;
761 dri2_dpy
->fd
= droid_open_device();
762 if (dri2_dpy
->fd
< 0) {
763 err
= "DRI2: failed to open device";
764 goto cleanup_display
;
767 dri2_dpy
->driver_name
= (char *) droid_get_driver_name(dri2_dpy
->fd
);
768 if (dri2_dpy
->driver_name
== NULL
) {
769 err
= "DRI2: failed to get driver name";
773 if (!dri2_load_driver(dpy
)) {
774 err
= "DRI2: failed to load driver";
778 dri2_dpy
->dri2_loader_extension
.base
.name
= __DRI_DRI2_LOADER
;
779 dri2_dpy
->dri2_loader_extension
.base
.version
= 3;
780 dri2_dpy
->dri2_loader_extension
.getBuffers
= NULL
;
781 dri2_dpy
->dri2_loader_extension
.flushFrontBuffer
= droid_flush_front_buffer
;
782 dri2_dpy
->dri2_loader_extension
.getBuffersWithFormat
=
783 droid_get_buffers_with_format
;
785 dri2_dpy
->extensions
[0] = &dri2_dpy
->dri2_loader_extension
.base
;
786 dri2_dpy
->extensions
[1] = &image_lookup_extension
.base
;
787 dri2_dpy
->extensions
[2] = &use_invalidate
.base
;
788 dri2_dpy
->extensions
[3] = NULL
;
790 if (!dri2_create_screen(dpy
)) {
791 err
= "DRI2: failed to create screen";
795 if (!droid_add_configs_for_visuals(drv
, dpy
)) {
796 err
= "DRI2: failed to add configs";
800 dpy
->Extensions
.ANDROID_image_native_buffer
= EGL_TRUE
;
801 dpy
->Extensions
.KHR_image_base
= EGL_TRUE
;
803 /* we're supporting EGL 1.4 */
804 dpy
->VersionMajor
= 1;
805 dpy
->VersionMinor
= 4;
807 droid_init_driver_functions(drv
);
812 dri2_dpy
->core
->destroyScreen(dri2_dpy
->dri_screen
);
814 dlclose(dri2_dpy
->driver
);
820 return _eglError(EGL_NOT_INITIALIZED
, err
);