summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/nv50
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/nv50')
-rw-r--r--src/gallium/drivers/nv50/nv50_context.h11
-rw-r--r--src/gallium/drivers/nv50/nv50_debug.h25
-rw-r--r--src/gallium/drivers/nv50/nv50_pc.c20
-rw-r--r--src/gallium/drivers/nv50/nv50_pc.h8
-rw-r--r--src/gallium/drivers/nv50/nv50_pc_optimize.c13
-rw-r--r--src/gallium/drivers/nv50/nv50_pc_regalloc.c14
-rw-r--r--src/gallium/drivers/nv50/nv50_program.c4
-rw-r--r--src/gallium/drivers/nv50/nv50_tgsi_to_nc.c6
8 files changed, 52 insertions, 49 deletions
diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h
index f480f043096..3f031994f0a 100644
--- a/src/gallium/drivers/nv50/nv50_context.h
+++ b/src/gallium/drivers/nv50/nv50_context.h
@@ -1,7 +1,6 @@
#ifndef __NV50_CONTEXT_H__
#define __NV50_CONTEXT_H__
-#include <stdio.h>
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
@@ -13,6 +12,7 @@
#include "draw/draw_vertex.h"
+#include "nv50_debug.h"
#include "nv50_winsys.h"
#include "nv50_stateobj.h"
#include "nv50_screen.h"
@@ -26,15 +26,6 @@
#include "nv50_3d.xml.h"
#include "nv50_2d.xml.h"
-#define NOUVEAU_ERR(fmt, args...) \
- fprintf(stderr, "%s:%d - "fmt, __FUNCTION__, __LINE__, ##args);
-
-#ifdef NOUVEAU_DEBUG
-# define NOUVEAU_DBG(args...) printf(args);
-#else
-# define NOUVEAU_DBG(args...)
-#endif
-
#define NV50_NEW_BLEND (1 << 0)
#define NV50_NEW_RASTERIZER (1 << 1)
#define NV50_NEW_ZSA (1 << 2)
diff --git a/src/gallium/drivers/nv50/nv50_debug.h b/src/gallium/drivers/nv50/nv50_debug.h
new file mode 100644
index 00000000000..f3dee621519
--- /dev/null
+++ b/src/gallium/drivers/nv50/nv50_debug.h
@@ -0,0 +1,25 @@
+
+#ifndef __NV50_DEBUG_H__
+#define __NV50_DEBUG_H__
+
+#include <stdio.h>
+
+#include "util/u_debug.h"
+
+#define NV50_DEBUG_MISC 0x0001
+#define NV50_DEBUG_SHADER 0x0100
+#define NV50_DEBUG_PROG_IR 0x0200
+#define NV50_DEBUG_PROG_RA 0x0400
+#define NV50_DEBUG_PROG_CFLOW 0x0800
+#define NV50_DEBUG_PROG_ALL 0x1f00
+
+#define NV50_DEBUG 0
+
+#define NOUVEAU_ERR(fmt, args...) \
+ fprintf(stderr, "%s:%d - "fmt, __FUNCTION__, __LINE__, ##args)
+
+#define NV50_DBGMSG(ch, args...) \
+ if ((NV50_DEBUG) & (NV50_DEBUG_##ch)) \
+ debug_printf(args)
+
+#endif /* __NV50_DEBUG_H__ */
diff --git a/src/gallium/drivers/nv50/nv50_pc.c b/src/gallium/drivers/nv50/nv50_pc.c
index 4fe13a75b29..7900bf811df 100644
--- a/src/gallium/drivers/nv50/nv50_pc.c
+++ b/src/gallium/drivers/nv50/nv50_pc.c
@@ -20,8 +20,6 @@
* SOFTWARE.
*/
-/* #define NV50PC_DEBUG */
-
#include "nv50_pc.h"
#include "nv50_program.h"
@@ -368,7 +366,7 @@ nv_print_program(struct nv_pc *pc)
nv_print_function(pc->root[i]);
}
-#ifdef NV50PC_DEBUG
+#if NV50_DEBUG & NV50_DEBUG_PROG_CFLOW
static void
nv_do_print_cfgraph(struct nv_pc *pc, FILE *f, struct nv_basic_block *b)
{
@@ -426,7 +424,7 @@ nv_print_cfgraph(struct nv_pc *pc, const char *filepath, int subr)
fclose(f);
}
-#endif
+#endif /* NV50_DEBUG_PROG_CFLOW */
static INLINE void
nvcg_show_bincode(struct nv_pc *pc)
@@ -447,7 +445,7 @@ nv50_emit_program(struct nv_pc *pc)
uint32_t *code = pc->emit;
int n;
- NV50_DBGMSG("emitting program: size = %u\n", pc->bin_size);
+ NV50_DBGMSG(SHADER, "emitting program: size = %u\n", pc->bin_size);
for (n = 0; n < pc->num_blocks; ++n) {
struct nv_instruction *i;
@@ -473,7 +471,7 @@ nv50_emit_program(struct nv_pc *pc)
pc->emit = code;
code[pc->bin_size / 4 - 1] |= 1;
-#ifdef NV50PC_DEBUG
+#if NV50_DEBUG & NV50_DEBUG_SHADER
nvcg_show_bincode(pc);
#endif
@@ -501,7 +499,7 @@ nv50_generate_code(struct nv50_translation_info *ti)
ret = nv50_tgsi_to_nc(pc, ti);
if (ret)
goto out;
-#ifdef NV50PC_DEBUG
+#if NV50_DEBUG & NV50_DEBUG_PROG_IR
nv_print_program(pc);
#endif
@@ -511,7 +509,7 @@ nv50_generate_code(struct nv50_translation_info *ti)
ret = nv_pc_exec_pass0(pc);
if (ret)
goto out;
-#ifdef NV50PC_DEBUG
+#if NV50_DEBUG & NV50_DEBUG_PROG_IR
nv_print_program(pc);
#endif
@@ -519,7 +517,7 @@ nv50_generate_code(struct nv50_translation_info *ti)
ret = nv_pc_exec_pass1(pc);
if (ret)
goto out;
-#ifdef NV50PC_DEBUG
+#if NV50_DEBUG & NV50_DEBUG_PROG_CFLOW
nv_print_program(pc);
nv_print_cfgraph(pc, "nv50_shader_cfgraph.dot", 0);
#endif
@@ -553,7 +551,7 @@ nv50_generate_code(struct nv50_translation_info *ti)
ti->p->uses_lmem = ti->store_to_memory;
- NV50_DBGMSG("SHADER TRANSLATION - %s\n", ret ? "failure" : "success");
+ NV50_DBGMSG(SHADER, "SHADER TRANSLATION - %s\n", ret ? "failed" : "success");
out:
nv_pc_free_refs(pc);
@@ -673,7 +671,7 @@ nv_nvi_delete(struct nv_instruction *nvi)
if (nvi == b->phi) {
if (nvi->opcode != NV_OP_PHI)
- NV50_DBGMSG("NOTE: b->phi points to non-PHI instruction\n");
+ NV50_DBGMSG(PROG_IR, "NOTE: b->phi points to non-PHI instruction\n");
assert(!nvi->prev);
if (!nvi->next || nvi->next->opcode != NV_OP_PHI)
diff --git a/src/gallium/drivers/nv50/nv50_pc.h b/src/gallium/drivers/nv50/nv50_pc.h
index a9a3248038b..5bb0e1296bb 100644
--- a/src/gallium/drivers/nv50/nv50_pc.h
+++ b/src/gallium/drivers/nv50/nv50_pc.h
@@ -23,13 +23,7 @@
#ifndef __NV50_COMPILER_H__
#define __NV50_COMPILER_H__
-#define NV50PC_DEBUG
-
-#ifdef NV50PC_DEBUG
-# define NV50_DBGMSG(args...) debug_printf(args)
-#else
-# define NV50_DBGMSG(args...)
-#endif
+#include "nv50_debug.h"
#include "pipe/p_defines.h"
#include "util/u_inlines.h"
diff --git a/src/gallium/drivers/nv50/nv50_pc_optimize.c b/src/gallium/drivers/nv50/nv50_pc_optimize.c
index 281ccf7ac61..d72b23c137a 100644
--- a/src/gallium/drivers/nv50/nv50_pc_optimize.c
+++ b/src/gallium/drivers/nv50/nv50_pc_optimize.c
@@ -20,8 +20,6 @@
* SOFTWARE.
*/
-/* #define NV50PC_DEBUG */
-
#include "nv50_pc.h"
#define DESCEND_ARBITRARY(j, f) \
@@ -116,7 +114,7 @@ nvi_isnop(struct nv_instruction *nvi)
return FALSE;
if (nvi->src[0]->value->join->reg.id < 0) {
- NV50_DBGMSG("nvi_isnop: orphaned value detected\n");
+ NV50_DBGMSG(PROG_IR, "nvi_isnop: orphaned value detected\n");
return TRUE;
}
@@ -201,7 +199,7 @@ nv_pc_pass_pre_emission(void *priv, struct nv_basic_block *b)
}
if (!b->entry) {
- NV50_DBGMSG("block %p is now empty\n", b);
+ NV50_DBGMSG(PROG_IR, "block %p is now empty\n", b);
} else
if (!b->exit->is_long) {
assert(n32);
@@ -240,7 +238,7 @@ nv_pc_exec_pass2(struct nv_pc *pc)
{
int i, ret;
- NV50_DBGMSG("preparing %u blocks for emission\n", pc->num_blocks);
+ NV50_DBGMSG(PROG_IR, "preparing %u blocks for emission\n", pc->num_blocks);
pc->num_blocks = 0; /* will reorder bb_list */
@@ -966,7 +964,8 @@ nv_pass_flatten(struct nv_pass *ctx, struct nv_basic_block *b)
if (bb_is_if_else_endif(b)) {
- NV50_DBGMSG("pass_flatten: IF/ELSE/ENDIF construct at BB:%i\n", b->id);
+ NV50_DBGMSG(PROG_IR,
+ "pass_flatten: IF/ELSE/ENDIF construct at BB:%i\n", b->id);
for (n0 = 0, nvi = b->out[0]->entry; nvi; nvi = nvi->next, ++n0)
if (!nv50_nvi_can_predicate(nvi))
@@ -975,7 +974,7 @@ nv_pass_flatten(struct nv_pass *ctx, struct nv_basic_block *b)
for (n1 = 0, nvi = b->out[1]->entry; nvi; nvi = nvi->next, ++n1)
if (!nv50_nvi_can_predicate(nvi))
break;
-#ifdef NV50PC_DEBUG
+#if NV50_DEBUG & NV50_DEBUG_PROG_IR
if (nvi) {
debug_printf("cannot predicate: "); nv_print_instruction(nvi);
}
diff --git a/src/gallium/drivers/nv50/nv50_pc_regalloc.c b/src/gallium/drivers/nv50/nv50_pc_regalloc.c
index e4f418aa7ca..e79fd594cea 100644
--- a/src/gallium/drivers/nv50/nv50_pc_regalloc.c
+++ b/src/gallium/drivers/nv50/nv50_pc_regalloc.c
@@ -20,11 +20,11 @@
* SOFTWARE.
*/
-/* #define NV50PC_DEBUG */
-
-/* #define NV50_RA_DEBUG_LIVEI */
-/* #define NV50_RA_DEBUG_LIVE_SETS */
-/* #define NV50_RA_DEBUG_JOIN */
+#if NV50_DEBUG & NV50_DEBUG_PROG_RA
+# define NV50_RA_DEBUG_LIVEI
+# define NV50_RA_DEBUG_LIVE_SETS
+# define NV50_RA_DEBUG_JOIN
+#endif
#include "nv50_context.h"
#include "nv50_pc.h"
@@ -1013,7 +1013,7 @@ nv_pc_pass1(struct nv_pc *pc, struct nv_basic_block *root)
struct nv_pc_pass *ctx;
int i, ret;
- NV50_DBGMSG("REGISTER ALLOCATION - entering\n");
+ NV50_DBGMSG(PROG_RA, "REGISTER ALLOCATION - entering\n");
ctx = CALLOC_STRUCT(nv_pc_pass);
if (!ctx)
@@ -1075,7 +1075,7 @@ nv_pc_pass1(struct nv_pc *pc, struct nv_basic_block *root)
for (i = 0; i < pc->num_values; ++i)
livei_release(&pc->values[i]);
- NV50_DBGMSG("REGISTER ALLOCATION - leaving\n");
+ NV50_DBGMSG(PROG_RA, "REGISTER ALLOCATION - leaving\n");
out:
FREE(ctx->insns);
diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c
index 37025a6f12e..41d3e14dc0f 100644
--- a/src/gallium/drivers/nv50/nv50_program.c
+++ b/src/gallium/drivers/nv50/nv50_program.c
@@ -20,8 +20,6 @@
* SOFTWARE.
*/
-/* #define NV50_PROGRAM_DEBUG */
-
#include "nv50_program.h"
#include "nv50_pc.h"
#include "nv50_context.h"
@@ -564,7 +562,7 @@ nv50_prog_scan(struct nv50_translation_info *ti)
tgsi_scan_shader(p->pipe.tokens, &ti->scan);
-#ifdef NV50_PROGRAM_DEBUG
+#if NV50_DEBUG & NV50_DEBUG_SHADER
tgsi_dump(p->pipe.tokens, 0);
#endif
diff --git a/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c b/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c
index f548836a9c4..25dcaaea14f 100644
--- a/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c
+++ b/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c
@@ -20,8 +20,6 @@
* SOFTWARE.
*/
-/* #define NV50_TGSI2NC_DEBUG */
-
#include <unistd.h>
#include "nv50_context.h"
@@ -213,7 +211,7 @@ static INLINE void
bld_warn_uninitialized(struct bld_context *bld, int kind,
struct bld_value_stack *stk, struct nv_basic_block *b)
{
-#ifdef NV50_TGSI2NC_DEBUG
+#if NV50_DEBUG & NV50_DEBUG_PROG_IR
long i = (stk - &bld->tvs[0][0]) / 4;
long c = (stk - &bld->tvs[0][0]) & 3;
@@ -1562,7 +1560,7 @@ bld_instruction(struct bld_context *bld,
int c;
uint opcode = translate_opcode(insn->Instruction.Opcode);
-#ifdef NV50_TGSI2NC_DEBUG
+#if NV50_DEBUG & NV50_DEBUG_PROG_IR
debug_printf("bld_instruction:"); tgsi_dump_instruction(insn, 1);
#endif