summaryrefslogtreecommitdiff
path: root/src/glsl/linker.cpp
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-07-20 13:36:32 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-07-20 17:48:24 -0700
commita7ba9a7919110fd619b0e792368aa1f3534080fe (patch)
tree569e72978a53b9b13af746dfef67e5e94c50e416 /src/glsl/linker.cpp
parent60e2d06d1ccc66ad00cd7ab81c418853f21be291 (diff)
linker: Do post-link lowering and optimization
The lowering code should probably be moved elsewhere.
Diffstat (limited to 'src/glsl/linker.cpp')
-rw-r--r--src/glsl/linker.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index eb4eb9d20e..640e6eee8e 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -80,6 +80,7 @@ extern "C" {
#include "hash_table.h"
#include "shader_api.h"
#include "linker.h"
+#include "ir_optimization.h"
/**
* Visitor that determines whether or not a variable is ever written.
@@ -1223,6 +1224,43 @@ link_shaders(struct gl_shader_program *prog)
}
/* FINISHME: Perform whole-program optimization here. */
+ for (unsigned i = 0; i < prog->_NumLinkedShaders; i++) {
+ /* Optimization passes */
+ bool progress;
+ exec_list *ir = prog->_LinkedShaders[i]->ir;
+
+ /* Lowering */
+ do_mat_op_to_vec(ir);
+ do_mod_to_fract(ir);
+ do_div_to_mul_rcp(ir);
+
+ do {
+ progress = false;
+
+ progress = do_function_inlining(ir) || progress;
+ progress = do_if_simplification(ir) || progress;
+ progress = do_copy_propagation(ir) || progress;
+ progress = do_dead_code_local(ir) || progress;
+#if 0
+ progress = do_dead_code_unlinked(state, ir) || progress;
+#endif
+ progress = do_constant_variable_unlinked(ir) || progress;
+ progress = do_constant_folding(ir) || progress;
+ progress = do_if_return(ir) || progress;
+#if 0
+ if (ctx->Shader.EmitNoIfs)
+ progress = do_if_to_cond_assign(ir) || progress;
+#endif
+
+ progress = do_vec_index_to_swizzle(ir) || progress;
+ /* Do this one after the previous to let the easier pass handle
+ * constant vector indexing.
+ */
+ progress = do_vec_index_to_cond_assign(ir) || progress;
+
+ progress = do_swizzle_swizzle(ir) || progress;
+ } while (progress);
+ }
assign_uniform_locations(prog);