tgsi: when printing/dumping programs indent loops and conditionals
This commit is contained in:
@@ -33,12 +33,19 @@
|
|||||||
#include "tgsi_info.h"
|
#include "tgsi_info.h"
|
||||||
#include "tgsi_iterate.h"
|
#include "tgsi_iterate.h"
|
||||||
|
|
||||||
|
|
||||||
|
/** Number of spaces to indent for IF/LOOP/etc */
|
||||||
|
static const int indent_spaces = 3;
|
||||||
|
|
||||||
|
|
||||||
struct dump_ctx
|
struct dump_ctx
|
||||||
{
|
{
|
||||||
struct tgsi_iterate_context iter;
|
struct tgsi_iterate_context iter;
|
||||||
|
|
||||||
uint instno;
|
uint instno;
|
||||||
|
|
||||||
|
uint indentation;
|
||||||
|
|
||||||
void (*printf)(struct dump_ctx *ctx, const char *format, ...);
|
void (*printf)(struct dump_ctx *ctx, const char *format, ...);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -328,6 +335,14 @@ tgsi_dump_immediate(
|
|||||||
iter_immediate( &ctx.iter, (struct tgsi_full_immediate *)imm );
|
iter_immediate( &ctx.iter, (struct tgsi_full_immediate *)imm );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
indent(struct dump_ctx *ctx)
|
||||||
|
{
|
||||||
|
uint i;
|
||||||
|
for (i = 0; i < ctx->indentation; i++)
|
||||||
|
TXT(" ");
|
||||||
|
}
|
||||||
|
|
||||||
static boolean
|
static boolean
|
||||||
iter_instruction(
|
iter_instruction(
|
||||||
struct tgsi_iterate_context *iter,
|
struct tgsi_iterate_context *iter,
|
||||||
@@ -341,6 +356,15 @@ iter_instruction(
|
|||||||
|
|
||||||
INSTID( instno );
|
INSTID( instno );
|
||||||
TXT( ": " );
|
TXT( ": " );
|
||||||
|
|
||||||
|
/* update indentation */
|
||||||
|
if (inst->Instruction.Opcode == TGSI_OPCODE_ENDIF ||
|
||||||
|
inst->Instruction.Opcode == TGSI_OPCODE_ENDFOR ||
|
||||||
|
inst->Instruction.Opcode == TGSI_OPCODE_ENDLOOP) {
|
||||||
|
ctx->indentation -= indent_spaces;
|
||||||
|
}
|
||||||
|
indent(ctx);
|
||||||
|
|
||||||
TXT( tgsi_get_opcode_info( inst->Instruction.Opcode )->mnemonic );
|
TXT( tgsi_get_opcode_info( inst->Instruction.Opcode )->mnemonic );
|
||||||
|
|
||||||
switch (inst->Instruction.Saturate) {
|
switch (inst->Instruction.Saturate) {
|
||||||
@@ -481,6 +505,14 @@ iter_instruction(
|
|||||||
break;
|
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();
|
EOL();
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -495,6 +527,7 @@ tgsi_dump_instruction(
|
|||||||
|
|
||||||
ctx.instno = instno;
|
ctx.instno = instno;
|
||||||
ctx.printf = dump_ctx_printf;
|
ctx.printf = dump_ctx_printf;
|
||||||
|
ctx.indentation = 0;
|
||||||
|
|
||||||
iter_instruction( &ctx.iter, (struct tgsi_full_instruction *)inst );
|
iter_instruction( &ctx.iter, (struct tgsi_full_instruction *)inst );
|
||||||
}
|
}
|
||||||
@@ -527,6 +560,7 @@ tgsi_dump(
|
|||||||
|
|
||||||
ctx.instno = 0;
|
ctx.instno = 0;
|
||||||
ctx.printf = dump_ctx_printf;
|
ctx.printf = dump_ctx_printf;
|
||||||
|
ctx.indentation = 0;
|
||||||
|
|
||||||
tgsi_iterate_shader( tokens, &ctx.iter );
|
tgsi_iterate_shader( tokens, &ctx.iter );
|
||||||
}
|
}
|
||||||
@@ -579,6 +613,7 @@ tgsi_dump_str(
|
|||||||
|
|
||||||
ctx.base.instno = 0;
|
ctx.base.instno = 0;
|
||||||
ctx.base.printf = &str_dump_ctx_printf;
|
ctx.base.printf = &str_dump_ctx_printf;
|
||||||
|
ctx.base.indentation = 0;
|
||||||
|
|
||||||
ctx.str = str;
|
ctx.str = str;
|
||||||
ctx.str[0] = 0;
|
ctx.str[0] = 0;
|
||||||
|
Reference in New Issue
Block a user