[Mesa-dev] [PATCH 09/13] i965 vs: Add get_debug_name().
Paul Berry
stereotype441 at gmail.com
Wed Nov 16 11:07:16 PST 2011
Previously, vec4_visitor contained several explicit references to
vertex shading in debug messages. This patch moves all of those
references into a single function, get_debug_name(), which returns a
human-readable description of the shader being compiled.
This helps pave the way for sharing code between VS and GS code
generation, by creating a function that can be made virtual.
---
src/mesa/drivers/dri/i965/brw_vec4.h | 1 +
src/mesa/drivers/dri/i965/brw_vec4_emit.cpp | 20 ++++++++++++++++----
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 3 ++-
3 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index 4e17d15..c0284fc 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -516,6 +516,7 @@ public:
void resolve_ud_negate(src_reg *reg);
bool get_debug_flag() const;
+ const char *get_debug_name() const;
int generate_code(int first_non_payload_grf);
void generate_vs_instruction(vec4_instruction *inst,
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
index 0ee6525..dceacc7 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
@@ -611,10 +611,12 @@ vec4_visitor::generate_vs_instruction(vec4_instruction *instruction,
default:
if (inst->opcode < (int)ARRAY_SIZE(brw_opcodes)) {
- fail("unsupported opcode in `%s' in VS\n",
- brw_opcodes[inst->opcode].name);
+ fail("unsupported opcode in `%s' in %s\n",
+ brw_opcodes[inst->opcode].name,
+ get_debug_name());
} else {
- fail("Unsupported opcode %d in VS", inst->opcode);
+ fail("Unsupported opcode %d in %s", inst->opcode,
+ get_debug_name());
}
}
}
@@ -670,6 +672,16 @@ vec4_visitor::get_debug_flag() const
return INTEL_DEBUG & DEBUG_VS;
}
+/**
+ * Return a string describing the program being compiled, for debugging
+ * purposes. Caller should not free this string.
+ */
+const char *
+vec4_visitor::get_debug_name() const
+{
+ return ralloc_asprintf(mem_ctx, "vertex shader %d", prog->Name);
+}
+
int
vec4_visitor::generate_code(int first_non_payload_grf)
{
@@ -693,7 +705,7 @@ vec4_visitor::generate_code(int first_non_payload_grf)
return 0;
if (unlikely(debug_flag)) {
- printf("Native code for vertex shader %d:\n", prog->Name);
+ printf("Native code for %s:\n", get_debug_name());
}
foreach_list(node, &this->instructions) {
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index 6262093..5025115 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -2424,7 +2424,8 @@ vec4_visitor::fail(const char *format, ...)
va_start(va, format);
msg = ralloc_vasprintf(mem_ctx, format, va);
va_end(va);
- msg = ralloc_asprintf(mem_ctx, "VS compile failed: %s\n", msg);
+ msg = ralloc_asprintf(mem_ctx, "compile failed for %s: %s\n",
+ get_debug_name(), msg);
this->fail_msg = msg;
--
1.7.6.4
More information about the mesa-dev
mailing list