[Mesa-dev] [PATCH] i965: Mark delta_x/y as BAD_FILE if remapped away completely.

Kenneth Graunke kenneth at whitecape.org
Fri Sep 12 17:45:30 PDT 2014


Commit afe3d1556f6b77031f7025309511a0eea2a3e8df (i965: Stop doing
remapping of "special" regs.) stopped remapping delta_x/delta_y, and
additionally stopped considering them always-live.  We later realized
delta_x was used in register allocaiton, so we actually needed to remap
it, which was fixed in commit 23d782067ae834ad53522b46638ea21c62e94ca3
(i965/fs: Keep track of the register that hold delta_x/delta_y.).

However, that commit didn't restore the "always consider it live" part.
If all the code using delta_x was eliminated, fs_visitor::delta_x would
be left pointing at its old register number.  Later code in register
allocation would handle that register number specially...even though it
wasn't actually delta_x.

To combat this, set delta_x/y to BAD_FILE if they're eliminated, and
check for that.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=83127
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_fs.cpp              | 19 ++++++++++++++-----
 src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp |  1 +
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 2f23a9c..fa95c81 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -1759,16 +1759,25 @@ fs_visitor::compact_virtual_grfs()
    }
 
    /* Patch all the references to delta_x/delta_y, since they're used in
-    * register allocation.
+    * register allocation.  If they're unused, switch them to BAD_FILE so
+    * we don't think some random VGRF is delta_x/delta_y.
     */
    for (unsigned i = 0; i < ARRAY_SIZE(delta_x); i++) {
-      if (delta_x[i].file == GRF && remap_table[delta_x[i].reg] != -1) {
-         delta_x[i].reg = remap_table[delta_x[i].reg];
+      if (delta_x[i].file == GRF) {
+         if (remap_table[delta_x[i].reg] != -1) {
+            delta_x[i].reg = remap_table[delta_x[i].reg];
+         } else {
+            delta_x[i].file = BAD_FILE;
+         }
       }
    }
    for (unsigned i = 0; i < ARRAY_SIZE(delta_y); i++) {
-      if (delta_y[i].file == GRF && remap_table[delta_y[i].reg] != -1) {
-         delta_y[i].reg = remap_table[delta_y[i].reg];
+      if (delta_y[i].file == GRF) {
+         if (remap_table[delta_y[i].reg] != -1) {
+            delta_y[i].reg = remap_table[delta_y[i].reg];
+         } else {
+            delta_y[i].file = BAD_FILE;
+         }
       }
    }
 }
diff --git a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
index a9bff65..237cc49 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
@@ -459,6 +459,7 @@ fs_visitor::assign_regs(bool allow_spilling)
        * that register and set it to the appropriate class.
        */
       if (screen->wm_reg_sets[rsi].aligned_pairs_class >= 0 &&
+          this->delta_x[BRW_WM_PERSPECTIVE_PIXEL_BARYCENTRIC].file == GRF &&
           this->delta_x[BRW_WM_PERSPECTIVE_PIXEL_BARYCENTRIC].reg == i) {
          c = screen->wm_reg_sets[rsi].aligned_pairs_class;
       }
-- 
2.0.4



More information about the mesa-dev mailing list