mesa: Branch 'glsl-compiler-1' - 8 commits

Brian Paul brianp at kemper.freedesktop.org
Fri Feb 9 04:00:30 UTC 2007


 src/mesa/shader/prog_instruction.h    |    2 
 src/mesa/shader/prog_parameter.c      |   21 +++-
 src/mesa/shader/slang/slang_codegen.c |  163 +++++++++++++++++++++++++++-------
 src/mesa/shader/slang/slang_emit.c    |   38 +++++--
 src/mesa/swrast/s_fragprog.c          |   10 --
 5 files changed, 180 insertions(+), 54 deletions(-)

New commits:
diff-tree 5e6908944bbc76be020a3f5306c2a674f944f42e (from bd9615bbc59b0ce626bb32e2a005fccec20e7331)
Author: Brian <brian at nostromo.localnet.net>
Date:   Thu Feb 8 20:39:42 2007 -0700

    do full swizzled matching in _mesa_lookup_parameter_constant()

diff --git a/src/mesa/shader/prog_parameter.c b/src/mesa/shader/prog_parameter.c
index a87dafc..870e826 100644
--- a/src/mesa/shader/prog_parameter.c
+++ b/src/mesa/shader/prog_parameter.c
@@ -493,17 +493,28 @@ _mesa_lookup_parameter_constant(const st
                }
             }
          }
