r300: Add radeonCompilerDump for debugging
authorNicolai Haehnle <nhaehnle@gmail.com>
Sat, 14 Jun 2008 01:34:09 +0000 (03:34 +0200)
committerNicolai Haehnle <nhaehnle@gmail.com>
Sat, 14 Jun 2008 02:15:20 +0000 (04:15 +0200)
src/mesa/drivers/dri/r300/r300_fragprog.c
src/mesa/drivers/dri/r300/radeon_program.c
src/mesa/drivers/dri/r300/radeon_program.h

index 4c6289298e75149b403b3560187a4ce93d90e765..814ccd3eacc709791d5353fd98495aae55b4ec7e 100644 (file)
@@ -301,6 +301,11 @@ void r300TranslateFragmentShader(r300ContextPtr r300,
                        &compiler.compiler.Clauses[0],
                        1, transformations);
 
+               if (RADEON_DEBUG & DEBUG_PIXEL) {
+                       _mesa_printf("Compiler state after transformations:\n");
+                       radeonCompilerDump(&compiler.compiler);
+               }
+
                if (!r300FragmentProgramEmit(&compiler))
                        fp->error = GL_TRUE;
 
index 41cedbe61dc5cfe563b0e94c04122cd20ce44caf..c8f40e818937bfd005afcee1e33caf5072e60d86 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "radeon_program.h"
 
+#include "shader/prog_print.h"
 
 /**
  * Initialize a compiler structure with a single mixed clause
@@ -79,6 +80,37 @@ int radeonCompilerAllocateTemporary(struct radeon_compiler *compiler)
 }
 
 
+static const char* clausename(int type)
+{
+       switch(type) {
+       case CLAUSE_MIXED: return "CLAUSE_MIXED";
+       case CLAUSE_ALU: return "CLAUSE_ALU";
+       case CLAUSE_TEX: return "CLAUSE_TEX";
+       default: return "CLAUSE_UNKNOWN";
+       }
+}
+
+
+/**
+ * Dump the current compiler state to the console for debugging.
+ */
+void radeonCompilerDump(struct radeon_compiler *compiler)
+{
+       int i;
+       for(i = 0; i < compiler->NumClauses; ++i) {
+               struct radeon_clause *clause = &compiler->Clauses[i];
+               int j;
+
+               _mesa_printf("%2i: %s\n", i+1, clausename(clause->Type));
+
+               for(j = 0; j < clause->NumInstructions; ++j) {
+                       _mesa_printf("%4i: ", j+1);
+                       _mesa_print_instruction(&clause->Instructions[j]);
+               }
+       }
+}
+
+
 /**
  * \p position index of the new clause; later clauses are moved
  * \p type of the new clause; one of CLAUSE_XXX
index 3cde4d4f6fc7f9b21f37844802dfd3d029242b59..25e70505b16162042fdd9cbc9f1beb6036c49cef 100644 (file)
@@ -104,6 +104,7 @@ void radeonCompilerInit(
        struct gl_program *source);
 void radeonCompilerCleanup(struct radeon_compiler *compiler);
 int radeonCompilerAllocateTemporary(struct radeon_compiler *compiler);
+void radeonCompilerDump(struct radeon_compiler *compiler);
 
 struct radeon_clause *radeonCompilerInsertClause(
        struct radeon_compiler *compiler,