Added TGSI_OPCODE_END

Halt program execution when we get to END instruction.  The GLSL compiler
puts subroutines after the end instruction so we have to stop before then.
This commit is contained in:
Brian 2007-10-02 13:49:38 -06:00
parent 4726489248
commit 5e49ec339d
5 changed files with 26 additions and 28 deletions

View file

@ -486,6 +486,10 @@ i915_translate_instruction(struct i915_fp_compile *p,
swizzle(src1, ONE, Y, ONE, W), 0);
break;
case TGSI_OPCODE_END:
/* no-op */
break;
case TGSI_OPCODE_EX2:
src0 = src_vector(p, &inst->FullSrcRegisters[0]);

View file

@ -363,7 +363,8 @@ static const char *TGSI_OPCODES[] =
"OPCODE_CALLNZ",
"OPCODE_IFC",
"OPCODE_BREAKC",
"OPCODE_TXP"
"OPCODE_TXP",
"OPCODE_END"
};
static const char *TGSI_OPCODES_SHORT[] =
@ -500,6 +501,8 @@ static const char *TGSI_OPCODES_SHORT[] =
"CALLNZ",
"IFC",
"BREAKC",
"TXP",
"END"
};
static const char *TGSI_SATS[] =

View file

@ -2029,6 +2029,11 @@ exec_instruction(
}
break;
case TGSI_OPCODE_END:
/* halt execution */
*pc = -1;
break;
case TGSI_OPCODE_ENDIF:
/* pop CondMask */
assert(mach->CondStackTop > 0);
@ -2233,15 +2238,14 @@ tgsi_exec_machine_run( struct tgsi_exec_machine *mach )
{
uint i;
int pc;
int pc = 0;
for (i = 0; i < mach->NumDeclarations; i++) {
exec_declaration( mach, mach->Declarations+i );
}
pc = 0;
while (pc != 99 && pc < mach->NumInstructions) {
while (pc != -1) {
assert(pc < mach->NumInstructions);
exec_instruction( mach, mach->Instructions + pc, &pc );
}
}

View file

@ -1100,7 +1100,9 @@ struct tgsi_immediate_float32
/* TGSI_OPCODE_MOVA */
/* TGSI_OPCODE_LOGP */
#define TGSI_OPCODE_LAST 133
#define TGSI_OPCODE_END 133 /* aka HALT */
#define TGSI_OPCODE_LAST 134
#define TGSI_SAT_NONE 0 /* do not saturate */
#define TGSI_SAT_ZERO_ONE 1 /* clamp to [0,1] */

View file

@ -154,7 +154,7 @@ convert_writemask(
return writemask;
}
static GLboolean
static void
compile_instruction(
const struct prog_instruction *inst,
struct tgsi_full_instruction *fullinst,
@ -460,12 +460,11 @@ compile_instruction(
fulldst->DstRegister.WriteMask &= TGSI_WRITEMASK_XYZ;
break;
case OPCODE_END:
return GL_TRUE;
fullinst->Instruction.Opcode = TGSI_OPCODE_END;
break;
default:
assert( 0 );
}
return GL_FALSE;
}
static struct tgsi_full_declaration
@ -658,20 +657,13 @@ tgsi_mesa_compile_fp_program(
#endif
for( i = 0; i < program->Base.NumInstructions; i++ ) {
if( compile_instruction(
compile_instruction(
&program->Base.Instructions[i],
&fullinst,
inputMapping,
outputMapping,
preamble_size,
TGSI_PROCESSOR_FRAGMENT ) ) {
assert( i == program->Base.NumInstructions - 1 );
if( TGSI_DEBUG ) {
tgsi_dump( tokens, 0 );
}
break;
}
TGSI_PROCESSOR_FRAGMENT );
ti += tgsi_build_full_instruction(
&fullinst,
@ -741,20 +733,13 @@ tgsi_mesa_compile_vp_program(
for( i = 0; i < program->Base.NumInstructions; i++ ) {
if( compile_instruction(
compile_instruction(
&program->Base.Instructions[i],
&fullinst,
inputMapping,
outputMapping,
0,
TGSI_PROCESSOR_VERTEX ) ) {
assert( i == program->Base.NumInstructions - 1 );
if( TGSI_DEBUG ) {
tgsi_dump( tokens, 0 );
}
break;
}
TGSI_PROCESSOR_VERTEX );
ti += tgsi_build_full_instruction(
&fullinst,