<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>