On 01/14/2011 02:58 PM, Eric Anholt wrote:
Module: Mesa
Branch: master
Commit: 34a9da4eb4dd41dc874f1a175e993e42d4ff4b2a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=34a9da4eb4dd41dc874f1a175e993e42d4ff4b2a
Author: Eric Anholt<e...@anholt.net>
Date: Wed Jan 12 18:25:33 2011 -0800
mesa: Add channel-wise copy propagation to ir_to_mesa.
This catches more opportunities than the prog_optimize.c code on
openarena's fixed function shaders turned to GLSL, mostly due to
looking at multiple source instructions for copy propagation
opportunities. It should also be much more CPU efficient than
prog_optimize.c's code.
---
src/mesa/program/ir_to_mesa.cpp | 129 +++++++++++++++++++++++++++++++++++++++
1 files changed, 129 insertions(+), 0 deletions(-)
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index c601ef6..0d40b09 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -295,6 +295,8 @@ public:
bool process_move_condition(ir_rvalue *ir);
+ void copy_propagate(void);
+
void *mem_ctx;
};
@@ -2616,6 +2618,131 @@ set_uniform_initializers(struct gl_context *ctx,
talloc_free(mem_ctx);
}
+/*
+ * On a basic block basis, tracks available PROGRAM_TEMPORARY register
+ * channels for copy propagation and updates following instructions to
+ * use the original versions.
+ *
+ * The ir_to_mesa_visitor lazily produces code assuming that this pass
+ * will occur. As an example, a TXP production before this pass:
+ *
+ * 0: MOV TEMP[1], INPUT[4].xyyy;
+ * 1: MOV TEMP[1].w, INPUT[4].wwww;
+ * 2: TXP TEMP[2], TEMP[1], texture[0], 2D;
+ *
+ * and after:
+ *
+ * 0: MOV TEMP[1], INPUT[4].xyyy;
+ * 1: MOV TEMP[1].w, INPUT[4].wwww;
+ * 2: TXP TEMP[2], INPUT[4].xyyw, texture[0], 2D;
+ *
+ * which allows for dead code elimination on TEMP[1]'s writes.
+ */
+void
+ir_to_mesa_visitor::copy_propagate(void)
+{
+ ir_to_mesa_instruction *acp[this->next_temp * 4];
This does not compile with MSVC:
src\mesa\program\ir_to_mesa.cpp(2644) : error C2466: cannot allocate
an array of constant size 0
src\mesa\program\ir_to_mesa.cpp(2644) : error C2133: 'acp' : unknown size
src\mesa\program\ir_to_mesa.cpp(2646) : error C2070:
'ir_to_mesa_instruction *[]': illegal sizeof operand
src\mesa\program\ir_to_mesa.cpp(2709) : error C2070:
'ir_to_mesa_instruction *[]': illegal sizeof operand
src\mesa\program\ir_to_mesa.cpp(2718) : error C2070:
'ir_to_mesa_instruction *[]': illegal sizeof operand
-Brian
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev