Mesa (master): r300g: do not remove unused constants if we are not near the limit

Marek Olšák mareko at kemper.freedesktop.org
Fri Dec 3 05:32:55 UTC 2010


Module: Mesa
Branch: master
Commit: a60a5b850bde94c9c0c21f07800ed57436525998
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a60a5b850bde94c9c0c21f07800ed57436525998

Author: Marek Olšák <maraeo at gmail.com>
Date:   Fri Dec  3 06:32:10 2010 +0100

r300g: do not remove unused constants if we are not near the limit

---

 src/gallium/drivers/r300/r300_fs.c |    6 +++++-
 src/gallium/drivers/r300/r300_vs.c |    5 ++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_fs.c b/src/gallium/drivers/r300/r300_fs.c
index c91532e..2936c34 100644
--- a/src/gallium/drivers/r300/r300_fs.c
+++ b/src/gallium/drivers/r300/r300_fs.c
@@ -390,7 +390,6 @@ static void r300_translate_fragment_shader(
     compiler.Base.max_temp_regs = compiler.Base.is_r500 ? 128 : 32;
     compiler.Base.max_constants = compiler.Base.is_r500 ? 256 : 32;
     compiler.Base.max_alu_insts = compiler.Base.is_r500 ? 512 : 64;
-    compiler.Base.remove_unused_constants = TRUE;
     compiler.AllocateHwInputs = &allocate_hardware_inputs;
     compiler.UserData = &shader->inputs;
 
@@ -408,6 +407,11 @@ static void r300_translate_fragment_shader(
 
     r300_tgsi_to_rc(&ttr, tokens);
 
+    if (!r300->screen->caps.is_r500 ||
+        compiler.Base.Program.Constants.Count > 200) {
+        compiler.Base.remove_unused_constants = TRUE;
+    }
+
     /**
      * Transform the program to support WPOS.
      *
diff --git a/src/gallium/drivers/r300/r300_vs.c b/src/gallium/drivers/r300/r300_vs.c
index 6569655..78021e2 100644
--- a/src/gallium/drivers/r300/r300_vs.c
+++ b/src/gallium/drivers/r300/r300_vs.c
@@ -213,7 +213,6 @@ void r300_translate_vertex_shader(struct r300_context *r300,
     compiler.Base.max_temp_regs = 32;
     compiler.Base.max_constants = 256;
     compiler.Base.max_alu_insts = r300->screen->caps.is_r500 ? 1024 : 256;
-    compiler.Base.remove_unused_constants = TRUE;
 
     if (compiler.Base.Debug & RC_DBG_LOG) {
         DBG(r300, DBG_VP, "r300: Initial vertex program\n");
@@ -227,6 +226,10 @@ void r300_translate_vertex_shader(struct r300_context *r300,
 
     r300_tgsi_to_rc(&ttr, vs->state.tokens);
 
+    if (compiler.Base.Program.Constants.Count > 200) {
+        compiler.Base.remove_unused_constants = TRUE;
+    }
+
     compiler.RequiredOutputs = ~(~0 << (vs->info.num_outputs + 1));
     compiler.SetHwInputOutput = &set_vertex_inputs_outputs;
 




More information about the mesa-commit mailing list