r300/compiler: Add rc_print_program
authorNicolai Hähnle <nhaehnle@gmail.com>
Thu, 23 Jul 2009 20:09:11 +0000 (22:09 +0200)
committerNicolai Hähnle <nhaehnle@gmail.com>
Mon, 27 Jul 2009 18:32:07 +0000 (20:32 +0200)
Signed-off-by: Nicolai Hähnle <nhaehnle@gmail.com>
src/mesa/drivers/dri/r300/compiler/radeon_program.c
src/mesa/drivers/dri/r300/compiler/radeon_program.h
src/mesa/shader/prog_print.c
src/mesa/shader/prog_print.h

index d6cc62ff8bd422e9bd0348b9e4a60e8037f8b061..fea7f6460704b5b42e1cd7d505d4b391a7099d67 100644 (file)
@@ -194,3 +194,27 @@ void rc_mesa_to_rc_program(struct radeon_compiler * c, struct gl_program * progr
        c->Program.InputsRead = program->InputsRead;
 }
 
+
+/**
+ * Print program to stderr, default options.
+ */
+void rc_print_program(const struct rc_program *prog)
+{
+       GLuint indent = 0;
+       GLuint linenum = 1;
+       struct rc_instruction *inst;
+
+       fprintf(stderr, "# Radeon Compiler Program\n");
+
+       for(inst = prog->Instructions.Next; inst != &prog->Instructions; inst = inst->Next) {
+               fprintf(stderr, "%3d: ", linenum);
+
+               /* Massive hack: We rely on the fact that the printers do not actually
+                * use the gl_program argument (last argument) in debug mode */
+               indent = _mesa_fprint_instruction_opt(
+                               stderr, &inst->I,
+                               indent, PROG_PRINT_DEBUG, 0);
+
+               linenum++;
+       }
+}
index 0fcedfcd9dd35b7299c5ac8b352d4fd39d19b28d..9987a3d3bc980b4409d45aff9eb12f8374f4eeaa 100644 (file)
@@ -36,6 +36,7 @@
 
 struct radeon_compiler;
 struct rc_instruction;
+struct rc_program;
 
 enum {
        PROGRAM_BUILTIN = PROGRAM_FILE_MAX /**< not a real register, but a special swizzle constant */
@@ -134,5 +135,6 @@ struct rc_instruction *rc_alloc_instruction(struct radeon_compiler * c);
 struct rc_instruction *rc_insert_new_instruction(struct radeon_compiler * c, struct rc_instruction * after);
 
 void rc_mesa_to_rc_program(struct radeon_compiler * c, struct gl_program * program);
+void rc_print_program(const struct rc_program *prog);
 
 #endif
index de7fef1f861e1c133405fc100b673cb95e6a1fb3..cef0288a9c9432dc22ca09eadfd5aa4e0357c720 100644 (file)
@@ -541,7 +541,7 @@ _mesa_print_alu_instruction(const struct prog_instruction *inst,
 /**
  * Print a single vertex/fragment program instruction.
  */
-static GLint
+GLint
 _mesa_fprint_instruction_opt(FILE *f,
                             const struct prog_instruction *inst,
                             GLint indent,
index d55661cebb807a03e47215644553e223eb5582fc..3da3e767cd0ba96099375fb249ba1587b90eca1f 100644 (file)
@@ -56,6 +56,13 @@ _mesa_print_alu_instruction(const struct prog_instruction *inst,
 extern void
 _mesa_print_instruction(const struct prog_instruction *inst);
 
+extern GLint
+_mesa_fprint_instruction_opt(FILE *f,
+                            const struct prog_instruction *inst,
+                            GLint indent,
+                            gl_prog_print_mode mode,
+                            const struct gl_program *prog);
+
 extern GLint
 _mesa_print_instruction_opt(const struct prog_instruction *inst, GLint indent,
                             gl_prog_print_mode mode,