From c20cb8d1f6cac0b98950828e69376bb9406761ff Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Sun, 26 Aug 2012 07:41:50 -0700 Subject: [PATCH] i965/vs: Add VS program key dumping to INTEL_DEBUG=perf. Eric added support for WM key debugging. This adds it for the VS. Signed-off-by: Kenneth Graunke Reviewed-by: Eric Anholt --- src/mesa/drivers/dri/i965/brw_vec4_emit.cpp | 3 +- src/mesa/drivers/dri/i965/brw_vs.c | 71 +++++++++++++++++++++ src/mesa/drivers/dri/i965/brw_vs.h | 3 + 3 files changed, 76 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp index 9e4efd0933a..0a504673a57 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp @@ -1023,6 +1023,7 @@ extern "C" { bool brw_vs_emit(struct gl_shader_program *prog, struct brw_vs_compile *c) { + struct brw_context *brw = c->func.brw; struct intel_context *intel = &c->func.brw->intel; bool start_busy = false; float start_time = 0; @@ -1049,7 +1050,7 @@ brw_vs_emit(struct gl_shader_program *prog, struct brw_vs_compile *c) if (unlikely(INTEL_DEBUG & DEBUG_PERF)) { if (shader->compiled_once) { - perf_debug("Recompiling vertex shader for program %d\n", prog->Name); + brw_vs_debug_recompile(brw, prog, &c->key); } if (start_busy && !drm_intel_bo_busy(intel->batch.last_bo)) { perf_debug("VS compile took %.03f ms and stalled the GPU\n", diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c index 2ad4134608c..21204372c0d 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.c +++ b/src/mesa/drivers/dri/i965/brw_vs.c @@ -297,6 +297,77 @@ do_vs_prog(struct brw_context *brw, return true; } +static bool +key_debug(const char *name, int a, int b) +{ + if (a != b) { + perf_debug(" %s %d->%d\n", name, a, b); + return true; + } + return false; +} + +void +brw_vs_debug_recompile(struct brw_context *brw, + struct gl_shader_program *prog, + const struct brw_vs_prog_key *key) +{ + struct brw_cache_item *c = NULL; + const struct brw_vs_prog_key *old_key = NULL; + bool found = false; + + perf_debug("Recompiling vertex shader for program %d\n", prog->Name); + + for (unsigned int i = 0; i < brw->cache.size; i++) { + for (c = brw->cache.items[i]; c; c = c->next) { + if (c->cache_id == BRW_VS_PROG) { + old_key = c->key; + + if (old_key->program_string_id == key->program_string_id) + break; + } + } + if (c) + break; + } + + if (!c) { + perf_debug(" Didn't find previous compile in the shader cache for " + "debug\n"); + return; + } + + for (unsigned int i = 0; i < VERT_ATTRIB_MAX; i++) { + found |= key_debug("GL_FIXED rescaling", + old_key->gl_fixed_input_size[i], + key->gl_fixed_input_size[i]); + } + + found |= key_debug("user clip flags", + old_key->userclip_active, key->userclip_active); + + found |= key_debug("user clipping planes as push constants", + old_key->nr_userclip_plane_consts, + key->nr_userclip_plane_consts); + + found |= key_debug("clip distance enable", + old_key->uses_clip_distance, key->uses_clip_distance); + found |= key_debug("clip plane enable bitfield", + old_key->userclip_planes_enabled_gen_4_5, + key->userclip_planes_enabled_gen_4_5); + found |= key_debug("copy edgeflag", + old_key->copy_edgeflag, key->copy_edgeflag); + found |= key_debug("PointCoord replace", + old_key->point_coord_replace, key->point_coord_replace); + found |= key_debug("vertex color clamping", + old_key->clamp_vertex_color, key->clamp_vertex_color); + + found |= brw_debug_recompile_sampler_key(&old_key->tex, &key->tex); + + if (!found) { + perf_debug(" Something else\n"); + } +} static void brw_upload_vs_prog(struct brw_context *brw) { diff --git a/src/mesa/drivers/dri/i965/brw_vs.h b/src/mesa/drivers/dri/i965/brw_vs.h index 6d3b6ce1d25..a68a620b1f2 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.h +++ b/src/mesa/drivers/dri/i965/brw_vs.h @@ -120,5 +120,8 @@ struct brw_vs_compile { bool brw_vs_emit(struct gl_shader_program *prog, struct brw_vs_compile *c); void brw_old_vs_emit(struct brw_vs_compile *c); bool brw_vs_precompile(struct gl_context *ctx, struct gl_shader_program *prog); +void brw_vs_debug_recompile(struct brw_context *brw, + struct gl_shader_program *prog, + const struct brw_vs_prog_key *key); #endif -- 2.30.2