From: Brian Date: Tue, 2 Oct 2007 19:49:38 +0000 (-0600) Subject: Added TGSI_OPCODE_END X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5e49ec339df1d23b1f1790c49c9f102098f42c0d;p=mesa.git 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. --- diff --git a/src/mesa/pipe/i915simple/i915_fpc_translate.c b/src/mesa/pipe/i915simple/i915_fpc_translate.c index 24f21f6633a..24bb1d3e2a9 100644 --- a/src/mesa/pipe/i915simple/i915_fpc_translate.c +++ b/src/mesa/pipe/i915simple/i915_fpc_translate.c @@ -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]); diff --git a/src/mesa/pipe/tgsi/exec/tgsi_dump.c b/src/mesa/pipe/tgsi/exec/tgsi_dump.c index 4cf3397162c..0b273cd6e56 100755 --- a/src/mesa/pipe/tgsi/exec/tgsi_dump.c +++ b/src/mesa/pipe/tgsi/exec/tgsi_dump.c @@ -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[] = diff --git a/src/mesa/pipe/tgsi/exec/tgsi_exec.c b/src/mesa/pipe/tgsi/exec/tgsi_exec.c index ca397bde6a4..27154d68839 100644 --- a/src/mesa/pipe/tgsi/exec/tgsi_exec.c +++ b/src/mesa/pipe/tgsi/exec/tgsi_exec.c @@ -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 ); } } diff --git a/src/mesa/pipe/tgsi/exec/tgsi_token.h b/src/mesa/pipe/tgsi/exec/tgsi_token.h index 1d99a50dde7..d2fa8138159 100644 --- a/src/mesa/pipe/tgsi/exec/tgsi_token.h +++ b/src/mesa/pipe/tgsi/exec/tgsi_token.h @@ -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] */ diff --git a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c index 5daf50ddef6..5c987436bed 100644 --- a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c +++ b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c @@ -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,