[Mesa-dev] [RFC v3 06/23] dri: Add createImageWithModifiers2 to DRIimageExtension

Louis-Francis Ratté-Boulianne lfrb at collabora.com
Thu Sep 28 07:54:46 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 f673d50cdf..52d9397941 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -1180,7 +1180,7 @@ struct __DRIdri2ExtensionRec {
  * extensions.
  */
 #define __DRI_IMAGE "DRI_IMAGE"
-#define __DRI_IMAGE_VERSION 17
+#define __DRI_IMAGE_VERSION 18
 
 /**
  * These formats correspond to the similarly named MESA_FORMAT_*
@@ -1633,6 +1633,23 @@ struct __DRIimageExtensionRec {
     * \since 17
     */
    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 18
+    */
+   __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 58f8576cad..00ef3c8556 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -639,20 +639,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)
@@ -664,10 +666,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 {
@@ -753,7 +759,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);
 }
 
@@ -765,7 +771,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
@@ -1304,7 +1323,7 @@ intel_image_suppress_implicit_sync(__DRIimage *image)
 }
 
 static __DRIimageExtension intelImageExtension = {
-    .base = { __DRI_IMAGE, 17 },
+    .base = { __DRI_IMAGE, 18 },
 
     .createImageFromName                = intel_create_image_from_name,
     .createImageFromRenderbuffer        = intel_create_image_from_renderbuffer,
@@ -1328,6 +1347,7 @@ static __DRIimageExtension intelImageExtension = {
     .queryDmaBufModifiers               = intel_query_dma_buf_modifiers,
     .queryDmaBufFormatModifierAttribs   = intel_query_format_modifier_attribs,
     .suppressImplicitSync               = NULL,
+    .createImageWithModifiers2          = intel_create_image_with_modifiers2,
 };
 
 static uint64_t
-- 
2.13.0



More information about the mesa-dev mailing list