-         else if (list->Parameters[i].Size >= vSize) {
-            /* see if we can match this constant */
-            GLuint match = 0, j;
+         else if (vSize <= list->Parameters[i].Size) {
+            /* see if we can match this constant (with a swizzle) */
+            GLuint swz[4];
+            GLuint match = 0, j, k;
             for (j = 0; j < vSize; j++) {
-               if (list->ParameterValues[i][j] == v[j]) {
+               if (v[j] == list->ParameterValues[i][j]) {
+                  swz[j] = j;
                   match++;
                }
+               else {
+                  for (k = 0; k < list->Parameters[i].Size; k++) {
+                     if (v[j] == list->ParameterValues[i][k]) {
+                        swz[j] = k;
+                        match++;
+                        break;
+                     }
+                  }
+               }
             }
             if (match == vSize) {
                *posOut = i;
-               *swizzleOut = SWIZZLE_NOOP;
+               *swizzleOut = MAKE_SWIZZLE4(swz[0], swz[1], swz[2], swz[3]);
                return GL_TRUE;
             }
          }
diff-tree bd9615bbc59b0ce626bb32e2a005fccec20e7331 (from c0a9f554be0b82f2e6ce2d9318854ecd24a1a890)
Author: Brian <brian at nostromo.localnet.net>
Date:   Thu Feb 8 17:40:29 2007 -0700

    Check for constant-valued while/do loop conditions.
    
    Allows us to:
    1. avoid generating constant-valued BRK test for while(1)..
    2. discard entire loop for while(0).
    3. detection infinite loops at compile-time.

diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index 7566ad2..6285454 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -1408,19 +1408,48 @@ _slang_gen_function_call_name(slang_asse
 }
 
 
+static GLboolean
+_slang_is_constant_cond(const slang_operation *oper, GLboolean *value)
+{
+   if (oper->type == slang_oper_literal_float ||
+       oper->type == slang_oper_literal_int ||
+       oper->type == slang_oper_literal_bool) {
+      if (oper->literal[0])
+         *value = GL_TRUE;
+      else
+         *value = GL_FALSE;
+      return GL_TRUE;
+   }
+   else if (oper->type == slang_oper_expression &&
+            oper->num_children == 1) {
+      return _slang_is_constant_cond(&oper->children[0], value);
+   }
+   return GL_FALSE;
+}
+
+
+
 /**
  * Generate loop code using high-level IR_LOOP instruction
  */
 static slang_ir_node *
 _slang_gen_while(slang_assemble_ctx * A, const slang_operation *oper)
 {
-   slang_ir_node *prevLoop;
    /*
     * LOOP:
     *    BREAK if !expr (child[0])
     *    body code (child[1])
     */
-   slang_ir_node *loop, *cond, *breakIf, *body;
+   slang_ir_node *prevLoop, *loop, *cond, *breakIf, *body;
+   GLboolean isConst, constTrue;
+
+   /* Check if loop condition is a constant */
+   isConst = _slang_is_constant_cond(&oper->children[0], &constTrue);
+
+   if (isConst && !constTrue) {
+      /* loop is never executed! */
+      return new_node0(IR_NOP);
+   }
 
    loop = new_loop(NULL);
 
@@ -1429,10 +1458,23 @@ _slang_gen_while(slang_assemble_ctx * A,
    A->CurLoop = loop;
 
    cond = new_cond(_slang_gen_operation(A, &oper->children[0]));
-   breakIf = new_break_if(A->CurLoop, cond, GL_FALSE);
+   if (isConst && constTrue) {
+      /* while(nonzero constant), no conditional break */
+      breakIf = NULL;
+   }
+   else {
+      breakIf = new_break_if(A->CurLoop, cond, GL_FALSE);
+   }
    body = _slang_gen_operation(A, &oper->children[1]);
    loop->Children[0] = new_seq(breakIf, body);
 
+   /* Do infinite loop detection */
+   if (loop->BranchNode == 0 && isConst && constTrue) {
+      /* infinite loop detected */
+      A->CurLoop = prevLoop; /* clean-up */
+      RETURN_ERROR("Infinite loop detected!", 0);
+   }
+
    /* pop loop, restore prev */
    A->CurLoop = prevLoop;
 
@@ -1446,13 +1488,16 @@ _slang_gen_while(slang_assemble_ctx * A,
 static slang_ir_node *
 _slang_gen_do(slang_assemble_ctx * A, const slang_operation *oper)
 {
-   slang_ir_node *prevLoop;
    /*
     * LOOP:
     *    body code (child[0])
     *    BREAK if !expr (child[1])
     */
-   slang_ir_node *loop, *cond, *breakIf, *body;
+   slang_ir_node *prevLoop, *loop, *cond, *breakIf, *body;
+   GLboolean isConst, constTrue;
+
+   /* Check if loop condition is a constant */
+   isConst = _slang_is_constant_cond(&oper->children[0], &constTrue);
 
    loop = new_loop(NULL);
 
@@ -1462,7 +1507,13 @@ _slang_gen_do(slang_assemble_ctx * A, co
 
    body = _slang_gen_operation(A, &oper->children[0]);
    cond = new_cond(_slang_gen_operation(A, &oper->children[1]));
-   breakIf = new_break_if(A->CurLoop, cond, GL_FALSE);
+   if (isConst && constTrue) {
+      /* while(nonzero constant), no conditional break */
+      breakIf = NULL;
+   }
+   else {
+      breakIf = new_break_if(A->CurLoop, cond, GL_FALSE);
+   }
    loop->Children[0] = new_seq(body, breakIf);
 
    /* pop loop, restore prev */
@@ -1478,7 +1529,6 @@ _slang_gen_do(slang_assemble_ctx * A, co
 static slang_ir_node *
 _slang_gen_for(slang_assemble_ctx * A, const slang_operation *oper)
 {
-   slang_ir_node *prevLoop;
    /*
     * init (child[0])
     * LOOP:
@@ -1486,7 +1536,7 @@ _slang_gen_for(slang_assemble_ctx * A, c
     *    body code (child[3])
     *    incr code (child[2])   // XXX continue here
     */
-   slang_ir_node *loop, *cond, *breakIf, *body, *init, *incr;
+   slang_ir_node *prevLoop, *loop, *cond, *breakIf, *body, *init, *incr;
 
    init = _slang_gen_operation(A, &oper->children[0]);
    loop = new_loop(NULL);
diff-tree c0a9f554be0b82f2e6ce2d9318854ecd24a1a890 (from 6230ae7faf46e0ebcb4807df051c8b50482089dd)
Author: Brian <brian at nostromo.localnet.net>
Date:   Thu Feb 8 17:11:18 2007 -0700

    optimize conditional breaks/continues

diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index 2da5317..7566ad2 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -614,12 +614,35 @@ new_break(slang_ir_node *loopNode)
 }
 
 
+/**
+ * Make new IR_BREAK_IF_TRUE or IR_BREAK_IF_FALSE node.
+ */
+static slang_ir_node *
+new_break_if(slang_ir_node *loopNode, slang_ir_node *cond, GLboolean breakTrue)
+{
+   slang_ir_node *n;
+   assert(loopNode);
+   assert(loopNode->Opcode == IR_LOOP);
+   n = new_node1(breakTrue ? IR_BREAK_IF_TRUE : IR_BREAK_IF_FALSE, cond);
+   if (n) {
+      /* insert this node at head of linked list */
+      n->BranchNode = loopNode->BranchNode;
+      loopNode->BranchNode = n;
+   }
+   return n;
+}
+
+
+/**
+ * Make new IR_CONT_IF_TRUE or IR_CONT_IF_FALSE node.
+ */
 static slang_ir_node *
-new_break_if_false(slang_ir_node *loopNode, slang_ir_node *cond)
+new_cont_if(slang_ir_node *loopNode, slang_ir_node *cond, GLboolean contTrue)
 {
-   slang_ir_node *n = new_node1(IR_BREAK_IF_FALSE, cond);
+   slang_ir_node *n;
    assert(loopNode);
    assert(loopNode->Opcode == IR_LOOP);
+   n = new_node1(contTrue ? IR_CONT_IF_TRUE : IR_CONT_IF_FALSE, cond);
    if (n) {
       /* insert this node at head of linked list */
       n->BranchNode = loopNode->BranchNode;
@@ -1406,7 +1429,7 @@ _slang_gen_while(slang_assemble_ctx * A,
    A->CurLoop = loop;
 
    cond = new_cond(_slang_gen_operation(A, &oper->children[0]));
-   breakIf = new_break_if_false(A->CurLoop, cond);
+   breakIf = new_break_if(A->CurLoop, cond, GL_FALSE);
    body = _slang_gen_operation(A, &oper->children[1]);
    loop->Children[0] = new_seq(breakIf, body);
 
@@ -1439,7 +1462,7 @@ _slang_gen_do(slang_assemble_ctx * A, co
 
    body = _slang_gen_operation(A, &oper->children[0]);
    cond = new_cond(_slang_gen_operation(A, &oper->children[1]));
-   breakIf = new_break_if_false(A->CurLoop, cond);
+   breakIf = new_break_if(A->CurLoop, cond, GL_FALSE);
    loop->Children[0] = new_seq(body, breakIf);
 
    /* pop loop, restore prev */
@@ -1473,7 +1496,7 @@ _slang_gen_for(slang_assemble_ctx * A, c
    A->CurLoop = loop;
 
    cond = new_cond(_slang_gen_operation(A, &oper->children[1]));
-   breakIf = new_break_if_false(A->CurLoop, cond);
+   breakIf = new_break_if(A->CurLoop, cond, GL_FALSE);
    body = _slang_gen_operation(A, &oper->children[3]);
    incr = _slang_gen_operation(A, &oper->children[2]);
    loop->Children[0] = new_seq(breakIf,
@@ -1537,6 +1560,23 @@ _slang_gen_if(slang_assemble_ctx * A, co
 
 
 /**
+ * Determine if the given operation is of a specific type.
+ */
+static GLboolean
+is_operation_type(const const slang_operation *oper, slang_operation_type type)
+{
+   if (oper->type == type)
+      return GL_TRUE;
+   else if ((oper->type == slang_oper_block_new_scope ||
+             oper->type == slang_oper_block_no_new_scope) &&
+            oper->num_children == 1)
+      return is_operation_type(&oper->children[0], type);
+   else
+      return GL_FALSE;
+}
+
+
+/**
  * Generate IR tree for an if/then/else conditional using high-level
  * IR_IF instruction.
  */
@@ -1551,24 +1591,40 @@ _slang_gen_hl_if(slang_assemble_ctx * A,
     *    else-body code
     * ENDIF
     */
-   /* XXX special cases to check for:
-    * if body of conditiona is just a "break", emit a conditional break
-    * instruction.
-    */
    const GLboolean haveElseClause = !_slang_is_noop(&oper->children[2]);
    slang_ir_node *ifNode, *cond, *ifBody, *elseBody;
 
    cond = _slang_gen_operation(A, &oper->children[0]);
    cond = new_cond(cond);
-   ifBody = _slang_gen_operation(A, &oper->children[1]);
-   if (haveElseClause)
-      elseBody = _slang_gen_operation(A, &oper->children[2]);
-   else
-      elseBody = NULL;
-
-   ifNode = new_if(cond, ifBody, elseBody);
 
-   return ifNode;
+   if (is_operation_type(&oper->children[1], slang_oper_break)) {
+      /* Special case: generate a conditional break */
+      ifBody = new_break_if(A->CurLoop, cond, GL_TRUE);
+      if (haveElseClause) {
+         elseBody = _slang_gen_operation(A, &oper->children[2]);
+         return new_seq(ifBody, elseBody);
+      }
+      return ifBody;
+   }
+   else if (is_operation_type(&oper->children[1], slang_oper_continue)) {
+      /* Special case: generate a conditional break */
+      ifBody = new_cont_if(A->CurLoop, cond, GL_TRUE);
+      if (haveElseClause) {
+         elseBody = _slang_gen_operation(A, &oper->children[2]);
+         return new_seq(ifBody, elseBody);
+      }
+      return ifBody;
+   }
+   else {
+      /* general case */
+      ifBody = _slang_gen_operation(A, &oper->children[1]);
+      if (haveElseClause)
+         elseBody = _slang_gen_operation(A, &oper->children[2]);
+      else
+         elseBody = NULL;
+      ifNode = new_if(cond, ifBody, elseBody);
+      return ifNode;
+   }
 }
 
 
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c
index c43f79c..1b43042 100644
--- a/src/mesa/shader/slang/slang_emit.c
+++ b/src/mesa/shader/slang/slang_emit.c
@@ -1156,9 +1156,9 @@ emit_loop(slang_var_table *vt, slang_ir_
       beginInst->BranchTarget = prog->NumInstructions - 1;
    }
 
-   /* Done emitting loop code.  Now walk over the loop's linked list
-    * of BREAK and CONT nodes, filling in their BranchTarget fields
-    * (which will point to the ENDLOOP or ENDLOOP+1 instructions).
+   /* Done emitting loop code.  Now walk over the loop's linked list of
+    * BREAK and CONT nodes, filling in their BranchTarget fields (which
+    * will point to the ENDLOOP+1 or BGNLOOP instructions, respectively).
     */
    for (ir = n->BranchNode; ir; ir = ir->BranchNode) {
       struct prog_instruction *inst = prog->Instructions + ir->InstLocation;
@@ -1186,7 +1186,8 @@ emit_loop(slang_var_table *vt, slang_ir_
 
 
 /**
- * Emit code for IR_CONT or IR_BREAK.
+ * "Continue" or "break" statement.
+ * Either OPCODE_CONT, OPCODE_BRK or OPCODE_BRA will be emitted.
  */
 static struct prog_instruction *
 emit_cont_break(slang_var_table *vt, slang_ir_node *n, struct gl_program *prog)
@@ -1207,7 +1208,8 @@ emit_cont_break(slang_var_table *vt, sla
 
 
 /**
- * Conditional loop continue/break.
+ * Conditional "continue" or "break" statement.
+ * Either OPCODE_CONT, OPCODE_BRK or OPCODE_BRA will be emitted.
  */
 static struct prog_instruction *
 emit_cont_break_if(slang_var_table *vt, slang_ir_node *n,
@@ -1223,7 +1225,11 @@ emit_cont_break_if(slang_var_table *vt, 
 
    n->InstLocation = prog->NumInstructions;
    if (EmitHighLevelInstructions) {
-      opcode = (n->Opcode == IR_CONT) ? OPCODE_CONT : OPCODE_BRK;
+      if (n->Opcode == IR_CONT_IF_TRUE ||
+          n->Opcode == IR_CONT_IF_FALSE)
+         opcode = OPCODE_CONT;
+      else
+         opcode = OPCODE_BRK;
    }
    else {
       opcode = OPCODE_BRA;
@@ -1452,8 +1458,10 @@ emit(slang_var_table *vt, slang_ir_node 
    case IR_LOOP:
       return emit_loop(vt, n, prog);
    case IR_BREAK_IF_FALSE:
+   case IR_CONT_IF_FALSE:
       return emit_cont_break_if(vt, n, prog, GL_FALSE);
    case IR_BREAK_IF_TRUE:
+   case IR_CONT_IF_TRUE:
       return emit_cont_break_if(vt, n, prog, GL_TRUE);
    case IR_BREAK:
       /* fall-through */
diff-tree 6230ae7faf46e0ebcb4807df051c8b50482089dd (from a1c2e87c4b7958b0f1a884bba893153b382973df)
Author: Brian <brian at nostromo.localnet.net>
Date:   Thu Feb 8 15:09:47 2007 -0700

    cont at top of loop, little clean-ups

diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c
index e572712..c43f79c 100644
--- a/src/mesa/shader/slang/slang_emit.c
+++ b/src/mesa/shader/slang/slang_emit.c
@@ -40,7 +40,7 @@
 
 
 #define PEEPHOLE_OPTIMIZATIONS 1
-#define ANNOTATE 1
+#define ANNOTATE 0
 
 
 static GLboolean EmitHighLevelInstructions = GL_TRUE;
@@ -59,7 +59,7 @@ typedef struct
 
 
 
-static slang_ir_info IrInfo[] = {
+static const slang_ir_info IrInfo[] = {
    /* binary ops */
    { IR_ADD, "IR_ADD", OPCODE_ADD, 4, 2 },
    { IR_SUB, "IR_SUB", OPCODE_SUB, 4, 2 },
@@ -124,7 +124,7 @@ static slang_ir_info IrInfo[] = {
 };
 
 
-static slang_ir_info *
+static const slang_ir_info *
 slang_find_ir_info(slang_ir_opcode opcode)
 {
    GLuint i;
@@ -334,6 +334,11 @@ slang_print_ir(const slang_ir_node *n, i
       break;
    case IR_BREAK_IF_FALSE:
       printf("BREAK_IF_FALSE\n");
+      slang_print_ir(n->Children[0], indent+3);
+      break;
+   case IR_BREAK_IF_TRUE:
+      printf("BREAK_IF_TRUE\n");
+      slang_print_ir(n->Children[0], indent+3);
       break;
 
    case IR_VAR:
@@ -1157,11 +1162,13 @@ emit_loop(slang_var_table *vt, slang_ir_
     */
    for (ir = n->BranchNode; ir; ir = ir->BranchNode) {
       struct prog_instruction *inst = prog->Instructions + ir->InstLocation;
+      assert(inst->BranchTarget < 0);
       if (ir->Opcode == IR_BREAK ||
           ir->Opcode == IR_BREAK_IF_FALSE ||
           ir->Opcode == IR_BREAK_IF_TRUE) {
          assert(inst->Opcode == OPCODE_BRK ||
                 inst->Opcode == OPCODE_BRA);
+         /* go to instruction after end of loop */
          inst->BranchTarget = endInstLoc + 1;
       }
       else {
@@ -1170,8 +1177,8 @@ emit_loop(slang_var_table *vt, slang_ir_
                 ir->Opcode == IR_CONT_IF_TRUE);
          assert(inst->Opcode == OPCODE_CONT ||
                 inst->Opcode == OPCODE_BRA);
-         /* XXX goto top of loop instead! */
-         inst->BranchTarget = endInstLoc;
+         /* to go instruction at top of loop */
+         inst->BranchTarget = beginInstLoc;
       }
    }
    return NULL;
diff-tree a1c2e87c4b7958b0f1a884bba893153b382973df (from fbf0f400b743686ccdf78b927fd5de477d764a9d)
Author: Brian <brian at nostromo.localnet.net>
Date:   Thu Feb 8 15:08:16 2007 -0700

    remove some cruft

diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index f71bbea..2da5317 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -47,8 +47,6 @@
 #include "slang_print.h"
 
 
-static GLboolean UseHighLevelInstructions = GL_TRUE;
-
 static slang_ir_node *
 _slang_gen_operation(slang_assemble_ctx * A, slang_operation *oper);
 
@@ -2441,8 +2439,7 @@ _slang_gen_operation(slang_assemble_ctx 
    case slang_oper_identifier:
       return _slang_gen_variable(A, oper);
    case slang_oper_if:
-      if (A->program->Target == GL_FRAGMENT_PROGRAM_ARB
-          && UseHighLevelInstructions) {
+      if (A->program->Target == GL_FRAGMENT_PROGRAM_ARB) {
          return _slang_gen_hl_if(A, oper);
       }
       else {
diff-tree fbf0f400b743686ccdf78b927fd5de477d764a9d (from 34af2b7194ad473c8ae20bcff933910f8386c3f0)
Author: Brian <brian at nostromo.localnet.net>
Date:   Thu Feb 8 14:10:54 2007 -0700

    fix broken BRA for return stmts

diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index 6671f31..f71bbea 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -1407,7 +1407,7 @@ _slang_gen_while(slang_assemble_ctx * A,
    prevLoop = A->CurLoop;
    A->CurLoop = loop;
 
-   cond = _slang_gen_operation(A, &oper->children[0]);
+   cond = new_cond(_slang_gen_operation(A, &oper->children[0]));
    breakIf = new_break_if_false(A->CurLoop, cond);
    body = _slang_gen_operation(A, &oper->children[1]);
    loop->Children[0] = new_seq(breakIf, body);
@@ -1440,7 +1440,7 @@ _slang_gen_do(slang_assemble_ctx * A, co
    A->CurLoop = loop;
 
    body = _slang_gen_operation(A, &oper->children[0]);
-   cond = _slang_gen_operation(A, &oper->children[1]);
+   cond = new_cond(_slang_gen_operation(A, &oper->children[1]));
    breakIf = new_break_if_false(A->CurLoop, cond);
    loop->Children[0] = new_seq(body, breakIf);
 
@@ -1474,7 +1474,7 @@ _slang_gen_for(slang_assemble_ctx * A, c
    prevLoop = A->CurLoop;
    A->CurLoop = loop;
 
-   cond = _slang_gen_operation(A, &oper->children[1]);
+   cond = new_cond(_slang_gen_operation(A, &oper->children[1]));
    breakIf = new_break_if_false(A->CurLoop, cond);
    body = _slang_gen_operation(A, &oper->children[3]);
    incr = _slang_gen_operation(A, &oper->children[2]);
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c
index d83880a..e572712 100644
--- a/src/mesa/shader/slang/slang_emit.c
+++ b/src/mesa/shader/slang/slang_emit.c
@@ -487,6 +487,7 @@ new_instruction(struct gl_program *prog,
    prog->NumInstructions++;
    _mesa_init_instructions(inst, 1);
    inst->Opcode = opcode;
+   inst->BranchTarget = -1; /* invalid */
    return inst;
 }
 
diff-tree 34af2b7194ad473c8ae20bcff933910f8386c3f0 (from c81aedeaeca431b6e91e34559eaabfce80a9796f)
Author: Brian <brian at nostromo.localnet.net>
Date:   Thu Feb 8 14:10:19 2007 -0700

    consolidate BRA with BRK, CONT

diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c
index ce028f7..fe41c0b 100644
--- a/src/mesa/swrast/s_fragprog.c
+++ b/src/mesa/swrast/s_fragprog.c
@@ -709,18 +709,14 @@ execute_program( GLcontext *ctx,
             break;
          case OPCODE_ENDSUB: /* end subroutine */
             break;
-         case OPCODE_BRA: /* conditional branch */
-            if (eval_condition(machine, inst)) {
-               /* take branch */
-               pc = inst->BranchTarget - 1;
-            }
-            break;
+         case OPCODE_BRA: /* branch (conditional) */
+            /* fall-through */
          case OPCODE_BRK: /* break out of loop (conditional) */
             /* fall-through */
          case OPCODE_CONT: /* continue loop (conditional) */
-            /* Subtract 1 here since we'll do pc++ at end of for-loop */
             if (eval_condition(machine, inst)) {
                /* take branch */
+               /* Subtract 1 here since we'll do pc++ at end of for-loop */
                pc = inst->BranchTarget - 1;
             }
             break;
diff-tree c81aedeaeca431b6e91e34559eaabfce80a9796f (from b768c485474baefdde63098776e9d32c17b859ab)
Author: Brian <brian at nostromo.localnet.net>
Date:   Thu Feb 8 14:09:34 2007 -0700

    change BranchTarget to GLint

diff --git a/src/mesa/shader/prog_instruction.h b/src/mesa/shader/prog_instruction.h
index 100aac4..8514cf6 100644
--- a/src/mesa/shader/prog_instruction.h
+++ b/src/mesa/shader/prog_instruction.h
@@ -401,7 +401,7 @@ struct prog_instruction
    /**
     * For BRA and CAL instructions, the location to jump to.
     */
-   GLuint BranchTarget;
+   GLint BranchTarget;
 
    /**
     * For TEX instructions in shaders, the sampler to use for the



More information about the mesa-commit mailing list