summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-10-02 16:05:07 -0600
committerBrian <[email protected]>2007-10-02 16:05:07 -0600
commit53a6a55c7c56c6811a9e627c8624c05e83d4e04b (patch)
treedc747b23226305a650829e2de67e8c884e1837e3 /src/mesa
parentfe1d15acc7b0ed5d6eb22829f2d8547a36a852a9 (diff)
Implement CONT statement.
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/pipe/tgsi/exec/tgsi_exec.c25
-rw-r--r--src/mesa/pipe/tgsi/exec/tgsi_exec.h9
2 files changed, 26 insertions, 8 deletions
diff --git a/src/mesa/pipe/tgsi/exec/tgsi_exec.c b/src/mesa/pipe/tgsi/exec/tgsi_exec.c
index 4a42238636f..03720d2fa07 100644
--- a/src/mesa/pipe/tgsi/exec/tgsi_exec.c
+++ b/src/mesa/pipe/tgsi/exec/tgsi_exec.c
@@ -57,7 +57,7 @@
/** The execution mask depends on the conditional mask and the loop mask */
#define UPDATE_EXEC_MASK(MACH) \
- MACH->ExecMask = MACH->CondMask & MACH->LoopMask
+ MACH->ExecMask = MACH->CondMask & MACH->LoopMask & MACH->ContMask
#define CHAN_X 0
@@ -2178,14 +2178,19 @@ exec_instruction(
case TGSI_OPCODE_LOOP:
/* fall-through (for now) */
case TGSI_OPCODE_BGNLOOP2:
- /* push LoopMask */
+ /* push LoopMask and ContMasks */
assert(mach->LoopStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
mach->LoopStack[mach->LoopStackTop++] = mach->LoopMask;
+ assert(mach->ContStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
+ mach->ContStack[mach->ContStackTop++] = mach->ContMask;
break;
case TGSI_OPCODE_ENDLOOP:
/* fall-through (for now at least) */
case TGSI_OPCODE_ENDLOOP2:
+ /* Restore ContMask, but don't pop */
+ assert(mach->ContStackTop > 0);
+ mach->ContMask = mach->ContStack[mach->ContStackTop - 1];
if (mach->LoopMask) {
/* repeat loop: jump to instruction just past BGNLOOP */
*pc = inst->InstructionExtLabel.Label + 1;
@@ -2194,8 +2199,11 @@ exec_instruction(
/* exit loop: pop LoopMask */
assert(mach->LoopStackTop > 0);
mach->LoopMask = mach->LoopStack[--mach->LoopStackTop];
- UPDATE_EXEC_MASK(mach);
+ /* pop ContMask */
+ assert(mach->ContStackTop > 0);
+ mach->ContMask = mach->ContStack[--mach->ContStackTop];
}
+ UPDATE_EXEC_MASK(mach);
break;
case TGSI_OPCODE_BRK:
@@ -2206,16 +2214,18 @@ exec_instruction(
break;
case TGSI_OPCODE_CONT:
- assert (0);
+ /* turn off cont channels for each enabled exec channel */
+ mach->ContMask &= ~mach->ExecMask;
+ /* Todo: if mach->LoopMask == 0, jump to end of loop */
+ UPDATE_EXEC_MASK(mach);
break;
-
case TGSI_OPCODE_BGNSUB:
/* no-op */
break;
case TGSI_OPCODE_ENDSUB:
- assert( 0 );
+ /* no-op */
break;
case TGSI_OPCODE_NOISE1:
@@ -2255,9 +2265,12 @@ tgsi_exec_machine_run( struct tgsi_exec_machine *mach )
mach->CondMask = 0xf;
mach->LoopMask = 0xf;
+ mach->ContMask = 0xf;
mach->ExecMask = 0xf;
+
assert(mach->CondStackTop == 0);
assert(mach->LoopStackTop == 0);
+ assert(mach->ContStackTop == 0);
assert(mach->CallStackTop == 0);
mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0] = 0;
diff --git a/src/mesa/pipe/tgsi/exec/tgsi_exec.h b/src/mesa/pipe/tgsi/exec/tgsi_exec.h
index ae5ce8a7c93..e7827ecce15 100644
--- a/src/mesa/pipe/tgsi/exec/tgsi_exec.h
+++ b/src/mesa/pipe/tgsi/exec/tgsi_exec.h
@@ -138,8 +138,9 @@ struct tgsi_exec_machine
const struct tgsi_interp_coef *InterpCoefs;
/* Conditional execution masks */
- uint CondMask;
- uint LoopMask;
+ uint CondMask; /**< For IF/ELSE/ENDIF */
+ uint LoopMask; /**< For BGNLOOP/ENDLOOP */
+ uint ContMask; /**< For loop CONT statements */
uint ExecMask; /**< = CondMask & LoopMask */
/** Condition mask stack (for nested conditionals) */
@@ -150,6 +151,10 @@ struct tgsi_exec_machine
uint LoopStack[TGSI_EXEC_MAX_LOOP_NESTING];
int LoopStackTop;
+ /** Loop continue mask stack (see comments in tgsi_exec.c) */
+ uint ContStack[TGSI_EXEC_MAX_LOOP_NESTING];
+ int ContStackTop;
+
uint CallStack[TGSI_EXEC_MAX_CALL_NESTING];
int CallStackTop;