Re: [Mesa-dev] [PATCH 1/6] glsl: Save and restore the whole switch state for nesting.
On 01/30/2012 10:58 AM, Eric Anholt wrote: The series is, Reviewed-by: Ian Romanick ian.d.roman...@intel.com Sorry for taking so long to review. This stuffs them all in a struct for sanity. Fixes piglit glsl-1.30/execution/switch/fs-uniform-nested. NOTE: This is a candidate for the 8.0 branch. --- src/glsl/ast_to_hir.cpp | 497 +++ src/glsl/glsl_parser_extras.cpp |2 +- src/glsl/glsl_parser_extras.h | 16 +- 3 files changed, 255 insertions(+), 260 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index cde7052..25ccdab 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -3405,7 +3405,7 @@ ast_jump_statement::hir(exec_list *instructions, continue may only appear in a loop); } else if (mode == ast_break state-loop_nesting_ast == NULL -state-switch_nesting_ast == NULL) { +state-switch_state.switch_nesting_ast == NULL) { YYLTYPE loc = this-get_location(); _mesa_glsl_error( loc, state, @@ -3423,11 +3423,11 @@ ast_jump_statement::hir(exec_list *instructions, state); } -if (state-is_switch_innermost +if (state-switch_state.is_switch_innermost mode == ast_break) { /* Force break out of switch by setting is_break switch state. */ - ir_variable *const is_break_var = state-is_break_var; + ir_variable *const is_break_var = state-switch_state.is_break_var; ir_dereference_variable *const deref_is_break_var = new(ctx) ir_dereference_variable(is_break_var); ir_constant *const true_val = new(ctx) ir_constant(true); @@ -3530,25 +3530,22 @@ ast_switch_statement::hir(exec_list *instructions, /* Track the switch-statement nesting in a stack-like manner. */ - ir_variable *saved_test_var = state-test_var; - ir_variable *saved_is_fallthru_var = state-is_fallthru_var; - - bool save_is_switch_innermost = state-is_switch_innermost; - ast_switch_statement *saved_nesting_ast = state-switch_nesting_ast; + struct glsl_switch_state saved = state-switch_state; - state-is_switch_innermost = true; - state-switch_nesting_ast = this; + state-switch_state.is_switch_innermost = true; + state-switch_state.switch_nesting_ast = this; /* Initalize is_fallthru state to false. */ ir_rvalue *const is_fallthru_val = new (ctx) ir_constant(false); - state-is_fallthru_var = new(ctx) ir_variable(glsl_type::bool_type, - switch_is_fallthru_tmp, - ir_var_temporary); - instructions-push_tail(state-is_fallthru_var); + state-switch_state.is_fallthru_var = + new(ctx) ir_variable(glsl_type::bool_type, + switch_is_fallthru_tmp, + ir_var_temporary); + instructions-push_tail(state-switch_state.is_fallthru_var); ir_dereference_variable *deref_is_fallthru_var = - new(ctx) ir_dereference_variable(state-is_fallthru_var); + new(ctx) ir_dereference_variable(state-switch_state.is_fallthru_var); instructions-push_tail(new(ctx) ir_assignment(deref_is_fallthru_var, is_fallthru_val, NULL)); @@ -3556,13 +3553,13 @@ ast_switch_statement::hir(exec_list *instructions, /* Initalize is_break state to false. */ ir_rvalue *const is_break_val = new (ctx) ir_constant(false); - state-is_break_var = new(ctx) ir_variable(glsl_type::bool_type, - switch_is_break_tmp, - ir_var_temporary); - instructions-push_tail(state-is_break_var); + state-switch_state.is_break_var = new(ctx) ir_variable(glsl_type::bool_type, + switch_is_break_tmp, + ir_var_temporary); + instructions-push_tail(state-switch_state.is_break_var); ir_dereference_variable *deref_is_break_var = - new(ctx) ir_dereference_variable(state-is_break_var); + new(ctx) ir_dereference_variable(state-switch_state.is_break_var); instructions-push_tail(new(ctx) ir_assignment(deref_is_break_var, is_break_val, NULL)); @@ -3575,254 +3572,248 @@ ast_switch_statement::hir(exec_list *instructions, */ body-hir(instructions, state); - /* Restore previous nesting before returning. -*/ - state-switch_nesting_ast = saved_nesting_ast; - state-is_switch_innermost = save_is_switch_innermost; - - state-test_var = saved_test_var; - state-is_fallthru_var = saved_is_fallthru_var; - - /*
[Mesa-dev] [PATCH 1/6] glsl: Save and restore the whole switch state for nesting.
This stuffs them all in a struct for sanity. Fixes piglit glsl-1.30/execution/switch/fs-uniform-nested. NOTE: This is a candidate for the 8.0 branch. --- src/glsl/ast_to_hir.cpp | 497 +++ src/glsl/glsl_parser_extras.cpp |2 +- src/glsl/glsl_parser_extras.h | 16 +- 3 files changed, 255 insertions(+), 260 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index cde7052..25ccdab 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -3405,7 +3405,7 @@ ast_jump_statement::hir(exec_list *instructions, continue may only appear in a loop); } else if (mode == ast_break state-loop_nesting_ast == NULL -state-switch_nesting_ast == NULL) { +state-switch_state.switch_nesting_ast == NULL) { YYLTYPE loc = this-get_location(); _mesa_glsl_error( loc, state, @@ -3423,11 +3423,11 @@ ast_jump_statement::hir(exec_list *instructions, state); } -if (state-is_switch_innermost +if (state-switch_state.is_switch_innermost mode == ast_break) { /* Force break out of switch by setting is_break switch state. */ - ir_variable *const is_break_var = state-is_break_var; + ir_variable *const is_break_var = state-switch_state.is_break_var; ir_dereference_variable *const deref_is_break_var = new(ctx) ir_dereference_variable(is_break_var); ir_constant *const true_val = new(ctx) ir_constant(true); @@ -3530,25 +3530,22 @@ ast_switch_statement::hir(exec_list *instructions, /* Track the switch-statement nesting in a stack-like manner. */ - ir_variable *saved_test_var = state-test_var; - ir_variable *saved_is_fallthru_var = state-is_fallthru_var; - - bool save_is_switch_innermost = state-is_switch_innermost; - ast_switch_statement *saved_nesting_ast = state-switch_nesting_ast; + struct glsl_switch_state saved = state-switch_state; - state-is_switch_innermost = true; - state-switch_nesting_ast = this; + state-switch_state.is_switch_innermost = true; + state-switch_state.switch_nesting_ast = this; /* Initalize is_fallthru state to false. */ ir_rvalue *const is_fallthru_val = new (ctx) ir_constant(false); - state-is_fallthru_var = new(ctx) ir_variable(glsl_type::bool_type, - switch_is_fallthru_tmp, - ir_var_temporary); - instructions-push_tail(state-is_fallthru_var); + state-switch_state.is_fallthru_var = + new(ctx) ir_variable(glsl_type::bool_type, + switch_is_fallthru_tmp, + ir_var_temporary); + instructions-push_tail(state-switch_state.is_fallthru_var); ir_dereference_variable *deref_is_fallthru_var = - new(ctx) ir_dereference_variable(state-is_fallthru_var); + new(ctx) ir_dereference_variable(state-switch_state.is_fallthru_var); instructions-push_tail(new(ctx) ir_assignment(deref_is_fallthru_var, is_fallthru_val, NULL)); @@ -3556,13 +3553,13 @@ ast_switch_statement::hir(exec_list *instructions, /* Initalize is_break state to false. */ ir_rvalue *const is_break_val = new (ctx) ir_constant(false); - state-is_break_var = new(ctx) ir_variable(glsl_type::bool_type, - switch_is_break_tmp, - ir_var_temporary); - instructions-push_tail(state-is_break_var); + state-switch_state.is_break_var = new(ctx) ir_variable(glsl_type::bool_type, + switch_is_break_tmp, + ir_var_temporary); + instructions-push_tail(state-switch_state.is_break_var); ir_dereference_variable *deref_is_break_var = - new(ctx) ir_dereference_variable(state-is_break_var); + new(ctx) ir_dereference_variable(state-switch_state.is_break_var); instructions-push_tail(new(ctx) ir_assignment(deref_is_break_var, is_break_val, NULL)); @@ -3575,254 +3572,248 @@ ast_switch_statement::hir(exec_list *instructions, */ body-hir(instructions, state); - /* Restore previous nesting before returning. -*/ - state-switch_nesting_ast = saved_nesting_ast; - state-is_switch_innermost = save_is_switch_innermost; - - state-test_var = saved_test_var; - state-is_fallthru_var = saved_is_fallthru_var; - - /* Switch statements do not have r-values. -*/ - return NULL; -} - - -void -ast_switch_statement::test_to_hir(exec_list *instructions, -