glsl: fix switch statement default case regressions
authorTapani Pälli <tapani.palli@intel.com>
Fri, 25 Jul 2014 06:40:13 +0000 (09:40 +0300)
committerTapani Pälli <tapani.palli@intel.com>
Mon, 4 Aug 2014 09:32:59 +0000 (12:32 +0300)
This patch fixes regressions caused by commit 48deb4d. Regressions
happened because 'run_default' var did not get initialized when default
case was the last one.

Now all the switch tests in es3conform suite are passing.

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=81857

src/glsl/ast_to_hir.cpp

index a15ee9c057237bc3c37b2fc8c8ba25b5d676bd71..7249a06c928fcfa36c80e8c3c7aca004e0ab7829 100644 (file)
@@ -4597,12 +4597,6 @@ ast_case_statement_list::hir(exec_list *instructions,
     */
    if (!default_case.is_empty()) {
 
-      /* Default case was the last one, no checks required. */
-      if (after_default.is_empty()) {
-         instructions->append_list(&default_case);
-         return NULL;
-      }
-
       ir_rvalue *const true_val = new (state) ir_constant(true);
       ir_dereference_variable *deref_run_default_var =
          new(state) ir_dereference_variable(state->switch_state.run_default);
@@ -4614,6 +4608,12 @@ ast_case_statement_list::hir(exec_list *instructions,
          new(state) ir_assignment(deref_run_default_var, true_val);
       instructions->push_tail(init_var);
 
+      /* Default case was the last one, no checks required. */
+      if (after_default.is_empty()) {
+         instructions->append_list(&default_case);
+         return NULL;
+      }
+
       foreach_in_list(ir_instruction, ir, &after_default) {
          ir_assignment *assign = ir->as_assignment();