diff options
author | Brian <[email protected]> | 2007-02-05 17:18:10 -0700 |
---|---|---|
committer | Brian <[email protected]> | 2007-02-05 17:18:10 -0700 |
commit | 86080796471df6a9e126fd536b21c3b10cb5310c (patch) | |
tree | 26d7c96f3aa66061aacf5c9ca68f1a073b685f93 /src/mesa/swrast/s_fragprog.c | |
parent | d9731b26e759671d63e357eee2c921e90448ada2 (diff) |
Use IR node's BranchNode field for IF/ELSE/ENDIF instructions.
This allows us to back-patch the IF/ELSE instruction's BranchTarget field
to point to the location of the ELSE/ENDIF instructions. No longer have to
search for ELSE/ENDIF in the interpreter. Also makes it trivial to translate
IF/ELSE instructions into conditional/unconditional BRA instructions.
Diffstat (limited to 'src/mesa/swrast/s_fragprog.c')
-rw-r--r-- | src/mesa/swrast/s_fragprog.c | 57 |
1 files changed, 6 insertions, 51 deletions
diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c index 287dd9b1dbe..fbd25c0fbfe 100644 --- a/src/mesa/swrast/s_fragprog.c +++ b/src/mesa/swrast/s_fragprog.c @@ -897,62 +897,17 @@ execute_program( GLcontext *ctx, /* do if-clause (just continue execution) */ } else { - /* search for else-clause or endif */ - /* XXX could encode location of the else/endif statement - * in the IF instruction to avoid searching... - */ - GLint ifDepth = 1; - do { - pc++; - inst = program->Base.Instructions + pc; - if (inst->Opcode == OPCODE_END) { - /* mal-formed program! */ - _mesa_problem(ctx, "END found before ELSE/ENDIF"); - return GL_FALSE; - } - else if (inst->Opcode == OPCODE_IF) { - /* nested if */ - ifDepth++; - } - else if (inst->Opcode == OPCODE_ELSE) { - if (ifDepth == 1) { - /* ok, continue normal execution */ - break; - } - } - else if (inst->Opcode == OPCODE_ENDIF) { - ifDepth--; - if (ifDepth == 0) { - /* ok, continue normal execution */ - break; - } - } - assert(ifDepth >= 0); - } while (pc < maxInst); + /* go to the instruction after ELSE or ENDIF */ + assert(inst->BranchTarget >= 0); + pc = inst->BranchTarget - 1; } } break; case OPCODE_ELSE: { - /* find/goto ENDIF */ - GLint ifDepth = 1; - do { - pc++; - inst = program->Base.Instructions + pc; - if (inst->Opcode == OPCODE_END) { - /* mal-formed program! */ - abort(); - } - else if (inst->Opcode == OPCODE_IF) { - ifDepth++; - } - else if (inst->Opcode == OPCODE_ENDIF) { - ifDepth--; - if (ifDepth == 0) - break; - } - assert(ifDepth >= 0); - } while (pc < maxInst); + /* goto ENDIF */ + assert(inst->BranchTarget >= 0); + pc = inst->BranchTarget - 1; } break; case OPCODE_ENDIF: |