i965/fs: Teach regions_overlap() about COMPR4 MRF regions.
authorFrancisco Jerez <currojerez@riseup.net>
Fri, 27 May 2016 06:53:31 +0000 (23:53 -0700)
committerFrancisco Jerez <currojerez@riseup.net>
Tue, 31 May 2016 22:22:04 +0000 (15:22 -0700)
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/mesa/drivers/dri/i965/brw_ir_fs.h

index 7b1ec68e683e51ae0840cfec570bc3bb611cd36f..f2144835584a5d2fc727ada9846e43164142e190 100644 (file)
@@ -204,9 +204,23 @@ reg_offset(const fs_reg &r)
 static inline bool
 regions_overlap(const fs_reg &r, unsigned dr, const fs_reg &s, unsigned ds)
 {
-   return reg_space(r) == reg_space(s) &&
-          !(reg_offset(r) + dr <= reg_offset(s) ||
-            reg_offset(s) + ds <= reg_offset(r));
+   if (r.file == MRF && (r.nr & BRW_MRF_COMPR4)) {
+      fs_reg t = r;
+      t.nr &= ~BRW_MRF_COMPR4;
+      /* COMPR4 regions are translated by the hardware during decompression
+       * into two separate half-regions 4 MRFs apart from each other.
+       */
+      return regions_overlap(t, dr / 2, s, ds) ||
+             regions_overlap(byte_offset(t, 4 * REG_SIZE), dr / 2, s, ds);
+
+   } else if (s.file == MRF && (s.nr & BRW_MRF_COMPR4)) {
+      return regions_overlap(s, ds, r, dr);
+
+   } else {
+      return reg_space(r) == reg_space(s) &&
+             !(reg_offset(r) + dr <= reg_offset(s) ||
+               reg_offset(s) + ds <= reg_offset(r));
+   }
 }
 
 /**