gallium: remove the swizzling parts of ExtSwizzle
[mesa.git] / src / gallium / auxiliary / tgsi / tgsi_dump.c
index f36b1114a9559229bf4e9da8bbaaa7b213586ddf..3a584a10a10f5e6c2dd905cce8c2ee008f41ea47 100644 (file)
 #include "tgsi_info.h"
 #include "tgsi_iterate.h"
 
+
+/** Number of spaces to indent for IF/LOOP/etc */
+static const int indent_spaces = 3;
+
+
 struct dump_ctx
 {
    struct tgsi_iterate_context iter;
 
    uint instno;
+   int indent;
    
+   uint indentation;
+
    void (*printf)(struct dump_ctx *ctx, const char *format, ...);
 };
 
@@ -140,15 +148,6 @@ static const char *texture_names[] =
    "SHADOWRECT"
 };
 
-static const char *extswizzle_names[] =
-{
-   "x",
-   "y",
-   "z",
-   "w",
-   "0",
-   "1"
-};
 
 static const char *modulate_names[TGSI_MODULATE_COUNT] =
 {
@@ -335,13 +334,19 @@ iter_instruction(
 {
    struct dump_ctx *ctx = (struct dump_ctx *) iter;
    uint instno = ctx->instno++;
-   
+   const struct tgsi_opcode_info *info = tgsi_get_opcode_info( inst->Instruction.Opcode );
    uint i;
    boolean first_reg = TRUE;
 
    INSTID( instno );
    TXT( ": " );
-   TXT( tgsi_get_opcode_info( inst->Instruction.Opcode )->mnemonic );
+   
+   ctx->indent -= info->pre_dedent;
+   for(i = 0; (int)i < ctx->indent; ++i)
+      TXT( "  " );
+   ctx->indent += info->post_indent;
+   
+   TXT( info->mnemonic );
 
    switch (inst->Instruction.Saturate) {
    case TGSI_SAT_NONE:
@@ -432,24 +437,6 @@ iter_instruction(
          ENM( src->SrcRegister.SwizzleZ, swizzle_names );
          ENM( src->SrcRegister.SwizzleW, swizzle_names );
       }
-      if (src->SrcRegisterExtSwz.ExtSwizzleX != TGSI_EXTSWIZZLE_X ||
-          src->SrcRegisterExtSwz.ExtSwizzleY != TGSI_EXTSWIZZLE_Y ||
-          src->SrcRegisterExtSwz.ExtSwizzleZ != TGSI_EXTSWIZZLE_Z ||
-          src->SrcRegisterExtSwz.ExtSwizzleW != TGSI_EXTSWIZZLE_W) {
-         CHR( '.' );
-         if (src->SrcRegisterExtSwz.NegateX)
-            TXT("-");
-         ENM( src->SrcRegisterExtSwz.ExtSwizzleX, extswizzle_names );
-         if (src->SrcRegisterExtSwz.NegateY)
-            TXT("-");
-         ENM( src->SrcRegisterExtSwz.ExtSwizzleY, extswizzle_names );
-         if (src->SrcRegisterExtSwz.NegateZ)
-            TXT("-");
-         ENM( src->SrcRegisterExtSwz.ExtSwizzleZ, extswizzle_names );
-         if (src->SrcRegisterExtSwz.NegateW)
-            TXT("-");
-         ENM( src->SrcRegisterExtSwz.ExtSwizzleW, extswizzle_names );
-      }
 
       if (src->SrcRegisterExtMod.Complement)
          CHR( ')' );
@@ -481,6 +468,14 @@ iter_instruction(
       break;
    }
 
+   /* update indentation */
+   if (inst->Instruction.Opcode == TGSI_OPCODE_IF ||
+       inst->Instruction.Opcode == TGSI_OPCODE_ELSE ||
+       inst->Instruction.Opcode == TGSI_OPCODE_BGNFOR ||
+       inst->Instruction.Opcode == TGSI_OPCODE_BGNLOOP) {
+      ctx->indentation += indent_spaces;
+   }
+
    EOL();
 
    return TRUE;
@@ -494,7 +489,9 @@ tgsi_dump_instruction(
    struct dump_ctx ctx;
 
    ctx.instno = instno;
+   ctx.indent = 0;
    ctx.printf = dump_ctx_printf;
+   ctx.indentation = 0;
 
    iter_instruction( &ctx.iter, (struct tgsi_full_instruction *)inst );
 }
@@ -526,7 +523,9 @@ tgsi_dump(
    ctx.iter.epilog = NULL;
 
    ctx.instno = 0;
+   ctx.indent = 0;
    ctx.printf = dump_ctx_printf;
+   ctx.indentation = 0;
 
    tgsi_iterate_shader( tokens, &ctx.iter );
 }
@@ -578,7 +577,9 @@ tgsi_dump_str(
    ctx.base.iter.epilog = NULL;
 
    ctx.base.instno = 0;
+   ctx.base.indent = 0;
    ctx.base.printf = &str_dump_ctx_printf;
+   ctx.base.indentation = 0;
 
    ctx.str = str;
    ctx.str[0] = 0;