Mesa (main): gallium/dri: add createImageFromFds2
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Oct 18 15:59:44 UTC 2021
Module: Mesa
Branch: main
Commit: 7a5de842499b31161f5db702446d1fe8081d7956
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7a5de842499b31161f5db702446d1fe8081d7956
Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date: Thu Oct 14 15:09:49 2021 +0200
gallium/dri: add createImageFromFds2
Same as createImageFromFds but with added flags so the caller can give
the driver more context.
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13362>
---
include/GL/internal/dri_interface.h | 18 ++++++++++++++++--
src/gallium/frontends/dri/dri2.c | 18 +++++++++++++++++-
2 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
index 49ea14f3c2c..cd30046fde2 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -1237,7 +1237,7 @@ struct __DRIdri2ExtensionRec {
* extensions.
*/
#define __DRI_IMAGE "DRI_IMAGE"
-#define __DRI_IMAGE_VERSION 19
+#define __DRI_IMAGE_VERSION 20
/**
* These formats correspond to the similarly named MESA_FORMAT_*
@@ -1408,7 +1408,7 @@ enum __DRIChromaSiting {
#define __BLIT_FLAG_FINISH 0x0002
/**
- * Flags for createImageFromDmaBufs3
+ * Flags for createImageFromDmaBufs3 and createImageFromFds2
*/
#define __DRI_IMAGE_PROTECTED_CONTENT_FLAG 0x00000001
@@ -1738,6 +1738,20 @@ struct __DRIimageExtensionRec {
const unsigned int modifier_count,
unsigned int use,
void *loaderPrivate);
+
+ /**
+ * Like createImageFromFds, but with an added flag parameter.
+ *
+ * See __DRI_IMAGE_*_FLAG for valid definitions of flags.
+ *
+ * \since 20
+ */
+ __DRIimage *(*createImageFromFds2)(__DRIscreen *screen,
+ int width, int height, int fourcc,
+ int *fds, int num_fds,
+ uint32_t flags,
+ int *strides, int *offsets,
+ void *loaderPrivate);
};
diff --git a/src/gallium/frontends/dri/dri2.c b/src/gallium/frontends/dri/dri2.c
index fa088e79f97..8c8630586eb 100644
--- a/src/gallium/frontends/dri/dri2.c
+++ b/src/gallium/frontends/dri/dri2.c
@@ -1518,6 +1518,20 @@ dri2_from_fds(__DRIscreen *screen, int width, int height, int fourcc,
strides, offsets, 0, NULL, loaderPrivate);
}
+static __DRIimage *
+dri2_from_fds2(__DRIscreen *screen, int width, int height, int fourcc,
+ int *fds, int num_fds, uint32_t flags, int *strides,
+ int *offsets, void *loaderPrivate)
+{
+ unsigned bind = 0;
+ if (flags & __DRI_IMAGE_PROTECTED_CONTENT_FLAG)
+ bind |= PIPE_BIND_PROTECTED;
+
+ return dri2_create_image_from_fd(screen, width, height, fourcc,
+ DRM_FORMAT_MOD_INVALID, fds, num_fds,
+ strides, offsets, bind, NULL, loaderPrivate);
+}
+
static boolean
dri2_query_dma_buf_modifiers(__DRIscreen *_screen, int fourcc, int max,
uint64_t *modifiers, unsigned int *external_only,
@@ -1774,7 +1788,7 @@ dri2_get_capabilities(__DRIscreen *_screen)
/* The extension is modified during runtime if DRI_PRIME is detected */
static const __DRIimageExtension dri2ImageExtensionTempl = {
- .base = { __DRI_IMAGE, 19 },
+ .base = { __DRI_IMAGE, 20 },
.createImageFromName = dri2_create_image_from_name,
.createImageFromRenderbuffer = dri2_create_image_from_renderbuffer,
@@ -1787,6 +1801,7 @@ static const __DRIimageExtension dri2ImageExtensionTempl = {
.fromPlanar = dri2_from_planar,
.createImageFromTexture = dri2_create_from_texture,
.createImageFromFds = NULL,
+ .createImageFromFds2 = NULL,
.createImageFromDmaBufs = NULL,
.blitImage = dri2_blit_image,
.getCapabilities = dri2_get_capabilities,
@@ -2279,6 +2294,7 @@ dri2_init_screen_extensions(struct dri_screen *screen,
if (drmGetCap(screen->sPriv->fd, DRM_CAP_PRIME, &cap) == 0 &&
(cap & DRM_PRIME_CAP_IMPORT)) {
screen->image_extension.createImageFromFds = dri2_from_fds;
+ screen->image_extension.createImageFromFds2 = dri2_from_fds2;
screen->image_extension.createImageFromDmaBufs = dri2_from_dma_bufs;
screen->image_extension.createImageFromDmaBufs2 = dri2_from_dma_bufs2;
screen->image_extension.createImageFromDmaBufs3 = dri2_from_dma_bufs3;
More information about the mesa-commit
mailing list