diff options
Diffstat (limited to 'src/egl/drivers/dri2/egl_dri2.c')
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index b7749196c5d..a3aabf5ab51 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -320,7 +320,7 @@ static struct dri2_extension_match dri2_driver_extensions[] = { static struct dri2_extension_match dri2_core_extensions[] = { { __DRI2_FLUSH, 1, offsetof(struct dri2_egl_display, flush) }, { __DRI_TEX_BUFFER, 2, offsetof(struct dri2_egl_display, tex_buffer) }, - { __DRI_IMAGE, 1, offsetof(struct dri2_egl_display, image) }, + { __DRI_IMAGE, 7, offsetof(struct dri2_egl_display, image) }, { NULL, 0, 0 } }; @@ -1498,7 +1498,7 @@ dri2_export_drm_image_mesa(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img, #ifdef HAVE_WAYLAND_PLATFORM static void -dri2_wl_reference_buffer(void *user_data, uint32_t name, +dri2_wl_reference_buffer(void *user_data, uint32_t name, int fd, struct wl_drm_buffer *buffer) { _EGLDisplay *disp = user_data; @@ -1506,13 +1506,24 @@ dri2_wl_reference_buffer(void *user_data, uint32_t name, __DRIimage *img; int i, dri_components = 0; - img = dri2_dpy->image->createImageFromNames(dri2_dpy->dri_screen, - buffer->buffer.width, - buffer->buffer.height, - buffer->format, (int*)&name, 1, - buffer->stride, - buffer->offset, - NULL); + if (fd == -1) + img = dri2_dpy->image->createImageFromNames(dri2_dpy->dri_screen, + buffer->buffer.width, + buffer->buffer.height, + buffer->format, + (int*)&name, 1, + buffer->stride, + buffer->offset, + NULL); + else + img = dri2_dpy->image->createImageFromFds(dri2_dpy->dri_screen, + buffer->buffer.width, + buffer->buffer.height, + buffer->format, + &fd, 1, + buffer->stride, + buffer->offset, + NULL); if (img == NULL) return; @@ -1550,6 +1561,8 @@ dri2_bind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp, struct wl_display *wl_dpy) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + int ret, flags = 0; + uint64_t cap; (void) drv; @@ -1559,9 +1572,13 @@ dri2_bind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp, wl_drm_callbacks.authenticate = (int(*)(void *, uint32_t)) dri2_dpy->authenticate; + ret = drmGetCap(dri2_dpy->fd, DRM_CAP_PRIME, &cap); + if (ret == 0 && cap == (DRM_PRIME_CAP_IMPORT | DRM_PRIME_CAP_EXPORT)) + flags |= WAYLAND_DRM_PRIME; + dri2_dpy->wl_server_drm = wayland_drm_init(wl_dpy, dri2_dpy->device_name, - &wl_drm_callbacks, disp); + &wl_drm_callbacks, disp, flags); if (!dri2_dpy->wl_server_drm) return EGL_FALSE; |