diff options
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_context.h | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs.cpp | 6 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_program.h | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vec4_emit.cpp | 6 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_wm.c | 84 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_wm.h | 3 |
6 files changed, 103 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 1548f81ec4f..51dfcca4827 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -275,6 +275,8 @@ struct brw_fragment_program { struct brw_shader { struct gl_shader base; + bool compiled_once; + /** Shader IR transformed for native compile, at link time. */ struct exec_list *ir; }; diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 334a14c25d5..642d95a9289 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -2104,6 +2104,12 @@ brw_wm_fs_emit(struct brw_context *brw, struct brw_wm_compile *c, c->prog_data.dispatch_width = 8; + if (unlikely(INTEL_DEBUG & DEBUG_PERF)) { + if (shader->compiled_once) + brw_wm_debug_recompile(brw, prog, &c->key); + shader->compiled_once = true; + } + return true; } diff --git a/src/mesa/drivers/dri/i965/brw_program.h b/src/mesa/drivers/dri/i965/brw_program.h index 874238f2049..9fbc201ec9a 100644 --- a/src/mesa/drivers/dri/i965/brw_program.h +++ b/src/mesa/drivers/dri/i965/brw_program.h @@ -45,5 +45,7 @@ struct brw_sampler_prog_key_data { void brw_populate_sampler_prog_key_data(struct gl_context *ctx, const struct gl_program *prog, struct brw_sampler_prog_key_data *key); +bool brw_debug_recompile_sampler_key(const struct brw_sampler_prog_key_data *old_key, + const struct brw_sampler_prog_key_data *key); #endif diff --git a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp index e63e08dc7da..aea7d015a0e 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp @@ -1037,6 +1037,10 @@ brw_vs_emit(struct gl_shader_program *prog, struct brw_vs_compile *c) printf("\n\n"); } + if (shader->compiled_once) { + perf_debug("Recompiling vertex shader for program %d\n", prog->Name); + } + vec4_visitor v(c, prog, shader); if (!v.run()) { prog->LinkStatus = false; @@ -1044,6 +1048,8 @@ brw_vs_emit(struct gl_shader_program *prog, struct brw_vs_compile *c) return false; } + shader->compiled_once = true; + return true; } diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c index 3abc696b108..323eabd8169 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.c +++ b/src/mesa/drivers/dri/i965/brw_wm.c @@ -347,6 +347,90 @@ bool do_wm_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; + } else { + return false; + } +} + +bool +brw_debug_recompile_sampler_key(const struct brw_sampler_prog_key_data *old_key, + const struct brw_sampler_prog_key_data *key) +{ + bool found = false; + + for (unsigned int i = 0; i < BRW_MAX_TEX_UNIT; i++) { + found |= key_debug("EXT_texture_swizzle or DEPTH_TEXTURE_MODE", + key->swizzles[i], old_key->swizzles[i]); + } + found |= key_debug("GL_CLAMP enabled on any texture unit's 1st coordinate", + key->gl_clamp_mask[0], old_key->gl_clamp_mask[0]); + found |= key_debug("GL_CLAMP enabled on any texture unit's 2nd coordinate", + key->gl_clamp_mask[1], old_key->gl_clamp_mask[1]); + found |= key_debug("GL_CLAMP enabled on any texture unit's 3rd coordinate", + key->gl_clamp_mask[2], old_key->gl_clamp_mask[2]); + found |= key_debug("GL_MESA_ycbcr texturing\n", + key->yuvtex_mask, old_key->yuvtex_mask); + found |= key_debug("GL_MESA_ycbcr UV swapping\n", + key->yuvtex_swap_mask, old_key->yuvtex_swap_mask); + + return found; +} + +void +brw_wm_debug_recompile(struct brw_context *brw, + struct gl_shader_program *prog, + const struct brw_wm_prog_key *key) +{ + struct brw_cache_item *c = NULL; + const struct brw_wm_prog_key *old_key = NULL; + bool found = false; + + perf_debug("Recompiling fragment 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_WM_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; + } + + found |= key_debug("alphatest, computed depth, depth test, or depth write", + key->iz_lookup, old_key->iz_lookup); + found |= key_debug("depth statistics", key->stats_wm, old_key->stats_wm); + found |= key_debug("flat shading", key->flat_shade, old_key->flat_shade); + found |= key_debug("number of color buffers", key->nr_color_regions, old_key->nr_color_regions); + found |= key_debug("rendering to FBO", key->render_to_fbo, old_key->render_to_fbo); + found |= key_debug("fragment color clamping", key->clamp_fragment_color, old_key->clamp_fragment_color); + found |= key_debug("line smoothing", key->line_aa, old_key->line_aa); + found |= key_debug("proj_attrib_mask", key->proj_attrib_mask, old_key->proj_attrib_mask); + found |= key_debug("renderbuffer height", key->drawable_height, old_key->drawable_height); + found |= key_debug("vertex shader outputs", key->vp_outputs_written, old_key->vp_outputs_written); + + found |= brw_debug_recompile_sampler_key(&key->tex, &old_key->tex); + + if (!found) { + perf_debug(" Something else\n"); + } +} + void brw_populate_sampler_prog_key_data(struct gl_context *ctx, const struct gl_program *prog, diff --git a/src/mesa/drivers/dri/i965/brw_wm.h b/src/mesa/drivers/dri/i965/brw_wm.h index b976a605cb6..53b644fa002 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.h +++ b/src/mesa/drivers/dri/i965/brw_wm.h @@ -480,5 +480,8 @@ bool do_wm_prog(struct brw_context *brw, struct gl_shader_program *prog, struct brw_fragment_program *fp, struct brw_wm_prog_key *key); +void brw_wm_debug_recompile(struct brw_context *brw, + struct gl_shader_program *prog, + const struct brw_wm_prog_key *key); #endif |