At image creation create a path for dealing with the linear modifier.
This works exactly like the old usage flags where __DRI_IMAGE_USE_LINEAR
was specified.

During development of this patch series, it was decided that a lack of
modifier was an insufficient way to express the required modifiers. As a
result, 0 was repurposed to mean a modifier for a LINEAR layout.

NOTE: This patch was added for v3 of the patch series.

References: https://patchwork.kernel.org/patch/9419157/
Signed-off-by: Ben Widawsky <b...@bwidawsk.net>
---
 src/mesa/drivers/dri/i965/intel_screen.c | 35 ++++++++++++++++++++++++--------
 1 file changed, 27 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_screen.c 
b/src/mesa/drivers/dri/i965/intel_screen.c
index 7429603e86..22ab3a30b6 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -45,6 +45,10 @@
 #define DRM_FORMAT_MOD_INVALID ((1ULL<<56) - 1)
 #endif
 
+#ifndef DRM_FORMAT_MOD_LINEAR
+#define DRM_FORMAT_MOD_LINEAR 0
+#endif
+
 static const __DRIconfigOptionsExtension brw_config_options = {
    .base = { __DRI_CONFIG_OPTIONS, 1 },
    .xml =
@@ -516,8 +520,16 @@ select_best_modifier(struct gen_device_info *devinfo,
                      const uint64_t *modifiers,
                      const unsigned count)
 {
-   /* Modifiers are not supported by this DRI driver */
-   return DRM_FORMAT_MOD_INVALID;
+   uint64_t modifier = DRM_FORMAT_MOD_INVALID;
+
+   for (int i = 0; i < count; i++) {
+      switch (modifiers[i]) {
+      case DRM_FORMAT_MOD_LINEAR:
+         return modifiers[i];
+      }
+   }
+
+   return modifier;
 }
 
 static __DRIimage *
@@ -530,7 +542,10 @@ intel_create_image_common(__DRIscreen *dri_screen,
 {
    __DRIimage *image;
    struct intel_screen *screen = dri_screen->driverPrivate;
-   uint32_t tiling;
+   /* Historically, X-tiled was the default, and so lack of modifier means
+    * X-tiled.
+    */
+   uint32_t tiling = I915_TILING_X;
    int cpp;
    unsigned long pitch;
 
@@ -541,12 +556,15 @@ intel_create_image_common(__DRIscreen *dri_screen,
    assert(!(use && count));
 
    uint64_t modifier = select_best_modifier(&screen->devinfo, modifiers, 
count);
-   assert(modifier == DRM_FORMAT_MOD_INVALID);
+   switch (modifier) {
+   case DRM_FORMAT_MOD_LINEAR:
+      tiling = I915_TILING_NONE;
+      break;
+   case DRM_FORMAT_MOD_INVALID:
+   default:
+         break;
+   }
 
-   /* Historically, X-tiled was the default, and so lack of modifier means
-    * X-tiled.
-    */
-   tiling = I915_TILING_X;
    if (use & __DRI_IMAGE_USE_CURSOR) {
       if (width != 64 || height != 64)
         return NULL;
@@ -571,6 +589,7 @@ intel_create_image_common(__DRIscreen *dri_screen,
    image->width = width;
    image->height = height;
    image->pitch = pitch;
+   image->modifier = modifier;
 
    return image;
 }
-- 
2.12.0

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to