<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Feb 9, 2018 at 3:43 PM, Jason Ekstrand <span dir="ltr"><<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Louis-Francis Ratté-Boulianne <<a href="mailto:lfrb@collabora.com">lfrb@collabora.com</a>><br>
<br>
It does the same as createImagewithModifiers but allow multiple<br>
modifiers set to be given. The modifier used to create the image<br>
should be selected from the first tranche if possible. If not,<br>
then the subsequent tranches should be used.<br>
<br>
Signed-off-by: Louis-Francis Ratté-Boulianne <<a href="mailto:lfrb@collabora.com">lfrb@collabora.com</a>><br>
---<br>
include/GL/internal/dri_<wbr>interface.h | 19 +++++++++++++++-<br>
src/mesa/drivers/dri/i965/<wbr>intel_screen.c | 38 ++++++++++++++++++++++++------<wbr>--<br>
2 files changed, 47 insertions(+), 10 deletions(-)<br>
<br>
diff --git a/include/GL/internal/dri_<wbr>interface.h b/include/GL/internal/dri_<wbr>interface.h<br>
index be12918..11a64f0 100644<br>
--- a/include/GL/internal/dri_<wbr>interface.h<br>
+++ b/include/GL/internal/dri_<wbr>interface.h<br>
@@ -1220,7 +1220,7 @@ struct __DRIdri2ExtensionRec {<br>
* extensions.<br>
*/<br>
#define __DRI_IMAGE "DRI_IMAGE"<br>
-#define __DRI_IMAGE_VERSION 18<br>
+#define __DRI_IMAGE_VERSION 19<br>
<br>
/**<br>
* These formats correspond to the similarly named MESA_FORMAT_*<br>
@@ -1699,6 +1699,23 @@ struct __DRIimageExtensionRec {<br>
* \since 18<br>
*/<br>
void (*suppressImplicitSync)(__<wbr>DRIimage *image);<br>
+<br>
+<br>
+ /**<br>
+ * Like createImageWithModifiers, but can take multiple tranches/sets of<br>
+ * modifiers according to the priority for which they should be selected.<br>
+ *<br>
+ * Modifier should be selected from the first tranche, from the second<br>
+ * one if not possible, etc.<br>
+ *<br>
+ * \since 19<br>
+ */<br>
+ __DRIimage *(*createImageWithModifiers2)(<wbr>__DRIscreen *screen,<br>
+ int width, int height, int format,<br>
+ const uint64_t **modifiers,<br>
+ const unsigned int *counts,<br>
+ const unsigned tranches_count,<br>
+ void *loaderPrivate);<br></blockquote><div><br></div><div>I don't think this is really needed. We have queryDmaBufModifiers so the user of the DRI interface could call that, determine which of the trances is the first with a supported modifier, and then just call it it with a single modifier list. Given that this is on the image create path, the extra time it takes to make a quick list isn't bad. This is what I did for the Vulkan version and it worked out ok.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
};<br>
<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_screen.c b/src/mesa/drivers/dri/i965/<wbr>intel_screen.c<br>
index 9a54f27..131bffe 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>intel_screen.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>intel_screen.c<br>
@@ -647,20 +647,22 @@ static __DRIimage *<br>
intel_create_image_common(__<wbr>DRIscreen *dri_screen,<br>
int width, int height, int format,<br>
unsigned int use,<br>
- const uint64_t *modifiers,<br>
- unsigned count,<br>
+ const uint64_t **modifiers,<br>
+ const unsigned *counts,<br>
+ const unsigned tranches_count,<br>
void *loaderPrivate)<br>
{<br>
__DRIimage *image;<br>
struct intel_screen *screen = dri_screen->driverPrivate;<br>
uint64_t modifier = DRM_FORMAT_MOD_INVALID;<br>
bool ok;<br>
+ int i;<br>
<br>
/* Callers of this may specify a modifier, or a dri usage, but not both. The<br>
* newer modifier interface deprecates the older usage flags newer modifier<br>
* interface deprecates the older usage flags.<br>
*/<br>
- assert(!(use && count));<br>
+ assert(!(use && tranches_count));<br>
<br>
if (use & __DRI_IMAGE_USE_CURSOR) {<br>
if (width != 64 || height != 64)<br>
@@ -672,10 +674,14 @@ intel_create_image_common(__<wbr>DRIscreen *dri_screen,<br>
modifier = DRM_FORMAT_MOD_LINEAR;<br>
<br>
if (modifier == DRM_FORMAT_MOD_INVALID) {<br>
- if (modifiers) {<br>
+ if (tranches_count > 0 && counts && modifiers && modifiers[0]) {<br>
/* User requested specific modifiers */<br>
- modifier = select_best_modifier(&screen-><wbr>devinfo, format,<br>
- modifiers, count);<br>
+ for (i = 0; i < tranches_count; i++) {<br>
+ modifier = select_best_modifier(&screen-><wbr>devinfo, format,<br>
+ modifiers[i], counts[i]);<br>
+ if (modifier != DRM_FORMAT_MOD_INVALID)<br>
+ break;<br>
+ }<br>
if (modifier == DRM_FORMAT_MOD_INVALID)<br>
return NULL;<br>
} else {<br>
@@ -761,7 +767,7 @@ intel_create_image(__DRIscreen *dri_screen,<br>
unsigned int use,<br>
void *loaderPrivate)<br>
{<br>
- return intel_create_image_common(dri_<wbr>screen, width, height, format, use, NULL, 0,<br>
+ return intel_create_image_common(dri_<wbr>screen, width, height, format, use, NULL, NULL, 0,<br>
loaderPrivate);<br>
}<br>
<br>
@@ -834,7 +840,20 @@ intel_create_image_with_<wbr>modifiers(__DRIscreen *dri_screen,<br>
void *loaderPrivate)<br>
{<br>
return intel_create_image_common(dri_<wbr>screen, width, height, format, 0,<br>
- modifiers, count, loaderPrivate);<br>
+ &modifiers, &count, 1, loaderPrivate);<br>
+}<br>
+<br>
+static __DRIimage *<br>
+intel_create_image_with_<wbr>modifiers2(__DRIscreen *dri_screen,<br>
+ int width, int height, int format,<br>
+ const uint64_t **modifiers,<br>
+ const unsigned *counts,<br>
+ const unsigned tranches_count,<br>
+ void *loaderPrivate)<br>
+{<br>
+ return intel_create_image_common(dri_<wbr>screen, width, height, format, 0,<br>
+ modifiers, counts, tranches_count,<br>
+ loaderPrivate);<br>
}<br>
<br>
static GLboolean<br>
@@ -1376,7 +1395,7 @@ intel_image_suppress_implicit_<wbr>sync(__DRIimage *image)<br>
}<br>
<br>
static __DRIimageExtension intelImageExtension = {<br>
- .base = { __DRI_IMAGE, 18 },<br>
+ .base = { __DRI_IMAGE, 19 },<br>
<br>
.createImageFromName = intel_create_image_from_name,<br>
.createImageFromRenderbuffer = intel_create_image_from_<wbr>renderbuffer,<br>
@@ -1401,6 +1420,7 @@ static __DRIimageExtension intelImageExtension = {<br>
.<wbr>queryDmaBufFormatModifierAttri<wbr>bs = intel_query_format_modifier_<wbr>attribs,<br>
.createImageFromRenderbuffer2 = NULL,<br>
.suppressImplicitSync = NULL,<br>
+ .createImageWithModifiers2 = intel_create_image_with_<wbr>modifiers2,<br>
};<br>
<br>
static uint64_t<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.5.0.400.gff86faf<br>
<br>
</font></span></blockquote></div><br></div></div>