diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 7256d54a5e0..1c9399ccd2a 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -3117,9 +3117,10 @@ dri2_wl_reference_buffer(void *user_data, uint32_t name, int fd, dri2_dpy->dri_screen_render_gpu, buffer->width, buffer->height, buffer->format, (int *)&name, 1, buffer->stride, buffer->offset, NULL); else - img = dri2_dpy->image->createImageFromFds2( + img = dri2_dpy->image->createImageFromDmaBufs( dri2_dpy->dri_screen_render_gpu, buffer->width, buffer->height, - buffer->format, &fd, 1, 0, buffer->stride, buffer->offset, NULL); + buffer->format, DRM_FORMAT_MOD_INVALID, &fd, 1, buffer->stride, + buffer->offset, 0, 0, 0, 0, 0, NULL, NULL); if (img == NULL) return; @@ -3172,8 +3173,7 @@ dri2_bind_wayland_display_wl(_EGLDisplay *disp, struct wl_display *wl_dpy) if (drmGetCap(dri2_dpy->fd_render_gpu, DRM_CAP_PRIME, &cap) == 0 && cap == (DRM_PRIME_CAP_IMPORT | DRM_PRIME_CAP_EXPORT) && - dri2_dpy->image->base.version >= 7 && - dri2_dpy->image->createImageFromFds != NULL) + dri2_dpy->image->createImageFromDmaBufs != NULL) flags |= WAYLAND_DRM_PRIME; dri2_dpy->wl_server_drm = diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c index 294cd1898e5..1c642516b37 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -2316,12 +2316,12 @@ dri2_initialize_wayland_drm(_EGLDisplay *disp) dri2_wl_setup_swap_interval(disp); if (dri2_dpy->wl_drm) { - /* To use Prime, we must have _DRI_IMAGE v7 at least. createImageFromFds - * support indicates that Prime export/import is supported by the driver. - * We deprecated the support to GEM names API, so we bail out if the - * driver does not support Prime. */ + /* To use Prime, we must have _DRI_IMAGE v7 at least. + * createImageFromDmaBufs support indicates that Prime export/import is + * supported by the driver. We deprecated the support to GEM names API, so + * we bail out if the driver does not support Prime. */ if (!(dri2_dpy->capabilities & WL_DRM_CAPABILITY_PRIME) || - (dri2_dpy->image->createImageFromFds == NULL)) { + (dri2_dpy->image->createImageFromDmaBufs == NULL)) { _eglLog(_EGL_WARNING, "wayland-egl: display does not support prime"); goto cleanup; } diff --git a/src/gallium/frontends/dri/dri2.c b/src/gallium/frontends/dri/dri2.c index 1db72708b9c..852aa7b8fc0 100644 --- a/src/gallium/frontends/dri/dri2.c +++ b/src/gallium/frontends/dri/dri2.c @@ -1842,21 +1842,25 @@ dri2_from_dma_bufs(__DRIscreen *screen, enum __DRISampleRange sample_range, enum __DRIChromaSiting horizontal_siting, enum __DRIChromaSiting vertical_siting, - uint32_t flags, + uint32_t dri_flags, unsigned *error, void *loaderPrivate) { - unsigned bind = 0; __DRIimage *img; + /* Allow a NULL error arg since many callers don't care. */ + unsigned unused_error; + if (!error) + error = &unused_error; - if (flags & __DRI_IMAGE_PROTECTED_CONTENT_FLAG) - bind |= PIPE_BIND_PROTECTED; - if (flags & __DRI_IMAGE_PRIME_LINEAR_BUFFER) - bind |= PIPE_BIND_PRIME_BLIT_DST; + uint32_t flags = 0; + if (dri_flags & __DRI_IMAGE_PROTECTED_CONTENT_FLAG) + flags |= PIPE_BIND_PROTECTED; + if (dri_flags & __DRI_IMAGE_PRIME_LINEAR_BUFFER) + flags |= PIPE_BIND_PRIME_BLIT_DST; img = dri2_create_image_from_fd(screen, width, height, fourcc, modifier, fds, num_fds, strides, offsets, - bind, error, loaderPrivate); + flags, error, loaderPrivate); if (img == NULL) return NULL; @@ -2115,6 +2119,7 @@ const __DRIimageExtension driVkImageExtensionSw = { .createImageFromTexture = dri2_create_from_texture, .createImageFromFds = dri2_from_fds, .createImageFromFds2 = dri2_from_fds2, + .createImageFromDmaBufs = dri2_from_dma_bufs, .blitImage = dri2_blit_image, .getCapabilities = dri2_get_capabilities, .mapImage = dri2_map_image, diff --git a/src/gallium/frontends/dri/kopper.c b/src/gallium/frontends/dri/kopper.c index f7c96290149..4bd6a67f4b5 100644 --- a/src/gallium/frontends/dri/kopper.c +++ b/src/gallium/frontends/dri/kopper.c @@ -278,17 +278,19 @@ dri3_create_image(xcb_connection_t *c, stride = bp_reply->stride; offset = 0; - /* createImageFromFds creates a wrapper __DRIimage structure which + /* createImageFromDmaBufs creates a wrapper __DRIimage structure which * can deal with multiple planes for things like Yuv images. So, once * we've gotten the planar wrapper, pull the single plane out of it and * discard the wrapper. */ - image_planar = image->createImageFromFds2(opaque_dri_screen(screen), - bp_reply->width, - bp_reply->height, - fourcc, - fds, 1, - 0, &stride, &offset, loaderPrivate); + image_planar = image->createImageFromDmaBufs(opaque_dri_screen(screen), + bp_reply->width, + bp_reply->height, + fourcc, + DRM_FORMAT_MOD_INVALID, fds, 1, + &stride, &offset, + 0, 0, 0, 0, 0, + NULL, loaderPrivate); close(fds[0]); if (!image_planar) return NULL; @@ -328,7 +330,7 @@ handle_in_fence(struct dri_context *ctx, __DRIimage *img) /** kopper_get_pixmap_buffer * * Get the DRM object for a pixmap from the X server and - * wrap that with a __DRIimage structure using createImageFromFds + * wrap that with a __DRIimage structure using createImageFromDmaBufs */ static struct pipe_resource * kopper_get_pixmap_buffer(struct dri_drawable *drawable, diff --git a/src/gallium/include/mesa_interface.h b/src/gallium/include/mesa_interface.h index 12d31a980c3..591c1c8da3f 100644 --- a/src/gallium/include/mesa_interface.h +++ b/src/gallium/include/mesa_interface.h @@ -1676,7 +1676,7 @@ struct __DRIimageExtensionRec { unsigned *error); /** - * Like createImageFromFds, but takes additional attributes. + * Creates a DRI image from an array of dmabuf fds and their modifiers. * * See __DRI_IMAGE_*_FLAG for valid definitions of flags. */ diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c index a70edcd61ef..24f3c0bcb55 100644 --- a/src/gbm/backends/dri/gbm_dri.c +++ b/src/gbm/backends/dri/gbm_dri.c @@ -778,18 +778,19 @@ gbm_dri_bo_import(struct gbm_device *gbm, int fourcc; /* GBM's GBM_FORMAT_* tokens are a strict superset of the DRI FourCC - * tokens accepted by createImageFromFds, except for not supporting + * tokens accepted by createImageFromDmaBufs, except for not supporting * the sARGB format. */ fourcc = gbm_core.v0.format_canonicalize(fd_data->format); - image = dri->image->createImageFromFds2(dri->screen, - fd_data->width, - fd_data->height, - fourcc, - &fd_data->fd, 1, - 0, - &stride, &offset, - NULL); + image = dri->image->createImageFromDmaBufs(dri->screen, + fd_data->width, + fd_data->height, + fourcc, + DRM_FORMAT_MOD_INVALID, + &fd_data->fd, 1, + &stride, &offset, + 0, 0, 0, 0, 0, + NULL, NULL); if (image == NULL) { errno = EINVAL; return NULL; diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c index d27432896f6..2d3dd404571 100644 --- a/src/glx/dri3_glx.c +++ b/src/glx/dri3_glx.c @@ -891,8 +891,8 @@ dri3_create_screen(int screen, struct glx_display * priv, bool driver_name_is_in dri3_bind_extensions(psc, priv, driverName); - if (!psc->image || psc->image->base.version < 7 || !psc->image->createImageFromFds) { - ErrorMessageF("Version 7 or imageFromFds image extension not found\n"); + if (!psc->image || !psc->image->createImageFromDmaBufs) { + ErrorMessageF("Version 7 or imageFromDmaBufs image extension not found\n"); goto handle_error; } diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c index a04ce6f94fa..177bad87d31 100644 --- a/src/loader/loader_dri3_helper.c +++ b/src/loader/loader_dri3_helper.c @@ -1618,15 +1618,16 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int format, * need to make it visible to render GPU */ buffer->linear_buffer = - draw->ext->image->createImageFromFds2(draw->dri_screen_render_gpu, - width, - height, - loader_image_format_to_fourcc(format), - &buffer_fds[0], num_planes, - __DRI_IMAGE_PRIME_LINEAR_BUFFER, - &buffer->strides[0], - &buffer->offsets[0], - buffer); + draw->ext->image->createImageFromDmaBufs(draw->dri_screen_render_gpu, + width, + height, + loader_image_format_to_fourcc(format), + DRM_FORMAT_MOD_INVALID, + &buffer_fds[0], num_planes, + &buffer->strides[0], + &buffer->offsets[0], + 0, 0, 0, 0, __DRI_IMAGE_PRIME_LINEAR_BUFFER, + NULL, buffer); if (!buffer->linear_buffer) goto no_buffer_attrib; @@ -1839,17 +1840,20 @@ loader_dri3_create_image(xcb_connection_t *c, stride = bp_reply->stride; offset = 0; - /* createImageFromFds creates a wrapper __DRIimage structure which + /* createImageFromDmaBufs creates a wrapper __DRIimage structure which * can deal with multiple planes for things like Yuv images. So, once * we've gotten the planar wrapper, pull the single plane out of it and * discard the wrapper. */ - image_planar = image->createImageFromFds2(dri_screen, - bp_reply->width, - bp_reply->height, - loader_image_format_to_fourcc(format), - fds, 1, - 0, &stride, &offset, loaderPrivate); + image_planar = image->createImageFromDmaBufs(dri_screen, + bp_reply->width, + bp_reply->height, + loader_image_format_to_fourcc(format), + DRM_FORMAT_MOD_INVALID, + fds, 1, + &stride, &offset, + 0, 0, 0, 0, 0, + NULL, loaderPrivate); close(fds[0]); if (!image_planar) return NULL; @@ -1911,7 +1915,7 @@ loader_dri3_create_image_from_buffers(xcb_connection_t *c, /** dri3_get_pixmap_buffer * * Get the DRM object for a pixmap from the X server and - * wrap that with a __DRIimage structure using createImageFromFds + * wrap that with a __DRIimage structure using createImageFromDmaBufs */ static struct loader_dri3_buffer * dri3_get_pixmap_buffer(__DRIdrawable *driDrawable, unsigned int format, diff --git a/src/loader/loader_dri_helper.c b/src/loader/loader_dri_helper.c index e8d36765389..145452e2d12 100644 --- a/src/loader/loader_dri_helper.c +++ b/src/loader/loader_dri_helper.c @@ -116,9 +116,9 @@ bool dri_valid_swap_interval(__DRIscreen *driScreen, } /* the DRIimage createImage function takes __DRI_IMAGE_FORMAT codes, while - * the createImageFromFds call takes DRM_FORMAT codes. To avoid + * the createImageFromDmaBufs call takes DRM_FORMAT codes. To avoid * complete confusion, just deal in __DRI_IMAGE_FORMAT codes for now and - * translate to DRM_FORMAT codes in the call to createImageFromFds + * translate to DRM_FORMAT codes in the call to createImageFromDmaBufs */ int loader_image_format_to_fourcc(int format)