Modifiers will be obtains or guessed by the client and passed in during
image creation/import.
This requires bumping the DRIimage version.
As of this patch, the modifiers aren't plumbed all the way down, this
patch simply makes sure the interface level stuff is correct.
v2: Don't allow usage + modifiers
Cc: Kristian Høgsberg <k...@bitplanet.net>
Signed-off-by: Ben Widawsky <b...@bwidawsk.net>
Reviewed-by: Eric Engestrom <eric.engest...@imgtec.com>
Acked-by: Daniel Stone <dani...@collabora.com>
---
include/GL/internal/dri_interface.h | 27 +++++++++++++++++++++++++-
src/gallium/state_trackers/dri/dri2.c | 1 +
src/mesa/drivers/dri/i965/intel_screen.c | 33 +++++++++++++++++++++++++++++++-
3 files changed, 59 insertions(+), 2 deletions(-)
diff --git a/include/GL/internal/dri_interface.h
b/include/GL/internal/dri_interface.h
index 8922356990..820dd34fa1 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -1136,7 +1136,7 @@ struct __DRIdri2ExtensionRec {
* extensions.
*/
#define __DRI_IMAGE "DRI_IMAGE"
-#define __DRI_IMAGE_VERSION 13
+#define __DRI_IMAGE_VERSION 14
/**
* These formats correspond to the similarly named MESA_FORMAT_*
@@ -1253,6 +1253,8 @@ struct __DRIdri2ExtensionRec {
#define __DRI_IMAGE_ATTRIB_NUM_PLANES 0x2009 /* available in versions 11 */
#define __DRI_IMAGE_ATTRIB_OFFSET 0x200A /* available in versions 13 */
+#define __DRI_IMAGE_ATTRIB_MODIFIER_LOWER 0x200B /* available in versions 14 */
+#define __DRI_IMAGE_ATTRIB_MODIFIER_UPPER 0x200C /* available in versions 14 */
enum __DRIYUVColorSpace {
__DRI_YUV_COLOR_SPACE_UNDEFINED = 0,
@@ -1464,6 +1466,29 @@ struct __DRIimageExtensionRec {
*/
void (*unmapImage)(__DRIcontext *context, __DRIimage *image, void *data);
+
+ /**
+ * Creates an image with implementation's favorite modifiers.
+ *
+ * This acts like createImage except there is a list of modifiers passed in
+ * which the implementation may selectively use to create the DRIimage. The
+ * result should be the implementation selects one modifier (perhaps it
would
+ * hold on to a few and later pick).
+ *
+ * The created image should be destroyed with destroyImage().
+ *
+ * Returns the new DRIimage. The chosen modifier can be obtained later on
+ * and passed back to things like the kernel's AddFB2 interface.
+ *
+ * \sa __DRIimageRec::createImage
+ *
+ * \since 14
+ */
+ __DRIimage *(*createImageWithModifiers)(__DRIscreen *screen,
+ int width, int height, int format,
+ const uint64_t *modifiers,
+ const unsigned int modifier_count,
+ void *loaderPrivate);
};
diff --git a/src/gallium/state_trackers/dri/dri2.c
b/src/gallium/state_trackers/dri/dri2.c
index 77523e98ff..1806b4e344 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -1409,6 +1409,7 @@ static __DRIimageExtension dri2ImageExtension = {
.getCapabilities = dri2_get_capabilities,
.mapImage = dri2_map_image,
.unmapImage = dri2_unmap_image,
+ .createImageWithModifiers = NULL,
};
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c
b/src/mesa/drivers/dri/i965/intel_screen.c
index 2ebdadd157..8ffa6cb1a4 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -541,9 +541,11 @@ intel_destroy_image(__DRIimage *image)
}
static __DRIimage *
-intel_create_image(__DRIscreen *dri_screen,
+__intel_create_image(__DRIscreen *dri_screen,
int width, int height, int format,
unsigned int use,
+ const uint64_t *modifiers,
+ unsigned count,
void *loaderPrivate)
{
__DRIimage *image;
@@ -552,6 +554,13 @@ intel_create_image(__DRIscreen *dri_screen,
int cpp;
unsigned long pitch;
+ /* Callers of this may specify a modifier, or a dri usage, but not both. The
+ * newer modifier interface deprecates the older usage flags
+ * newer modifier interface deprecates the older usage flags. This is the
+ * equivalent of usage NAND count.
+ */
+ assert(~(use & count));