summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichal <michal@michal-laptop.(none)>2007-08-07 12:50:12 +0100
committermichal <michal@michal-laptop.(none)>2007-08-07 12:50:12 +0100
commit281dad225947b4f00bfc5e785d92d2a7c2f06afe (patch)
treee396ae9e9785e8c9a45bd1459f2c560b2c935785
parentf141399031981d6af19a32025ae7c1b947196480 (diff)
Handle labels for IF/ELSE correctly
-rw-r--r--src/mesa/pipe/tgsi/core/tgsi_dump.c18
-rw-r--r--src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c9
2 files changed, 23 insertions, 4 deletions
diff --git a/src/mesa/pipe/tgsi/core/tgsi_dump.c b/src/mesa/pipe/tgsi/core/tgsi_dump.c
index 68b81b7ffe..641339c896 100644
--- a/src/mesa/pipe/tgsi/core/tgsi_dump.c
+++ b/src/mesa/pipe/tgsi/core/tgsi_dump.c
@@ -686,12 +686,15 @@ dump_immediate_verbose(
static void
dump_instruction_short(
struct text_dump *dump,
- struct tgsi_full_instruction *inst )
+ struct tgsi_full_instruction *inst,
+ GLuint instno )
{
GLuint i;
GLboolean first_reg = GL_TRUE;
CHR( '\n' );
+ UID( instno );
+ CHR( ':' );
ENM( inst->Instruction.Opcode, TGSI_OPCODES_SHORT );
switch( inst->Instruction.Saturate ) {
@@ -781,6 +784,14 @@ dump_instruction_short(
first_reg = GL_FALSE;
}
+
+ switch( inst->Instruction.Opcode ) {
+ case TGSI_OPCODE_IF:
+ case TGSI_OPCODE_ELSE:
+ TXT( " : " );
+ UID( inst->InstructionExtLabel.Label );
+ break;
+ }
}
static void
@@ -1140,6 +1151,7 @@ tgsi_dump(
GLuint verbose = flags & TGSI_DUMP_VERBOSE;
GLuint ignored = !(flags & TGSI_DUMP_NO_IGNORED);
GLuint deflt = !(flags & TGSI_DUMP_NO_DEFAULT);
+ GLuint instno = 0;
{
#if 0
@@ -1206,7 +1218,9 @@ tgsi_dump(
case TGSI_TOKEN_TYPE_INSTRUCTION:
dump_instruction_short(
dump,
- &parse.FullToken.FullInstruction );
+ &parse.FullToken.FullInstruction,
+ instno );
+ instno++;
break;
default:
diff --git a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c
index 15f4d1e197..654ec9ac68 100644
--- a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c
+++ b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c
@@ -158,6 +158,7 @@ compile_instruction(
const struct prog_instruction *inst,
struct tgsi_full_instruction *fullinst,
GLuint inputs_read,
+ GLuint preamble_size,
GLuint processor )
{
GLuint i;
@@ -293,7 +294,7 @@ compile_instruction(
break;
case OPCODE_ELSE:
fullinst->Instruction.Opcode = TGSI_OPCODE_ELSE;
- fullinst->InstructionExtLabel.Label = inst->BranchTarget;
+ fullinst->InstructionExtLabel.Label = inst->BranchTarget + preamble_size;
break;
case OPCODE_ENDIF:
fullinst->Instruction.Opcode = TGSI_OPCODE_ENDIF;
@@ -318,7 +319,7 @@ compile_instruction(
break;
case OPCODE_IF:
fullinst->Instruction.Opcode = TGSI_OPCODE_IF;
- fullinst->InstructionExtLabel.Label = inst->BranchTarget;
+ fullinst->InstructionExtLabel.Label = inst->BranchTarget + preamble_size;
break;
case OPCODE_INT:
fullinst->Instruction.Opcode = TGSI_OPCODE_INT;
@@ -473,6 +474,7 @@ tgsi_mesa_compile_fp_program(
struct tgsi_full_dst_register *fulldst;
struct tgsi_full_src_register *fullsrc;
GLuint inputs_read;
+ GLuint preamble_size = 0;
*(struct tgsi_version *) &tokens[0] = tgsi_build_version();
@@ -559,12 +561,14 @@ tgsi_mesa_compile_fp_program(
&tokens[ti],
header,
maxTokens - ti );
+ preamble_size++;
for( i = 0; i < program->Base.NumInstructions; i++ ) {
if( compile_instruction(
&program->Base.Instructions[i],
&fullinst,
inputs_read,
+ preamble_size,
TGSI_PROCESSOR_FRAGMENT ) ) {
assert( i == program->Base.NumInstructions - 1 );
tgsi_dump(
@@ -610,6 +614,7 @@ tgsi_mesa_compile_vp_program(
&program->Base.Instructions[ii],
&fullinst,
inputs_read,
+ 0,
TGSI_PROCESSOR_VERTEX ) ) {
assert( ii == program->Base.NumInstructions - 1 );
tgsi_dump( tokens, TGSI_DUMP_NO_IGNORED | TGSI_DUMP_NO_DEFAULT );