Merge branch 'mesa_7_6_branch'
[mesa.git] / src / mesa / state_tracker / st_program.c
index 5f9d2a6dad9bff112b5a6859b2ced5ce3268d562..a9be80ce8f31be68bae8b197ad40e3397d5c4439 100644 (file)
@@ -42,6 +42,7 @@
 #include "draw/draw_context.h"
 #include "tgsi/tgsi_dump.h"
 
+#include "st_debug.h"
 #include "st_context.h"
 #include "st_atom.h"
 #include "st_program.h"
@@ -49,9 +50,6 @@
 #include "cso_cache/cso_context.h"
 
 
-#define TGSI_DEBUG 0
-
-
 /**
  * Translate a Mesa vertex shader into a TGSI shader.
  * \param outputMapping  to map vertex program output registers (VERT_RESULT_x)
@@ -317,7 +315,7 @@ st_translate_vertex_program(struct st_context *st,
 
    /* free old shader state, if any */
    if (stvp->state.tokens) {
-      _mesa_free((void *) stvp->state.tokens);
+      st_free_tokens(stvp->state.tokens);
       stvp->state.tokens = NULL;
    }
    if (stvp->driver_shader) {
@@ -346,11 +344,15 @@ st_translate_vertex_program(struct st_context *st,
    stvp->num_inputs = vs_num_inputs;
    stvp->driver_shader = pipe->create_vs_state(pipe, &stvp->state);
 
-   if (0)
+   if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) {
       _mesa_print_program(&stvp->Base.Base);
+      debug_printf("\n");
+   }
 
-   if (TGSI_DEBUG)
+   if (ST_DEBUG & DEBUG_TGSI) {
       tgsi_dump( stvp->state.tokens, 0 );
+      debug_printf("\n");
+   }
 }
 
 
@@ -526,11 +528,15 @@ st_translate_fragment_program(struct st_context *st,
 
    stfp->driver_shader = pipe->create_fs_state(pipe, &stfp->state);
 
-   if (0)
+   if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) {
       _mesa_print_program(&stfp->Base.Base);
+      debug_printf("\n");
+   }
 
-   if (TGSI_DEBUG)
+   if (ST_DEBUG & DEBUG_TGSI) {
       tgsi_dump( stfp->state.tokens, 0/*TGSI_DUMP_VERBOSE*/ );
+      debug_printf("\n");
+   }
 }