summaryrefslogtreecommitdiffstats
path: root/src/glsl/glsl_parser_extras.cpp
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2013-04-17 17:30:25 -0700
committerKenneth Graunke <[email protected]>2013-05-12 09:36:46 -0700
commite413d3f15ca72b82ca29e43f010597a83427d5e8 (patch)
tree89436a108f3e2f53ebab46c30d80c74ef6336277 /src/glsl/glsl_parser_extras.cpp
parent72a0b7a43531eb5e5cc4355941957864f86dd719 (diff)
glsl: Add a pass to flip matrix/vector multiplies to use dot products.
This pass flips (matrix * vector) operations to (vector * matrixTranspose) for certain built-in matrices (currently gl_ModelViewProjectionMatrix and gl_TextureMatrix). This is equivalent, but results in dot products rather than multiplies and adds. On some hardware, this is more efficient. This pass is conditionalized on ctx->mvp_with_dp4, the flag drivers set to indicate they prefer dot products. Improves performance in Lightsmark by 1.01131% +/- 0.162069% (n = 10) on a Haswell GT2 system. Passes Piglit on Ivybridge. v2: Use struct gl_shader_compiler_options instead of plumbing through another boolean flag for this purpose. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/glsl/glsl_parser_extras.cpp')
-rw-r--r--src/glsl/glsl_parser_extras.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 4e496a1749d..a6e6dde8564 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -1224,6 +1224,10 @@ do_common_optimization(exec_list *ir, bool linked,
progress = opt_flatten_nested_if_blocks(ir) || progress;
progress = do_copy_propagation(ir) || progress;
progress = do_copy_propagation_elements(ir) || progress;
+
+ if (options->PreferDP4 && !linked)
+ progress = opt_flip_matrices(ir) || progress;
+
if (linked)
progress = do_dead_code(ir, uniform_locations_assigned) || progress;
else