glsl: fix variable scope for loop-expression
We need to evaluate the loop-expression of a for loop before
we evaluate the loop body otherwise we will find the wrong
variable for the following loop.
int var_0 = 0;
for(; var_0 < 10; var_0++) {
const float var_0 = 1.0;
gl_FragColor = vec4(0.0, var_0, 0.0, 0.0);
}
Fixes: a87ac255cf
("Initial commit. lol")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5262
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:

committed by
Marge Bot

parent
732cd9db44
commit
8bbbbb02cd
@@ -7138,11 +7138,15 @@ 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);
|
||||
|
||||
if (body != NULL)
|
||||
body->hir(& stmt->body_instructions, state);
|
||||
|
||||
if (rest_expression != NULL)
|
||||
rest_expression->hir(& stmt->body_instructions, state);
|
||||
stmt->body_instructions.append_list(&rest_instructions);
|
||||
|
||||
if (mode == ast_do_while)
|
||||
condition_to_hir(&stmt->body_instructions, state);
|
||||
|
Reference in New Issue
Block a user