[Mesa-dev] [PATCH 10/12] i965/fs: Make compact_virtual_grfs an optimization pass
Jason Ekstrand
jason at jlekstrand.net
Fri Sep 19 13:10:28 PDT 2014
Previously we disabled compact_virtual_grfs when dumping optimizations.
The idea here was to make it easier to diff the dumped shader because you
didn't have a sudden renaming. However, sometimes a bug is affected by
compact_virtual_grfs and, when this happens, you want to keep dumping
instructions with compact_virtual_grfs enabled. By turning it into an
optimization pass and dumping it along with the others, we retain the
ability to diff because you can just diff against the compact_virtual_grf
output.
Signed-off-by: Jason Ekstrand <jason.ekstrand at intel.com>
---
src/mesa/drivers/dri/i965/brw_fs.cpp | 17 +++++++++++------
src/mesa/drivers/dri/i965/brw_fs.h | 2 +-
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 002d40fd..a41cb4f 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -1752,12 +1752,10 @@ fs_visitor::split_virtual_grfs()
* to loop over all the virtual GRFs. Compacting them can save a lot of
* overhead.
*/
-void
+bool
fs_visitor::compact_virtual_grfs()
{
- if (unlikely(INTEL_DEBUG & DEBUG_OPTIMIZER))
- return;
-
+ bool progress = false;
int remap_table[this->virtual_grf_count];
memset(remap_table, -1, sizeof(remap_table));
@@ -1775,7 +1773,12 @@ fs_visitor::compact_virtual_grfs()
/* Compact the GRF arrays. */
int new_index = 0;
for (int i = 0; i < this->virtual_grf_count; i++) {
- if (remap_table[i] != -1) {
+ if (remap_table[i] == -1) {
+ /* We just found an unused register. This means that we are
+ * actually going to compact something.
+ */
+ progress = true;
+ } else {
remap_table[i] = new_index;
virtual_grf_sizes[new_index] = virtual_grf_sizes[i];
invalidate_live_intervals(false);
@@ -1818,6 +1821,8 @@ fs_visitor::compact_virtual_grfs()
}
}
}
+
+ return progress;
}
/*
@@ -3255,7 +3260,7 @@ fs_visitor::run()
iteration++;
int pass_num = 0;
- compact_virtual_grfs();
+ OPT(compact_virtual_grfs);
OPT(remove_duplicate_mrf_writes);
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index 402433b..56f40b4 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -325,7 +325,7 @@ public:
int choose_spill_reg(struct ra_graph *g);
void spill_reg(int spill_reg);
void split_virtual_grfs();
- void compact_virtual_grfs();
+ bool compact_virtual_grfs();
void move_uniform_array_access_to_pull_constants();
void assign_constant_locations();
void demote_pull_constants();
--
2.1.0
More information about the mesa-dev
mailing list