[Mesa-dev] [PATCH 17/17] i965/vs: Don't hardcode DEBUG_VS in generic vec4 code.
Paul Berry
stereotype441 at gmail.com
Sun Apr 7 15:54:10 PDT 2013
Since the vec4_visitor and vec4_generator classes are going to be
re-used for geometry shaders, we can't enable their debug
functionality based on (INTEL_DEBUG & DEBUG_VS) anymore. Instead, add
a debug_flag boolean to these two classes, so that when they're
instantiated the caller can specify whether debug dumps are needed.
---
src/mesa/drivers/dri/i965/brw_vec4.cpp | 3 ++-
src/mesa/drivers/dri/i965/brw_vec4.h | 9 +++++++--
src/mesa/drivers/dri/i965/brw_vec4_emit.cpp | 15 ++++++++-------
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 9 ++++++---
src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp | 2 +-
5 files changed, 24 insertions(+), 14 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index 68af874..6cf8af7 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -1535,7 +1535,8 @@ brw_vs_emit(struct brw_context *brw,
return NULL;
}
- vec4_generator g(brw, prog, &c->vp->program.Base, mem_ctx);
+ vec4_generator g(brw, prog, &c->vp->program.Base, mem_ctx,
+ INTEL_DEBUG & DEBUG_VS);
const unsigned *generated =g.generate_assembly(&v.instructions,
final_assembly_size);
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index 377868d..d967c3e 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -216,7 +216,8 @@ public:
struct brw_vec4_prog_data *vec4_prog_data,
struct gl_shader_program *prog,
struct brw_shader *shader,
- void *mem_ctx);
+ void *mem_ctx,
+ bool debug_flag);
~vec4_visitor();
dst_reg dst_null_f()
@@ -489,6 +490,8 @@ protected:
virtual void emit_urb_write_header(int mrf) = 0;
virtual vec4_instruction *emit_urb_write_opcode(bool complete) = 0;
virtual int compute_array_stride(ir_dereference_array *ir);
+
+ const bool debug_flag;
};
class vec4_vs_visitor : public vec4_visitor
@@ -532,7 +535,8 @@ public:
vec4_generator(struct brw_context *brw,
struct gl_shader_program *prog,
struct gl_program *glprog,
- void *mem_ctx);
+ void *mem_ctx,
+ bool debug_flag);
~vec4_generator();
const unsigned *generate_assembly(exec_list *insts, unsigned *asm_size);
@@ -592,6 +596,7 @@ private:
const struct gl_program *glprog;
void *mem_ctx;
+ const bool debug_flag;
};
} /* namespace brw */
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
index 7c3cda5..754fd2c 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
@@ -135,8 +135,9 @@ vec4_instruction::get_src(int i)
vec4_generator::vec4_generator(struct brw_context *brw,
struct gl_shader_program *prog,
struct gl_program *glprog,
- void *mem_ctx)
- : brw(brw), prog(prog), glprog(glprog), mem_ctx(mem_ctx)
+ void *mem_ctx,
+ bool debug_flag)
+ : brw(brw), prog(prog), glprog(glprog), mem_ctx(mem_ctx), debug_flag(debug_flag)
{
intel = &brw->intel;
@@ -694,7 +695,7 @@ vec4_generator::generate_code(exec_list *instructions)
const char *last_annotation_string = NULL;
const void *last_annotation_ir = NULL;
- if (unlikely(INTEL_DEBUG & DEBUG_VS)) {
+ if (unlikely(debug_flag)) {
if (shader) {
printf("Native code for vertex shader %d:\n", prog->Name);
} else {
@@ -706,7 +707,7 @@ vec4_generator::generate_code(exec_list *instructions)
vec4_instruction *inst = (vec4_instruction *)node;
struct brw_reg src[3], dst;
- if (unlikely(INTEL_DEBUG & DEBUG_VS)) {
+ if (unlikely(debug_flag)) {
if (last_annotation_ir != inst->ir) {
last_annotation_ir = inst->ir;
if (last_annotation_ir) {
@@ -882,7 +883,7 @@ vec4_generator::generate_code(exec_list *instructions)
last->header.dependency_control |= BRW_DEPENDENCY_NOTCHECKED;
}
- if (unlikely(INTEL_DEBUG & DEBUG_VS)) {
+ if (unlikely(debug_flag)) {
brw_dump_compile(p, stdout,
last_native_insn_offset, p->next_insn_offset);
}
@@ -890,7 +891,7 @@ vec4_generator::generate_code(exec_list *instructions)
last_native_insn_offset = p->next_insn_offset;
}
- if (unlikely(INTEL_DEBUG & DEBUG_VS)) {
+ if (unlikely(debug_flag)) {
printf("\n");
}
@@ -901,7 +902,7 @@ vec4_generator::generate_code(exec_list *instructions)
* which is often something we want to debug. So this is here in
* case you're doing that.
*/
- if (0 && unlikely(INTEL_DEBUG & DEBUG_VS)) {
+ if (0 && unlikely(debug_flag)) {
brw_dump_compile(p, stdout, 0, p->next_insn_offset);
}
}
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index 5f9fee7..27aab66 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -3026,7 +3026,9 @@ vec4_visitor::vec4_visitor(struct brw_context *brw,
struct brw_vec4_prog_data *vec4_prog_data,
struct gl_shader_program *prog,
struct brw_shader *shader,
- void *mem_ctx)
+ void *mem_ctx,
+ bool debug_flag)
+ : debug_flag(debug_flag)
{
this->brw = brw;
this->intel = &brw->intel;
@@ -3077,7 +3079,8 @@ vec4_vs_visitor::vec4_vs_visitor(struct brw_context *brw,
struct brw_shader *shader,
void *mem_ctx)
: vec4_visitor(brw, &c->base, &c->vp->program.Base, &c->key.base,
- &prog_data->base, prog, shader, mem_ctx),
+ &prog_data->base, prog, shader, mem_ctx,
+ INTEL_DEBUG & DEBUG_VS),
c(c),
prog_data(prog_data)
{
@@ -3102,7 +3105,7 @@ vec4_visitor::fail(const char *format, ...)
this->fail_msg = msg;
- if (INTEL_DEBUG & DEBUG_VS) {
+ if (debug_flag) {
fprintf(stderr, "%s", msg);
}
}
diff --git a/src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp b/src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp
index 595f519..286b3d3 100644
--- a/src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp
+++ b/src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp
@@ -48,7 +48,7 @@ class register_coalesce_vec4_visitor : public vec4_visitor
public:
register_coalesce_vec4_visitor(struct brw_context *brw,
struct gl_shader_program *prog)
- : vec4_visitor(brw, NULL, NULL, NULL, NULL, prog, NULL, NULL)
+ : vec4_visitor(brw, NULL, NULL, NULL, NULL, prog, NULL, NULL, false)
{
}
--
1.8.2
More information about the mesa-dev
mailing list