glsl: don't unroll loops containing continue/break
authorBrian Paul <brianp@vmware.com>
Wed, 17 Jun 2009 19:51:35 +0000 (13:51 -0600)
committerBrian Paul <brianp@vmware.com>
Fri, 26 Jun 2009 19:16:32 +0000 (13:16 -0600)
Just search the AST in _slang_can_unroll_for_loop().

src/mesa/shader/slang/slang_codegen.c

index f19da41b0d6dca6163b0041bbec811f2a5a12e3f..f6274780ad68721a1776a101ce28a50567722584 100644 (file)
@@ -2488,6 +2488,12 @@ _slang_can_unroll_for_loop(slang_assemble_ctx * A, const slang_operation *oper)
    assert(oper->type == SLANG_OPER_FOR);
    assert(oper->num_children == 4);
 
+   if (_slang_find_node_type((slang_operation *) oper, SLANG_OPER_CONTINUE) ||
+       _slang_find_node_type((slang_operation *) oper, SLANG_OPER_BREAK)) {
+      /* dont't unroll loops containing continue/break statements */
+      return GL_FALSE;
+   }
+
    /* children[0] must be either "int i=constant" or "i=constant" */
    if (oper->children[0].type == SLANG_OPER_BLOCK_NO_NEW_SCOPE) {
       slang_variable *var;