To determine whether a debug dump should be performed, vec4_visitor checks the DEBUG_VS bit in INTEL_DEBUG. This patch moves that check into a single common function, get_debug_flag().
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 | 2 ++ src/mesa/drivers/dri/i965/brw_vec4_emit.cpp | 21 ++++++++++++++++----- src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 2 +- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h index 6fafc97..4e17d15 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.h +++ b/src/mesa/drivers/dri/i965/brw_vec4.h @@ -515,6 +515,8 @@ public: bool try_emit_sat(ir_expression *ir); void resolve_ud_negate(src_reg *reg); + bool get_debug_flag() const; + int generate_code(int first_non_payload_grf); void generate_vs_instruction(vec4_instruction *inst, struct brw_reg dst, diff --git a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp index e5dc763..0ee6525 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp @@ -660,9 +660,20 @@ vec4_visitor::run() prog_data->total_grf = generate_code(first_non_payload_grf); } +/** + * Return a bool indicating whether debugging output should be generated + * for this shader. + */ +bool +vec4_visitor::get_debug_flag() const +{ + return INTEL_DEBUG & DEBUG_VS; +} + int vec4_visitor::generate_code(int first_non_payload_grf) { + bool debug_flag = get_debug_flag(); int last_native_inst = 0; const char *last_annotation_string = NULL; ir_instruction *last_annotation_ir = NULL; @@ -681,7 +692,7 @@ vec4_visitor::generate_code(int first_non_payload_grf) if (failed()) return 0; - if (unlikely(INTEL_DEBUG & DEBUG_VS)) { + if (unlikely(debug_flag)) { printf("Native code for vertex shader %d:\n", prog->Name); } @@ -689,7 +700,7 @@ vec4_visitor::generate_code(int first_non_payload_grf) 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) { @@ -862,7 +873,7 @@ vec4_visitor::generate_code(int first_non_payload_grf) break; } - if (unlikely(INTEL_DEBUG & DEBUG_VS)) { + if (unlikely(debug_flag)) { for (unsigned int i = last_native_inst; i < p->nr_insn; i++) { if (0) { printf("0x%08x 0x%08x 0x%08x 0x%08x ", @@ -878,7 +889,7 @@ vec4_visitor::generate_code(int first_non_payload_grf) last_native_inst = p->nr_insn; } - if (unlikely(INTEL_DEBUG & DEBUG_VS)) { + if (unlikely(debug_flag)) { printf("\n"); } @@ -893,7 +904,7 @@ vec4_visitor::generate_code(int first_non_payload_grf) * case you're doing that. */ if (0) { - if (unlikely(INTEL_DEBUG & DEBUG_VS)) { + if (unlikely(debug_flag)) { for (unsigned int i = 0; i < p->nr_insn; i++) { printf("0x%08x 0x%08x 0x%08x 0x%08x ", ((uint32_t *)&p->store[i])[3], diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp index 338106c..6262093 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -2428,7 +2428,7 @@ vec4_visitor::fail(const char *format, ...) this->fail_msg = msg; - if (INTEL_DEBUG & DEBUG_VS) { + if (get_debug_flag()) { fprintf(stderr, "%s", msg); } } -- 1.7.6.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev