i965/gen9: Disable Mip Tail for YF/YS tiled surfaces
authorAnuj Phogat <anuj.phogat@gmail.com>
Wed, 15 Apr 2015 05:06:50 +0000 (22:06 -0700)
committerAnuj Phogat <anuj.phogat@gmail.com>
Tue, 16 Jun 2015 21:52:49 +0000 (14:52 -0700)
Disabling miptails fixed the buffer corruption happening in FBO
which use YF/YS tiled renderbuffer or texture as color attachment.

Spec recommends disabling mip tails only for non-mip-mapped surfaces.
But, without disabling miptails I couldn't get correct data out of
mipmapped YF/YS tiled surface.

We need better understanding of miptails before start using them.
For now this patch helps move things forward.

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Ben Widawsky <ben@bwidawsk.net>
src/mesa/drivers/dri/i965/brw_defines.h
src/mesa/drivers/dri/i965/gen8_surface_state.c

index 54e5a8f78bcf3d8063188b29ff03833630f0ccc4..bfcc4424c3be7dda5281dd25814fd80f8e6595aa 100644 (file)
 #define GEN9_SURFACE_TRMODE_TILEYF         1
 #define GEN9_SURFACE_TRMODE_TILEYS         2
 
+#define GEN9_SURFACE_MIP_TAIL_START_LOD_SHIFT      8
+#define GEN9_SURFACE_MIP_TAIL_START_LOD_MASK       INTEL_MASK(11, 8)
+
 /* Surface state DW6 */
 #define GEN7_SURFACE_MCS_ENABLE                 (1 << 0)
 #define GEN7_SURFACE_MCS_PITCH_SHIFT            3
index 2514d960e2eea7d0276b69b712b7d97b890c16f4..b2d1a579815c6b620d93f0844963d3c8ab158f5b 100644 (file)
@@ -255,8 +255,11 @@ gen8_emit_texture_surface_state(struct brw_context *brw,
    surf[5] = SET_FIELD(min_level - mt->first_level, GEN7_SURFACE_MIN_LOD) |
              (max_level - min_level - 1); /* mip count */
 
-   if (brw->gen >= 9)
+   if (brw->gen >= 9) {
       surf[5] |= SET_FIELD(tr_mode, GEN9_SURFACE_TRMODE);
+      /* Disable Mip Tail by setting a large value. */
+      surf[5] |= SET_FIELD(15, GEN9_SURFACE_MIP_TAIL_START_LOD);
+   }
 
    if (aux_mt) {
       surf[6] = SET_FIELD(mt->qpitch / 4, GEN8_SURFACE_AUX_QPITCH) |
@@ -478,8 +481,11 @@ gen8_update_renderbuffer_surface(struct brw_context *brw,
 
    surf[5] = irb->mt_level - irb->mt->first_level;
 
-   if (brw->gen >= 9)
+   if (brw->gen >= 9) {
       surf[5] |= SET_FIELD(tr_mode, GEN9_SURFACE_TRMODE);
+      /* Disable Mip Tail by setting a large value. */
+      surf[5] |= SET_FIELD(15, GEN9_SURFACE_MIP_TAIL_START_LOD);
+   }
 
    if (aux_mt) {
       surf[6] = SET_FIELD(mt->qpitch / 4, GEN8_SURFACE_AUX_QPITCH) |