Handle labels for IF/ELSE correctly
authormichal <michal@michal-laptop.(none)>
Tue, 7 Aug 2007 11:50:12 +0000 (12:50 +0100)
committermichal <michal@michal-laptop.(none)>
Tue, 7 Aug 2007 11:50:12 +0000 (12:50 +0100)
src/mesa/pipe/tgsi/core/tgsi_dump.c
src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c

index 68b81b7ffe96c7cac381ee2a18bd1c51ef23e977..641339c8960b1bd926091f69fd03ca4569b37bea 100644 (file)
@@ -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:
index 15f4d1e197d89151461d5710cb3fd5bc7046ef03..654ec9ac68ad097ea46ca00b42cb22631401c006 100644 (file)
@@ -158,6 +158,7 @@ compile_instruction(
    const struct prog_instruction *inst,\r
    struct tgsi_full_instruction *fullinst,\r
    GLuint inputs_read,\r
+   GLuint preamble_size,\r
    GLuint processor )\r
 {\r
    GLuint i;\r
@@ -293,7 +294,7 @@ compile_instruction(
       break;\r
    case OPCODE_ELSE:\r
       fullinst->Instruction.Opcode = TGSI_OPCODE_ELSE;\r
-      fullinst->InstructionExtLabel.Label = inst->BranchTarget;\r
+      fullinst->InstructionExtLabel.Label = inst->BranchTarget + preamble_size;\r
       break;\r
    case OPCODE_ENDIF:\r
       fullinst->Instruction.Opcode = TGSI_OPCODE_ENDIF;\r
@@ -318,7 +319,7 @@ compile_instruction(
       break;\r
    case OPCODE_IF:\r
       fullinst->Instruction.Opcode = TGSI_OPCODE_IF;\r
-      fullinst->InstructionExtLabel.Label = inst->BranchTarget;\r
+      fullinst->InstructionExtLabel.Label = inst->BranchTarget + preamble_size;\r
       break;\r
    case OPCODE_INT:\r
       fullinst->Instruction.Opcode = TGSI_OPCODE_INT;\r
@@ -473,6 +474,7 @@ tgsi_mesa_compile_fp_program(
    struct tgsi_full_dst_register *fulldst;\r
    struct tgsi_full_src_register *fullsrc;\r
    GLuint inputs_read;\r
+   GLuint preamble_size = 0;\r
 \r
    *(struct tgsi_version *) &tokens[0] = tgsi_build_version();\r
 \r
@@ -559,12 +561,14 @@ tgsi_mesa_compile_fp_program(
       &tokens[ti],\r
       header,\r
       maxTokens - ti );\r
+   preamble_size++;\r
 \r
    for( i = 0; i < program->Base.NumInstructions; i++ ) {\r
       if( compile_instruction(\r
             &program->Base.Instructions[i],\r
             &fullinst,\r
             inputs_read,\r
+            preamble_size,\r
             TGSI_PROCESSOR_FRAGMENT ) ) {\r
          assert( i == program->Base.NumInstructions - 1 );\r
          tgsi_dump(\r
@@ -610,6 +614,7 @@ tgsi_mesa_compile_vp_program(
             &program->Base.Instructions[ii],\r
             &fullinst,\r
             inputs_read,\r
+            0,\r
             TGSI_PROCESSOR_VERTEX ) ) {\r
          assert( ii == program->Base.NumInstructions - 1 );\r
          tgsi_dump( tokens, TGSI_DUMP_NO_IGNORED | TGSI_DUMP_NO_DEFAULT );\r