[Mesa-dev] [PATCH 10/27] i965: Handle Y-tile modifier

Ben Widawsky benjamin.widawsky at intel.com
Thu Dec 1 22:09:51 UTC 2016


From: Ben Widawsky <ben at bwidawsk.net>

This doesn't actually enable Y-tiling, it simply parses it and moves on.

Signed-off-by: Ben Widawsky <benjamin.widawsky at intel.com>
---
 src/mesa/drivers/dri/i965/intel_image.h  |  1 +
 src/mesa/drivers/dri/i965/intel_screen.c | 36 +++++++++++++++++++++++++-------
 2 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_image.h b/src/mesa/drivers/dri/i965/intel_image.h
index fd63919..bbda952 100644
--- a/src/mesa/drivers/dri/i965/intel_image.h
+++ b/src/mesa/drivers/dri/i965/intel_image.h
@@ -80,6 +80,7 @@ struct __DRIimageRec {
    uint32_t strides[3];
    uint32_t offsets[3];
    struct intel_image_format *planar_format;
+   uint64_t modifier; /** fb modifier (fourcc) */
 
    /* particular miptree level */
    GLuint width;
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index b5bb4a0..e54332f 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -23,6 +23,7 @@
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
+#include <drm_fourcc.h>
 #include <errno.h>
 #include <time.h>
 #include <unistd.h>
@@ -547,11 +548,22 @@ __intel_create_image(__DRIscreen *dri_screen,
 {
    __DRIimage *image;
    struct intel_screen *screen = dri_screen->driverPrivate;
-   uint32_t tiling;
+   uint32_t tiling = I915_TILING_X;
    int cpp;
    unsigned long pitch;
 
-   tiling = I915_TILING_X;
+   image = intel_allocate_image(screen, format, loaderPrivate);
+   if (image == NULL)
+      return NULL;
+
+   for (int i = 0; i < count; i++) {
+      switch (modifiers[i]) {
+      case I915_FORMAT_MOD_Y_TILED:
+         image->modifier = I915_FORMAT_MOD_Y_TILED;
+         break;
+      }
+   }
+
    if (use & __DRI_IMAGE_USE_CURSOR) {
       if (width != 64 || height != 64)
 	 return NULL;
@@ -561,10 +573,6 @@ __intel_create_image(__DRIscreen *dri_screen,
    if (use & __DRI_IMAGE_USE_LINEAR)
       tiling = I915_TILING_NONE;
 
-   image = intel_allocate_image(screen, format, loaderPrivate);
-   if (image == NULL)
-      return NULL;
-
    cpp = _mesa_get_format_bytes(image->format);
    image->bo = drm_intel_bo_alloc_tiled(screen->bufmgr, "image",
                                         width, height, cpp, &tiling,
@@ -597,8 +605,20 @@ intel_create_image_with_modifiers(__DRIscreen *dri_screen,
                                   const unsigned count,
                                   void *loaderPrivate)
 {
-   return __intel_create_image(dri_screen, width, height, format, use, NULL, 0,
-                               loaderPrivate);
+   uint64_t local_mods[count];
+   int local_count = 0;
+
+   /* This compacts the actual modifiers to the ones we know how to handle */
+   for (int i = 0; i < count; i++) {
+      switch (modifiers[i]) {
+      case I915_FORMAT_MOD_Y_TILED:
+         local_mods[local_count++] = I915_FORMAT_MOD_Y_TILED;
+         break;
+      }
+   }
+
+   return __intel_create_image(dri_screen, width, height, format, use,
+                               local_mods, local_count, loaderPrivate);
 }
 
 static GLboolean
-- 
2.10.2



More information about the mesa-dev mailing list