Mesa (9.0): glsl: Allow ir_if in the linker' s move_non_declarations function.

Ian Romanick idr at kemper.freedesktop.org
Fri Nov 2 19:23:37 UTC 2012


Module: Mesa
Branch: 9.0
Commit: 895a5873d141c726e2e81ba53d5b757e4708fb29
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=895a5873d141c726e2e81ba53d5b757e4708fb29

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Wed Oct 24 13:17:24 2012 -0700

glsl: Allow ir_if in the linker's move_non_declarations function.

Global initializers using the ?: operator with at least one non-constant
operand generate ir_if statements.  For example,

   float foo = some_boolean ? 0.0 : 1.0;

becomes:

   (declare (temporary) float conditional_tmp)
   (if (var_ref some_boolean)
       ((assign (x) (var_ref conditional_tmp) (constant float (0.0))))
       ((assign (x) (var_ref conditional_tmp) (constant float (1.0)))))

This pattern is necessary because the second or third arguments could be
function calls, which create statements (not expressions).

The linker moves these global initializers into the main() function.
However, it incorrectly had an assertion that global initializer
statements were only assignments, calls, or temporary variable
declarations.  As demonstrated above, they can be if statements too.

Other than the assertion, everything works fine.  So remove it.

Fixes new Piglit test condition-08.vert, as well as an upcoming
game that will be released on Steam.

NOTE: This is a candidate for stable release branches.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Eric Anholt <eric at anholt.net>
(cherry picked from commit b45a68eebf3cf7227fc70082cb1e796041fc81ab)

---

 src/glsl/linker.cpp |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 34ce133..86371b5 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -882,6 +882,7 @@ move_non_declarations(exec_list *instructions, exec_node *last,
 
       assert(inst->as_assignment()
              || inst->as_call()
+             || inst->as_if() /* for initializers with the ?: operator */
 	     || ((var != NULL) && (var->mode == ir_var_temporary)));
 
       if (make_copies) {




More information about the mesa-commit mailing list