[Mesa-dev] [RFC v5 06/19] dri: Add createImageWithModifiers2 to DRIimageExtension
Louis-Francis Ratté-Boulianne
lfrb at collabora.com
Mon Nov 6 22:02:36 UTC 2017
It does the same as createImagewithModifiers but allow multiple
modifiers set to be given. The modifier used to create the image
should be selected from the first tranche if possible. If not,
then the subsequent tranches should be used.
Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
---
include/GL/internal/dri_interface.h | 19 +++++++++++++++-
src/mesa/drivers/dri/i965/intel_screen.c | 38 ++++++++++++++++++++++++--------
2 files changed, 47 insertions(+), 10 deletions(-)
diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
index 952f557f54..715c34d178 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -1186,7 +1186,7 @@ struct __DRIdri2ExtensionRec {
* extensions.
*/
#define __DRI_IMAGE "DRI_IMAGE"
-#define __DRI_IMAGE_VERSION 18
+#define __DRI_IMAGE_VERSION 19
/**
* These formats correspond to the similarly named MESA_FORMAT_*
@@ -1656,6 +1656,23 @@ struct __DRIimageExtensionRec {
* \since 18
*/
void (*suppressImplicitSync)(__DRIimage *image);
+
+
+ /**
+ * Like createImageWithModifiers, but can take multiple tranches/sets of
+ * modifiers according to the priority for which they should be selected.
+ *
+ * Modifier should be selected from the first tranche, from the second
+ * one if not possible, etc.
+ *
+ * \since 19
+ */
+ __DRIimage *(*createImageWithModifiers2)(__DRIscreen *screen,
+ int width, int height, int format,
+ const uint64_t **modifiers,
+ const unsigned int *counts,
+ const unsigned tranches_count,
+ void *loaderPrivate);
};
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index 88bc41ed64..94b3670ba3 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -637,20 +637,22 @@ static __DRIimage *
intel_create_image_common(__DRIscreen *dri_screen,
int width, int height, int format,
unsigned int use,
- const uint64_t *modifiers,
- unsigned count,
+ const uint64_t **modifiers,
+ const unsigned *counts,
+ const unsigned tranches_count,
void *loaderPrivate)
{
__DRIimage *image;
struct intel_screen *screen = dri_screen->driverPrivate;
uint64_t modifier = DRM_FORMAT_MOD_INVALID;
bool ok;
+ int i;
/* 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.
*/
- assert(!(use && count));
+ assert(!(use && tranches_count));
if (use & __DRI_IMAGE_USE_CURSOR) {
if (width != 64 || height != 64)
@@ -662,10 +664,14 @@ intel_create_image_common(__DRIscreen *dri_screen,
modifier = DRM_FORMAT_MOD_LINEAR;
if (modifier == DRM_FORMAT_MOD_INVALID) {
- if (modifiers) {
+ if (tranches_count > 0 && counts && modifiers && modifiers[0]) {
/* User requested specific modifiers */
- modifier = select_best_modifier(&screen->devinfo, format,
- modifiers, count);
+ for (i = 0; i < tranches_count; i++) {
+ modifier = select_best_modifier(&screen->devinfo, format,
+ modifiers[i], counts[i]);
+ if (modifier != DRM_FORMAT_MOD_INVALID)
+ break;
+ }
if (modifier == DRM_FORMAT_MOD_INVALID)
return NULL;
} else {
@@ -751,7 +757,7 @@ intel_create_image(__DRIscreen *dri_screen,
unsigned int use,
void *loaderPrivate)
{
- return intel_create_image_common(dri_screen, width, height, format, use, NULL, 0,
+ return intel_create_image_common(dri_screen, width, height, format, use, NULL, NULL, 0,
loaderPrivate);
}
@@ -763,7 +769,20 @@ intel_create_image_with_modifiers(__DRIscreen *dri_screen,
void *loaderPrivate)
{
return intel_create_image_common(dri_screen, width, height, format, 0,
- modifiers, count, loaderPrivate);
+ &modifiers, &count, 1, loaderPrivate);
+}
+
+static __DRIimage *
+intel_create_image_with_modifiers2(__DRIscreen *dri_screen,
+ int width, int height, int format,
+ const uint64_t **modifiers,
+ const unsigned *counts,
+ const unsigned tranches_count,
+ void *loaderPrivate)
+{
+ return intel_create_image_common(dri_screen, width, height, format, 0,
+ modifiers, counts, tranches_count,
+ loaderPrivate);
}
static GLboolean
@@ -1297,7 +1316,7 @@ intel_image_suppress_implicit_sync(__DRIimage *image)
}
static __DRIimageExtension intelImageExtension = {
- .base = { __DRI_IMAGE, 18 },
+ .base = { __DRI_IMAGE, 19 },
.createImageFromName = intel_create_image_from_name,
.createImageFromRenderbuffer = intel_create_image_from_renderbuffer,
@@ -1322,6 +1341,7 @@ static __DRIimageExtension intelImageExtension = {
.queryDmaBufFormatModifierAttribs = intel_query_format_modifier_attribs,
.createImageFromRenderbuffer2 = NULL,
.suppressImplicitSync = NULL,
+ .createImageWithModifiers2 = intel_create_image_with_modifiers2,
};
static uint64_t
--
2.13.0
More information about the mesa-dev
mailing list