aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2014-06-28 14:36:26 -0700
committerEric Anholt <[email protected]>2014-08-08 18:59:46 -0700
commit21db43021041e8dedc45bb232c10ece83fd09dd1 (patch)
tree692af36222549b888feb35b303848b4f23b1f2e9 /src
parent2e35981d4d625d951328ef5b8f95798112997fb3 (diff)
vc4: Add VC4_DEBUG env option
v2: Fix an accidental deletion of some characters from the copyright message (caught by Ilia Mirkin)
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/vc4/vc4_context.c17
-rw-r--r--src/gallium/drivers/vc4/vc4_program.c24
-rw-r--r--src/gallium/drivers/vc4/vc4_qpu_emit.c4
-rw-r--r--src/gallium/drivers/vc4/vc4_screen.c22
-rw-r--r--src/gallium/drivers/vc4/vc4_screen.h10
5 files changed, 63 insertions, 14 deletions
diff --git a/src/gallium/drivers/vc4/vc4_context.c b/src/gallium/drivers/vc4/vc4_context.c
index 66cba1f33e0..032d606eb7a 100644
--- a/src/gallium/drivers/vc4/vc4_context.c
+++ b/src/gallium/drivers/vc4/vc4_context.c
@@ -110,13 +110,16 @@ vc4_flush(struct pipe_context *pctx)
submit.shader_record_len = vc4->shader_rec.next - vc4->shader_rec.base;
submit.shader_record_count = vc4->shader_rec_count;
+ if (!(vc4_debug & VC4_DEBUG_NORAST)) {
#ifndef USE_VC4_SIMULATOR
- int ret = drmIoctl(vc4->fd, DRM_IOCTL_VC4_SUBMIT_CL, &submit);
- if (ret)
- errx(1, "VC4 submit failed\n");
+ int ret = drmIoctl(vc4->fd, DRM_IOCTL_VC4_SUBMIT_CL, &submit);
+ if (ret)
+ errx(1, "VC4 submit failed\n");
#else
- vc4_simulator_flush(vc4, csurf);
+ vc4_simulator_flush(vc4, csurf);
#endif
+ }
+
vc4_reset_cl(&vc4->bcl);
vc4_reset_cl(&vc4->rcl);
vc4_reset_cl(&vc4->shader_rec);
@@ -158,6 +161,10 @@ vc4_context_create(struct pipe_screen *pscreen, void *priv)
struct vc4_screen *screen = vc4_screen(pscreen);
struct vc4_context *vc4;
+ /* Prevent dumping of the shaders built during context setup. */
+ uint32_t saved_shaderdb_flag = vc4_debug & VC4_DEBUG_SHADERDB;
+ vc4_debug &= ~VC4_DEBUG_SHADERDB;
+
vc4 = CALLOC_STRUCT(vc4_context);
if (vc4 == NULL)
return NULL;
@@ -194,6 +201,8 @@ vc4_context_create(struct pipe_screen *pscreen, void *priv)
if (!vc4->primconvert)
goto fail;
+ vc4_debug |= saved_shaderdb_flag;
+
return &vc4->base;
fail:
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c
index 4742c54772a..8d71212a69f 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -274,8 +274,6 @@ emit_tgsi_instruction(struct tgsi_to_qir *trans,
if (tgsi_op == TGSI_OPCODE_END)
return;
- tgsi_dump_instruction(tgsi_inst, asdf++);
-
if (tgsi_op > ARRAY_SIZE(op_trans) || !op_trans[tgsi_op].func) {
fprintf(stderr, "unknown tgsi inst: ");
tgsi_dump_instruction(tgsi_inst, asdf++);
@@ -329,7 +327,7 @@ emit_frag_init(struct tgsi_to_qir *trans, struct vc4_shader_state *so)
{
/* XXX: lols */
for (int i = 0; i < 4; i++) {
- trans->inputs[i] = qir_uniform_ui(trans, fui(i / 4.0));
+ trans->inputs[i] = qir_uniform_ui(trans, fui(1.0));
}
}
@@ -457,8 +455,10 @@ vc4_shader_tgsi_to_qir(struct vc4_shader_state *so, enum qstage stage)
ret = tgsi_parse_init(&trans->parser, so->base.tokens);
assert(ret == TGSI_PARSE_OK);
- fprintf(stderr, "TGSI:\n");
- tgsi_dump(so->base.tokens, 0);
+ if (vc4_debug & VC4_DEBUG_TGSI) {
+ fprintf(stderr, "TGSI:\n");
+ tgsi_dump(so->base.tokens, 0);
+ }
switch (stage) {
case QSTAGE_FRAG:
@@ -500,13 +500,23 @@ vc4_shader_tgsi_to_qir(struct vc4_shader_state *so, enum qstage stage)
break;
}
- qir_dump(c);
+ if (vc4_debug & VC4_DEBUG_QIR) {
+ fprintf(stderr, "QIR:\n");
+ qir_dump(c);
+ }
tgsi_parse_free(&trans->parser);
free(trans->temps);
vc4_generate_code(c);
+ if (vc4_debug & VC4_DEBUG_SHADERDB) {
+ fprintf(stderr, "SHADER-DB: %s: %d instructions\n",
+ qir_get_stage_name(c->stage), c->num_qpu_insts);
+ fprintf(stderr, "SHADER-DB: %s: %d uniforms\n",
+ qir_get_stage_name(c->stage), trans->num_uniforms);
+ }
+
return trans;
}
@@ -629,7 +639,7 @@ vc4_get_uniform_bo(struct vc4_context *vc4, struct vc4_shader_state *shader,
map[i] = fui(vc4->framebuffer.height * -16.0f / 2.0f);
break;
}
-#if 1
+#if 0
fprintf(stderr, "%p/%d: %d: 0x%08x (%f)\n",
shader, shader_index, i, map[i], uif(map[i]));
#endif
diff --git a/src/gallium/drivers/vc4/vc4_qpu_emit.c b/src/gallium/drivers/vc4/vc4_qpu_emit.c
index d0f7f894182..4591c6b0301 100644
--- a/src/gallium/drivers/vc4/vc4_qpu_emit.c
+++ b/src/gallium/drivers/vc4/vc4_qpu_emit.c
@@ -363,7 +363,9 @@ vc4_generate_code(struct qcompile *c)
c->qpu_insts = insts;
c->num_qpu_insts = ni;
- vc4_dump_program(c);
+ if (vc4_debug & VC4_DEBUG_QPU)
+ vc4_dump_program(c);
+
vc4_qpu_validate(insts, ni);
}
diff --git a/src/gallium/drivers/vc4/vc4_screen.c b/src/gallium/drivers/vc4/vc4_screen.c
index 7c7ed4ca6eb..59ac1e2a8c1 100644
--- a/src/gallium/drivers/vc4/vc4_screen.c
+++ b/src/gallium/drivers/vc4/vc4_screen.c
@@ -37,9 +37,25 @@
#include "vc4_resource.h"
static const struct debug_named_value debug_options[] = {
- {"cl", VC4_DBG_CL, "Dump command list during creation"},
+ { "cl", VC4_DEBUG_CL,
+ "Dump command list during creation" },
+ { "qpu", VC4_DEBUG_QPU,
+ "Dump generated QPU instructions" },
+ { "qir", VC4_DEBUG_QIR,
+ "Dump QPU IR during program compile" },
+ { "tgsi", VC4_DEBUG_TGSI,
+ "Dump TGSI during program compile" },
+ { "shaderdb", VC4_DEBUG_SHADERDB,
+ "Dump program compile information for shader-db analysis" },
+ { "perf", VC4_DEBUG_PERF,
+ "Print during performance-related events" },
+ { "norast", VC4_DEBUG_NORAST,
+ "Skip actual hardware execution of commands" },
};
+DEBUG_GET_ONCE_FLAGS_OPTION(vc4_debug, "VC4_DEBUG", debug_options, 0)
+uint32_t vc4_debug;
+
static const char *
vc4_screen_get_name(struct pipe_screen *pscreen)
{
@@ -381,6 +397,10 @@ vc4_screen_create(int fd)
screen->fd = fd;
+ vc4_debug = debug_get_option_vc4_debug();
+ if (vc4_debug & VC4_DEBUG_SHADERDB)
+ vc4_debug |= VC4_DEBUG_NORAST;
+
#if USE_VC4_SIMULATOR
vc4_simulator_init(screen);
#endif
diff --git a/src/gallium/drivers/vc4/vc4_screen.h b/src/gallium/drivers/vc4/vc4_screen.h
index 64bd2cf6510..1fe5ce14190 100644
--- a/src/gallium/drivers/vc4/vc4_screen.h
+++ b/src/gallium/drivers/vc4/vc4_screen.h
@@ -29,7 +29,13 @@
struct vc4_bo;
-#define VC4_DBG_CL 0x0001
+#define VC4_DEBUG_CL 0x0001
+#define VC4_DEBUG_QPU 0x0002
+#define VC4_DEBUG_QIR 0x0004
+#define VC4_DEBUG_TGSI 0x0008
+#define VC4_DEBUG_SHADERDB 0x0010
+#define VC4_DEBUG_PERF 0x0020
+#define VC4_DEBUG_NORAST 0x0040
#define VC4_MAX_MIP_LEVELS 11
@@ -60,4 +66,6 @@ vc4_screen_bo_from_handle(struct pipe_screen *pscreen,
uint8_t vc4_get_texture_format(enum pipe_format format);
+extern uint32_t vc4_debug;
+
#endif /* VC4_SCREEN_H */