summaryrefslogtreecommitdiff
path: root/src/mesa/shader
diff options
context:
space:
mode:
authorBrian <brian@yutani.localnet.net>2007-02-05 14:58:15 -0700
committerBrian <brian@yutani.localnet.net>2007-02-05 14:58:15 -0700
commit5db088d70fbd14620c2fc7840096a05993f8e2b9 (patch)
tree3fecee5881e65fcf30b0af92d48f9263aaaac102 /src/mesa/shader
parent01001d80e26143ac768115ccb2266db2b24d4fa0 (diff)
indentation for program instructions (if/else, loops)
Diffstat (limited to 'src/mesa/shader')
-rw-r--r--src/mesa/shader/prog_print.c56
-rw-r--r--src/mesa/shader/prog_print.h6
2 files changed, 49 insertions, 13 deletions
diff --git a/src/mesa/shader/prog_print.c b/src/mesa/shader/prog_print.c
index 63ff84e345..9474fe995f 100644
--- a/src/mesa/shader/prog_print.c
+++ b/src/mesa/shader/prog_print.c
@@ -2,7 +2,7 @@
* Mesa 3-D graphics library
* Version: 6.5.3
*
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -238,9 +238,22 @@ _mesa_print_alu_instruction(const struct prog_instruction *inst,
/**
* Print a single vertex/fragment program instruction.
*/
-void
-_mesa_print_instruction(const struct prog_instruction *inst)
+GLint
+_mesa_print_instruction(const struct prog_instruction *inst, GLint indent)
{
+ GLuint i;
+
+ if (inst->Opcode == OPCODE_ELSE ||
+ inst->Opcode == OPCODE_ENDIF ||
+ inst->Opcode == OPCODE_ENDLOOP ||
+ inst->Opcode == OPCODE_ENDSUB) {
+ indent -= 3;
+ }
+ assert(indent >= 0);
+ for (i = 0; i < indent; i++) {
+ _mesa_printf(" ");
+ }
+
switch (inst->Opcode) {
case OPCODE_PRINT:
_mesa_printf("PRINT '%s'", inst->Data);
@@ -306,16 +319,38 @@ _mesa_print_instruction(const struct prog_instruction *inst)
print_comment(inst);
break;
case OPCODE_IF:
- _mesa_printf(" IF (%s%s)",
+ _mesa_printf("IF (%s%s)",
condcode_string(inst->DstReg.CondMask),
swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE));
print_comment(inst);
- break;
+ return indent + 3;
case OPCODE_ELSE:
- _mesa_printf(" ELSE;\n");
- break;
+ _mesa_printf("ELSE;\n");
+ return indent + 3;
case OPCODE_ENDIF:
- _mesa_printf(" ENDIF;\n");
+ _mesa_printf("ENDIF;\n");
+ break;
+ case OPCODE_BGNLOOP:
+ _mesa_printf("LOOP;\n");
+ return indent + 3;
+ case OPCODE_ENDLOOP:
+ _mesa_printf("ENDLOOP;\n");
+ break;
+ case OPCODE_BRK:
+ /* XXX just like BRA */
+ _mesa_printf("BRK %u (%s%s)",
+ inst->BranchTarget,
+ condcode_string(inst->DstReg.CondMask),
+ swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE));
+ print_comment(inst);
+ break;
+ case OPCODE_BGNSUB:
+ _mesa_printf("SUB;\n");
+ print_comment(inst);
+ return indent + 3;
+ case OPCODE_ENDSUB:
+ _mesa_printf("ENDSUB;\n");
+ print_comment(inst);
break;
case OPCODE_END:
_mesa_printf("END");
@@ -333,6 +368,7 @@ _mesa_print_instruction(const struct prog_instruction *inst)
_mesa_num_inst_src_regs(inst->Opcode));
break;
}
+ return indent;
}
@@ -343,10 +379,10 @@ _mesa_print_instruction(const struct prog_instruction *inst)
void
_mesa_print_program(const struct gl_program *prog)
{
- GLuint i;
+ GLuint i, indent = 0;
for (i = 0; i < prog->NumInstructions; i++) {
_mesa_printf("%3d: ", i);
- _mesa_print_instruction(prog->Instructions + i);
+ indent = _mesa_print_instruction(prog->Instructions + i, indent);
}
}
diff --git a/src/mesa/shader/prog_print.h b/src/mesa/shader/prog_print.h
index 8bc2c69c6f..19aaa53800 100644
--- a/src/mesa/shader/prog_print.h
+++ b/src/mesa/shader/prog_print.h
@@ -2,7 +2,7 @@
* Mesa 3-D graphics library
* Version: 6.5.3
*
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -27,8 +27,8 @@
#define PROG_PRINT_H
-extern void
-_mesa_print_instruction(const struct prog_instruction *inst);
+extern GLint
+_mesa_print_instruction(const struct prog_instruction *inst, GLint indent);
extern void
_mesa_print_alu_instruction(const struct prog_instruction *inst,