i965: Don't store qpitch / 4 as mt->qpitch for compressed surfaces.
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 23 Jan 2014 00:48:03 +0000 (16:48 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Sun, 26 Jan 2014 03:20:17 +0000 (19:20 -0800)
Broadwell requires software to specify QPitch in a bunch of packets,
so we decided to store it in the miptree.  However, when I did that
refactoring, I missed a subtlety: the hardware expects QPitch to be
"in units of rows in the uncompressed surface".

This is the value we originally compute.  However, for compressed
surfaces, we then divided it by 4 (the block height), to obtain the
physical layout.  This is no longer the QPitch Broadwell expects.

So, store the original undivided value in mt->qpitch, but continue to
use the divided value in brw_miptree_layout_texture_array().  For
non-Broadwell platforms, this should have no impact at all.

Helps fix Piglit's "getteximage-targets S3TC CUBE" test on Broadwell.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/i965/brw_tex_layout.c
src/mesa/drivers/dri/i965/intel_mipmap_tree.h

index 45aa85471afe12e0f588b852fef6fc986ec953c6..f5ea13437ae2f86d10cb01030a4772a4990e8cfb 100644 (file)
@@ -246,17 +246,17 @@ brw_miptree_layout_texture_array(struct brw_context *brw,
       mt->qpitch = h0;
    else
       mt->qpitch = (h0 + h1 + (brw->gen >= 7 ? 12 : 11) * mt->align_h);
-   if (mt->compressed)
-      mt->qpitch /= 4;
+
+   int physical_qpitch = mt->compressed ? mt->qpitch / 4 : mt->qpitch;
 
    brw_miptree_layout_2d(mt);
 
    for (unsigned level = mt->first_level; level <= mt->last_level; level++) {
       for (int q = 0; q < mt->physical_depth0; q++) {
-        intel_miptree_set_image_offset(mt, level, q, 0, q * mt->qpitch);
+        intel_miptree_set_image_offset(mt, level, q, 0, q * physical_qpitch);
       }
    }
-   mt->total_height = mt->qpitch * mt->physical_depth0;
+   mt->total_height = physical_qpitch * mt->physical_depth0;
 
    align_cube(mt);
 }
index bc63a249d2a53f8a6f03934e35c1a79d0a2e0d8a..69d5b0a22c0202b289bb5e587d0fd2c9f60fa4be 100644 (file)
@@ -334,7 +334,10 @@ struct intel_mipmap_tree
    bool array_spacing_lod0;
 
    /**
-    * The distance in rows between array slices.
+    * The distance in rows between array slices in an uncompressed surface.
+    *
+    * For compressed surfaces, slices are stored closer together physically;
+    * the real distance is (qpitch / block height).
     */
    uint32_t qpitch;