[Mesa-dev] [PATCH v2 3/3] mesa/st: glsl_to_tgsi: tie in the new register renaming approach

Gert Wollny gw.fossdev at gmail.com
Fri Jun 16 09:32:02 UTC 2017


This patch replaces the old register livetime estimation with the
new approach.
---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index f64aedb876..d57004c269 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -55,10 +55,11 @@
 #include "st_glsl_types.h"
 #include "st_nir.h"
 #include "st_shader_cache.h"
-#include "st_glsl_to_tgsi_private.h"
+#include "st_glsl_to_tgsi_temprename.h"
 
 #include "util/hash_table.h"
 #include <algorithm>
+#include <iostream>
 
 #define PROGRAM_ANY_CONST ((1 << PROGRAM_STATE_VAR) |    \
                            (1 << PROGRAM_CONSTANT) |     \
@@ -325,6 +326,7 @@ public:
 
    void merge_two_dsts(void);
    void merge_registers(void);
+   void merge_registers_alternative(void);
    void renumber_registers(void);
 
    void emit_block_mov(ir_assignment *ir, const struct glsl_type *type,
@@ -5140,6 +5142,16 @@ glsl_to_tgsi_visitor::merge_two_dsts(void)
    }
 }
 
+void
+glsl_to_tgsi_visitor::merge_registers_alternative(void)
+{
+   struct rename_reg_pair *renames = rzalloc_array(mem_ctx, struct rename_reg_pair, this->next_temp);
+   auto lt = estimate_temporary_lifetimes(&this->instructions, this->next_temp);
+   evaluate_remapping(lt, renames);
+   rename_temp_registers(&renames[0]);
+   ralloc_free(renames);
+}
+
 /* Merges temporary registers together where possible to reduce the number of
  * registers needed to run a program.
  *
@@ -6605,7 +6617,7 @@ get_mesa_program_tgsi(struct gl_context *ctx,
 
    v->merge_two_dsts();
    if (!skip_merge_registers)
-      v->merge_registers();
+      v->merge_registers_alternative();
    v->renumber_registers();
 
    /* Write the END instruction. */
-- 
2.13.0



More information about the mesa-dev mailing list