diff options
author | Brian Paul <[email protected]> | 2009-01-10 11:40:20 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-01-10 11:40:20 -0700 |
commit | 6333005f7aea3e5d1d86a5c47b3fa2a1ed2f3ff0 (patch) | |
tree | e366b0c255dc07f9c6b8fea4c3ead1bd1a6aae7c /src/mesa/shader/slang/slang_compile.c | |
parent | 1d352b42a106ed0c3cd0831fa681d07794b7ff3d (diff) |
glsl: force creation of new scope for for-loop body
Fixes regression in progs/demos/convolution.c due to loop unrolling.
This also allows the following to be compiled correctly:
for (int i = 0; i < n; i++) {
int i;
...
}
This fix is a bit of a hack, however. The better fix would be to change
the slang_shader.syn grammar. Will revisit that...
Diffstat (limited to 'src/mesa/shader/slang/slang_compile.c')
-rw-r--r-- | src/mesa/shader/slang/slang_compile.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index ec27fc69dff..add8594ff95 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -1138,8 +1138,26 @@ parse_statement(slang_parse_ctx * C, slang_output_ctx * O, RETURN0; if (!parse_child_operation(C, &o, oper, GL_FALSE)) RETURN0; +#if 0 if (!parse_child_operation(C, &o, oper, GL_TRUE)) RETURN0; +#else + /* force creation of new scope for loop body */ + { + slang_operation *ch; + slang_output_ctx oo = o; + + /* grow child array */ + ch = slang_operation_grow(&oper->num_children, &oper->children); + ch->type = SLANG_OPER_BLOCK_NEW_SCOPE; + + ch->locals->outer_scope = o.vars; + oo.vars = ch->locals; + + if (!parse_child_operation(C, &oo, ch, GL_TRUE)) + RETURN0; + } +#endif } break; case OP_PRECISION: |