mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 05:08:08 +02:00
glsl: handle scope correctly when inlining loop expression
We need to clone the previously evaluated loop expression when
inlining otherwise we will have conflicts with shadow variables
defined in deeper scopes.
Fixes: 5c02e2e2de ("glsl: Generate IR for switch statements")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5255
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12465>
This commit is contained in:
parent
8bbbbb02cd
commit
174c057926
2 changed files with 6 additions and 5 deletions
|
|
@ -1195,6 +1195,8 @@ public:
|
|||
ast_node *condition;
|
||||
ast_expression *rest_expression;
|
||||
|
||||
exec_list rest_instructions;
|
||||
|
||||
ast_node *body;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -6531,8 +6531,8 @@ ast_jump_statement::hir(exec_list *instructions,
|
|||
if (state->loop_nesting_ast != NULL &&
|
||||
mode == ast_continue && !state->switch_state.is_switch_innermost) {
|
||||
if (state->loop_nesting_ast->rest_expression) {
|
||||
state->loop_nesting_ast->rest_expression->hir(instructions,
|
||||
state);
|
||||
clone_ir_list(ctx, instructions,
|
||||
&state->loop_nesting_ast->rest_instructions);
|
||||
}
|
||||
if (state->loop_nesting_ast->mode ==
|
||||
ast_iteration_statement::ast_do_while) {
|
||||
|
|
@ -6780,8 +6780,8 @@ ast_switch_statement::hir(exec_list *instructions,
|
|||
|
||||
if (state->loop_nesting_ast != NULL) {
|
||||
if (state->loop_nesting_ast->rest_expression) {
|
||||
state->loop_nesting_ast->rest_expression->hir(&irif->then_instructions,
|
||||
state);
|
||||
clone_ir_list(ctx, &irif->then_instructions,
|
||||
&state->loop_nesting_ast->rest_instructions);
|
||||
}
|
||||
if (state->loop_nesting_ast->mode ==
|
||||
ast_iteration_statement::ast_do_while) {
|
||||
|
|
@ -7138,7 +7138,6 @@ ast_iteration_statement::hir(exec_list *instructions,
|
|||
if (mode != ast_do_while)
|
||||
condition_to_hir(&stmt->body_instructions, state);
|
||||
|
||||
exec_list rest_instructions;
|
||||
if (rest_expression != NULL)
|
||||
rest_expression->hir(&rest_instructions, state);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue