Mesa (shader-work): glsl: add pass to lower variable array indexing to conditional assignments

Luca Barbieri lb at kemper.freedesktop.org
Thu Sep 9 18:38:09 UTC 2010


Module: Mesa
Branch: shader-work
Commit: 831691d0bdcae4b1efbab3a62f7ead59e30ae5d7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=831691d0bdcae4b1efbab3a62f7ead59e30ae5d7

Author: Luca Barbieri <luca at luca-barbieri.com>
Date:   Wed Sep  8 01:35:44 2010 +0200

glsl: add pass to lower variable array indexing to conditional assignments

Currenly GLSL happily generates indirect addressing of any kind of
arrays.

Unfortunately DirectX 9 GPUs are not guaranteed to support any of them in
general.

This pass fixes that by lowering such constructs to a binary search on the
values, followed at the end by vectorized generation of equality masks, and
4 conditional assignments for each mask generation.

Note that this requires the ir_binop_equal change so that we can emit SEQ
to generate the boolean masks.

Unfortunately, ir_structure_splitting is too dumb to turn the resulting
constant array references to individual variables, so this will need to
be added too before this pass can actually be effective for temps.

---

 src/glsl/Makefile          |    1 +
 src/glsl/SConscript        |    1 +
 src/glsl/ir_optimization.h |    1 +
 3 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/glsl/Makefile b/src/glsl/Makefile
index efa274b..b12878c 100644
--- a/src/glsl/Makefile
+++ b/src/glsl/Makefile
@@ -31,6 +31,7 @@ CXX_SOURCES = \
 	glsl_symbol_table.cpp \
 	hir_field_selection.cpp \
 	ir_algebraic.cpp \
+	ir_array_index_to_cond_assign.cpp \
 	ir_basic_block.cpp \
 	ir_clone.cpp \
 	ir_constant_expression.cpp \
diff --git a/src/glsl/SConscript b/src/glsl/SConscript
index ac6324a..ed12e84 100644
--- a/src/glsl/SConscript
+++ b/src/glsl/SConscript
@@ -28,6 +28,7 @@ sources = [
     'glsl_symbol_table.cpp',
     'hir_field_selection.cpp',
     'ir_algebraic.cpp',
+    'ir_array_index_to_cond_assign.cpp',
     'ir_basic_block.cpp',
     'ir_clone.cpp',
     'ir_constant_expression.cpp',
diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h
index cba2976..8cb46b3 100644
--- a/src/glsl/ir_optimization.h
+++ b/src/glsl/ir_optimization.h
@@ -31,6 +31,7 @@
 bool do_common_optimization(exec_list *ir, bool linked, unsigned max_unroll_iterations, bool robust_access);
 
 bool do_algebraic(exec_list *instructions);
+bool do_array_index_to_cond_assign(exec_list *instructions);
 bool do_constant_folding(exec_list *instructions);
 bool do_constant_variable(exec_list *instructions);
 bool do_constant_variable_unlinked(exec_list *instructions);




More information about the mesa-commit mailing list