[Mesa-dev] [PATCH 11/34] i965: Handle the linear fb modifier

Ben Widawsky ben at bwidawsk.net
Tue Jan 24 06:21:34 UTC 2017


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 <ben at bwidawsk.net>
---
 src/mesa/drivers/dri/i965/intel_image.h  |  1 +
 src/mesa/drivers/dri/i965/intel_screen.c | 35 +++++++++++++++++++++++++-------
 2 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_image.h b/src/mesa/drivers/dri/i965/intel_image.h
index fd63919b2d..3a35487dc4 100644
--- a/src/mesa/drivers/dri/i965/intel_image.h
+++ b/src/mesa/drivers/dri/i965/intel_image.h
@@ -71,6 +71,7 @@ struct __DRIimageRec {
    GLenum internal_format;
    uint32_t dri_format;
    GLuint format;
+   uint64_t modifier; /** fb modifier (fourcc) */
    uint32_t offset;
 
    /*
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index e3bbeefe8e..ebfa74a8ff 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -549,12 +549,26 @@ intel_destroy_image(__DRIimage *image)
 #ifndef DRM_FORMAT_MOD_INVALID
 #define DRM_FORMAT_MOD_INVALID ((1ULL<<56) - 1)
 #endif
+
+#ifndef DRM_FORMAT_MOD_LINEAR
+#define DRM_FORMAT_MOD_LINEAR 0
+#endif
+
 static uint64_t
 select_best_modifier(struct gen_device_info *devinfo,
                      const uint64_t *modifiers,
                      const unsigned count)
 {
-   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 *
@@ -567,7 +581,10 @@ __intel_create_image(__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;
 
@@ -578,12 +595,15 @@ __intel_create_image(__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;
@@ -608,6 +628,7 @@ __intel_create_image(__DRIscreen *dri_screen,
    image->width = width;
    image->height = height;
    image->pitch = pitch;
+   image->modifier = modifier;
 
    return image;
 }
-- 
2.11.0



More information about the mesa-dev mailing list