Looks alright to me though I still don't really understand this code :-) Reviewed-by: Roland Scheidegger <srol...@vmware.com>
Am 07.04.2017 um 03:24 schrieb Timothy Arceri: > Fixes the case were a loop contains a return and the loop is > nested inside an if. > > https://bugs.freedesktop.org/show_bug.cgi?id=100303 > --- > src/compiler/glsl/lower_jumps.cpp | 6 ++++++ > src/compiler/glsl/tests/lower_jumps/create_test_cases.py | 5 ++++- > 2 files changed, 10 insertions(+), 1 deletion(-) > > diff --git a/src/compiler/glsl/lower_jumps.cpp > b/src/compiler/glsl/lower_jumps.cpp > index e165172..7dc3405 100644 > --- a/src/compiler/glsl/lower_jumps.cpp > +++ b/src/compiler/glsl/lower_jumps.cpp > @@ -938,20 +938,26 @@ lower_continue: > * those instructions into the else clause of the generated if > * statement. > */ > move_outer_block_inside(ir, &return_if->else_instructions); > > /* In case the loop is embedded inside an if add a new return to > * the return flag then branch and let a future pass tidy it up. > */ > if (this->function.signature->return_type->is_void()) > return_if->then_instructions.push_tail(new(ir) > ir_return(NULL)); > + else { > + assert(this->function.return_value); > + ir_variable* return_value = this->function.return_value; > + return_if->then_instructions.push_tail( > + new(ir) ir_return(new(ir) > ir_dereference_variable(return_value))); > + } > } > > ir->insert_after(return_if); > } > > this->loop = saved_loop; > --this->function.nesting_depth; > } > > virtual void visit(ir_function_signature *ir) > diff --git a/src/compiler/glsl/tests/lower_jumps/create_test_cases.py > b/src/compiler/glsl/tests/lower_jumps/create_test_cases.py > index 20f5ace..623487e 100644 > --- a/src/compiler/glsl/tests/lower_jumps/create_test_cases.py > +++ b/src/compiler/glsl/tests/lower_jumps/create_test_cases.py > @@ -621,21 +621,24 @@ def test_lower_return_non_void_at_end_of_loop(): > assign_x('b', const_float(3)) + > return_(const_float(4)) > )) > expected_sexp = make_test_case('sub', 'float', ( > declare_execute_flag() + > declare_return_value() + > declare_return_flag() + > loop(assign_x('a', const_float(1)) + > lowered_return_simple(const_float(2)) + > break_()) + > - if_not_return_flag(assign_x('b', const_float(3)) + > + if_return_flag(assign_x('return_value', '(var_ref > return_value)') + > + assign_x('return_flag', const_bool(1)) + > + assign_x('execute_flag', const_bool(0)), > + assign_x('b', const_float(3)) + > lowered_return(const_float(4))) + > final_return() > )) > create_test_case(doc_string, input_sexp, input_sexp, > 'return_non_void_at_end_of_loop_lower_nothing') > create_test_case(doc_string, input_sexp, expected_sexp, > 'return_non_void_at_end_of_loop_lower_return', > lower_sub_return=True) > create_test_case(doc_string, input_sexp, expected_sexp, > 'return_non_void_at_end_of_loop_lower_return_and_break', > lower_sub_return=True, lower_break=True) > > if __name__ == '__main__': > _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev