i965/vs: Add VS program key dumping to INTEL_DEBUG=perf.
authorKenneth Graunke <kenneth@whitecape.org>
Sun, 26 Aug 2012 14:41:50 +0000 (07:41 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 27 Aug 2012 21:23:40 +0000 (14:23 -0700)
Eric added support for WM key debugging.  This adds it for the VS.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
src/mesa/drivers/dri/i965/brw_vs.c
src/mesa/drivers/dri/i965/brw_vs.h

index 9e4efd0933ab40c33598198b51dafea4dd2491a5..0a504673a57cc3b8c13c73ffeb750a75e507d02a 100644 (file)
@@ -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",
index 2ad4134608c7a714963c45a7784fb4a23ba86216..21204372c0de4a84d0e80e438f2cb84e0aab07ec 100644 (file)
@@ -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)
 {
index 6d3b6ce1d254f4c6126957a9b3c11f72d8c3b56d..a68a620b1f2bf999cf900f6784999236ed691592 100644 (file)
@@ -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