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

Louis-Francis Ratté-Boulianne lfrb at collabora.com
Mon Oct 16 07:04:16 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 915c1b45d3..4352fb14db 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 18
+#define __DRI_IMAGE_VERSION 19
 
 /**
  * These formats correspond to the similarly named MESA_FORMAT_*
@@ -1650,6 +1650,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 be6c5aafd4..4461781995 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
@@ -1302,7 +1321,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,
@@ -1327,6 +1346,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