Mesa (master): i915g: Fix 2D layouts

Jakob Bornecrantz wallbraker at kemper.freedesktop.org
Thu Apr 15 22:53:04 UTC 2010


Module: Mesa
Branch: master
Commit: 97c326417cf1c2c2df0c8ba11046c4a7b752f3e7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=97c326417cf1c2c2df0c8ba11046c4a7b752f3e7

Author: Jakob Bornecrantz <jakob at vmware.com>
Date:   Thu Apr 15 23:26:12 2010 +0100

i915g: Fix 2D layouts

This should fix 2D compressed layouts

---

 src/gallium/drivers/i915/i915_resource_texture.c |   29 +++++++++++++---------
 1 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_resource_texture.c b/src/gallium/drivers/i915/i915_resource_texture.c
index 0ec6106..87c53f1 100644
--- a/src/gallium/drivers/i915/i915_resource_texture.c
+++ b/src/gallium/drivers/i915/i915_resource_texture.c
@@ -202,6 +202,7 @@ i915_texture_layout_2d(struct i915_texture *tex)
    unsigned width = pt->width0;
    unsigned height = pt->height0;
    unsigned nblocksy = util_format_get_nblocksy(pt->format, pt->width0);
+   unsigned align_y = 2;
 
    /* used for scanouts that need special layouts */
    if (pt->bind & PIPE_BIND_SCANOUT)
@@ -218,6 +219,9 @@ i915_texture_layout_2d(struct i915_texture *tex)
       if (i9x5_display_target_layout(tex))
          return;
 
+   if (util_format_is_s3tc(pt->format))
+      align_y = 1;
+
    tex->stride = align(util_format_get_stride(pt->format, pt->width0), 4);
    tex->total_nblocksy = 0;
 
@@ -225,13 +229,11 @@ i915_texture_layout_2d(struct i915_texture *tex)
       i915_texture_set_level_info(tex, level, 1);
       i915_texture_set_image_offset(tex, level, 0, 0, tex->total_nblocksy);
 
-      nblocksy = align(MAX2(2, nblocksy), 2);
-
       tex->total_nblocksy += nblocksy;
 
       width = u_minify(width, 1);
       height = u_minify(height, 1);
-      nblocksy = util_format_get_nblocksy(pt->format, height);
+      nblocksy = align(util_format_get_nblocksy(pt->format, height), align_y);
    }
 }
 
@@ -345,7 +347,7 @@ static void
 i945_texture_layout_2d(struct i915_texture *tex)
 {
    struct pipe_resource *pt = &tex->b.b;
-   const int align_x = 2, align_y = 4;
+   int align_x = 4, align_y = 2;
    unsigned level;
    unsigned x = 0;
    unsigned y = 0;
@@ -364,6 +366,11 @@ i945_texture_layout_2d(struct i915_texture *tex)
       if (i9x5_display_target_layout(tex))
          return;
 
+   if (util_format_is_s3tc(pt->format)) {
+      align_x = 1;
+      align_y = 1;
+   }
+
    tex->stride = align(util_format_get_stride(pt->format, pt->width0), 4);
 
    /* May need to adjust pitch to accomodate the placement of
@@ -372,9 +379,9 @@ i945_texture_layout_2d(struct i915_texture *tex)
     * 2nd mipmap level out past the width of its parent.
     */
    if (pt->last_level > 0) {
-      unsigned mip1_nblocksx 
-         = align(util_format_get_nblocksx(pt->format, u_minify(width, 1)), align_x)
-         + util_format_get_nblocksx(pt->format, u_minify(width, 2));
+      unsigned mip1_nblocksx =
+         align(util_format_get_nblocksx(pt->format, u_minify(pt->width0, 1)), align_x) +
+         util_format_get_nblocksx(pt->format, u_minify(pt->width0, 2));
 
       if (mip1_nblocksx > nblocksx)
          tex->stride = mip1_nblocksx * util_format_get_blocksize(pt->format);
@@ -389,8 +396,6 @@ i945_texture_layout_2d(struct i915_texture *tex)
       i915_texture_set_level_info(tex, level, 1);
       i915_texture_set_image_offset(tex, level, 0, x, y);
 
-      nblocksy = align(nblocksy, align_y);
-
       /* Because the images are packed better, the final offset
        * might not be the maximal one:
        */
@@ -399,15 +404,15 @@ i945_texture_layout_2d(struct i915_texture *tex)
       /* Layout_below: step right after second mipmap level.
        */
       if (level == 1) {
-         x += align(nblocksx, align_x);
+         x += nblocksx;
       } else {
          y += nblocksy;
       }
 
       width  = u_minify(width, 1);
       height = u_minify(height, 1);
-      nblocksx = util_format_get_nblocksx(pt->format, width);
-      nblocksy = util_format_get_nblocksy(pt->format, height);
+      nblocksx = align(util_format_get_nblocksx(pt->format, width), align_x);
+      nblocksy = align(util_format_get_nblocksy(pt->format, height), align_y);
    }
 }
 




More information about the mesa-commit mailing list