break;
case TGSI_OPCODE_CAL:
- assert (0);
+ /* note that PC was already incremented above */
+ mach->CallStack[mach->CallStackTop++] = *pc;
+ *pc = inst->InstructionExtLabel.Label;
break;
case TGSI_OPCODE_RET:
- /* XXX: end of shader! */
- /*assert (0);*/
+ assert(mach->CallStackTop >= 0);
+ if (mach->CallStackTop == 0) {
+ /* XXX error? */
+ return;
+ }
+ *pc = mach->CallStack[--mach->CallStackTop];
break;
case TGSI_OPCODE_SSG:
UPDATE_EXEC_MASK(mach);
break;
- case TGSI_OPCODE_ENDLOOP:
- /* pop LoopMask */
- assert(mach->LoopStackTop > 0);
- mach->LoopMask = mach->LoopStack[--mach->LoopStackTop];
- UPDATE_EXEC_MASK(mach);
- break;
-
case TGSI_OPCODE_ENDREP:
assert (0);
break;
break;
case TGSI_OPCODE_BGNSUB:
- assert( 0 );
+ /* no-op */
break;
+ case TGSI_OPCODE_ENDLOOP:
+ /* fall-through (for now at least) */
case TGSI_OPCODE_ENDLOOP2:
if (mach->LoopMask) {
/* repeat loop: jump to instruction just past BGNLOOP */
void
tgsi_exec_machine_run( struct tgsi_exec_machine *mach )
{
+ uint i;
+ int pc = 0;
+
#if XXX_SSE
mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0] = 0;
#else
mach->CondMask = 0xf;
mach->LoopMask = 0xf;
mach->ExecMask = 0xf;
+ assert(mach->CondStackTop == 0);
+ assert(mach->LoopStackTop == 0);
+ assert(mach->CallStackTop == 0);
mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0] = 0;
mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0] = 0;
}
- {
- uint i;
- int pc = 0;
-
- for (i = 0; i < mach->NumDeclarations; i++) {
- exec_declaration( mach, mach->Declarations+i );
- }
+ /* execute declarations (interpolants) */
+ for (i = 0; i < mach->NumDeclarations; i++) {
+ exec_declaration( mach, mach->Declarations+i );
+ }
- while (pc != -1) {
- assert(pc < mach->NumInstructions);
- exec_instruction( mach, mach->Instructions + pc, &pc );
- }
+ /* execute instructions, until pc is set to -1 */
+ while (pc != -1) {
+ assert(pc < mach->NumInstructions);
+ exec_instruction( mach, mach->Instructions + pc, &pc );
}
#endif
case OPCODE_BRK:\r
fullinst->Instruction.Opcode = TGSI_OPCODE_BRK;\r
break;\r
+ case OPCODE_CAL:\r
+ fullinst->Instruction.Opcode = TGSI_OPCODE_CAL;\r
+ fullinst->InstructionExtLabel.Label = inst->BranchTarget + preamble_size;\r
+ break;\r
case OPCODE_CMP:\r
fullinst->Instruction.Opcode = TGSI_OPCODE_CMP;\r
break;\r
case OPCODE_RCP:\r
fullinst->Instruction.Opcode = TGSI_OPCODE_RCP;\r
break;\r
+ case OPCODE_RET:\r
+ fullinst->Instruction.Opcode = TGSI_OPCODE_RET;\r
+ break;\r
case OPCODE_RSQ:\r
fullinst->Instruction.Opcode = TGSI_OPCODE_RSQ;\r
tgsi_util_set_full_src_register_sign_mode(\r