summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2019-04-15 21:59:50 -0700
committerKenneth Graunke <kenneth@whitecape.org>2019-04-16 09:01:15 -0700
commitfad7801afd194c504bd945c497741ecaf04e2cdd (patch)
tree552a1266c996048a4f900f333a54fb0b8bffb473 /src/mesa
parent4f715868a94b2c43656b3574b876bd254757521b (diff)
i965: Move program key debugging to the compiler.
The i965 driver has a bunch of code to compare two sets of program keys and print out the differences. This can be useful for debugging why a shader needed to be recompiled on the fly due to non-orthogonal state dependencies. anv doesn't do recompiles, so we didn't need to share this in the past - but I'd like to use it in iris. This moves the bulk of the code to the compiler where it can be reused. To make that possible, we need to decouple it from i965 - we can't get at the brw program cache directly, nor use brw_context to print things. Instead, we use compiler->shader_perf_log(), and simply pass in keys. We put all of this debugging code in brw_debug_recompile.c, and only export a single function, for simplicity. I also tidied the code a bit while moving it, now that it all lives in one file. Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.h20
-rw-r--r--src/mesa/drivers/dri/i965/brw_cs.c3
-rw-r--r--src/mesa/drivers/dri/i965/brw_gs.c27
-rw-r--r--src/mesa/drivers/dri/i965/brw_program.c20
-rw-r--r--src/mesa/drivers/dri/i965/brw_program.h6
-rw-r--r--src/mesa/drivers/dri/i965/brw_tcs.c38
-rw-r--r--src/mesa/drivers/dri/i965/brw_tes.c32
-rw-r--r--src/mesa/drivers/dri/i965/brw_vs.c44
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm.c129
9 files changed, 36 insertions, 283 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 4d6cd58d3ce..d6187541a8c 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1456,26 +1456,6 @@ void brw_validate_textures( struct brw_context *brw );
/*======================================================================
* brw_program.c
*/
-static inline bool
-key_debug(struct brw_context *brw, const char *name, int a, int b)
-{
- if (a != b) {
- perf_debug(" %s %d->%d\n", name, a, b);
- return true;
- }
- return false;
-}
-
-static inline bool
-key_debug_float(struct brw_context *brw, const char *name, float a, float b)
-{
- if (a != b) {
- perf_debug(" %s %f->%f\n", name, a, b);
- return true;
- }
- return false;
-}
-
void brwInitFragProgFuncs( struct dd_function_table *functions );
void brw_get_scratch_bo(struct brw_context *brw,
diff --git a/src/mesa/drivers/dri/i965/brw_cs.c b/src/mesa/drivers/dri/i965/brw_cs.c
index 4d968c26656..ea78471d763 100644
--- a/src/mesa/drivers/dri/i965/brw_cs.c
+++ b/src/mesa/drivers/dri/i965/brw_cs.c
@@ -104,7 +104,8 @@ brw_codegen_cs_prog(struct brw_context *brw,
if (unlikely(brw->perf_debug)) {
if (cp->compiled_once) {
- _mesa_problem(&brw->ctx, "CS programs shouldn't need recompiles");
+ brw_debug_recompile(brw, MESA_SHADER_COMPUTE, cp->program.Id,
+ key->program_string_id, key);
}
cp->compiled_once = true;
diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c
index a35ce97db3e..eeff4784e72 100644
--- a/src/mesa/drivers/dri/i965/brw_gs.c
+++ b/src/mesa/drivers/dri/i965/brw_gs.c
@@ -36,30 +36,6 @@
#include "compiler/glsl/ir_uniform.h"
static void
-brw_gs_debug_recompile(struct brw_context *brw, struct gl_program *prog,
- const struct brw_gs_prog_key *key)
-{
- perf_debug("Recompiling geometry shader for program %d\n", prog->Id);
-
- bool found = false;
- const struct brw_gs_prog_key *old_key =
- brw_find_previous_compile(&brw->cache, BRW_CACHE_GS_PROG,
- key->program_string_id);
-
- if (!old_key) {
- perf_debug(" Didn't find previous compile in the shader cache for "
- "debug\n");
- return;
- }
-
- found |= brw_debug_recompile_sampler_key(brw, &old_key->tex, &key->tex);
-
- if (!found) {
- perf_debug(" Something else\n");
- }
-}
-
-static void
assign_gs_binding_table_offsets(const struct gen_device_info *devinfo,
const struct gl_program *prog,
struct brw_gs_prog_data *prog_data)
@@ -128,7 +104,8 @@ brw_codegen_gs_prog(struct brw_context *brw,
if (unlikely(brw->perf_debug)) {
if (gp->compiled_once) {
- brw_gs_debug_recompile(brw, &gp->program, key);
+ brw_debug_recompile(brw, MESA_SHADER_GEOMETRY, gp->program.Id,
+ key->program_string_id, key);
}
if (start_busy && !brw_bo_busy(brw->batch.last_bo)) {
perf_debug("GS compile took %.03f ms and stalled the GPU\n",
diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c
index 2ef11508c79..b8681fe579e 100644
--- a/src/mesa/drivers/dri/i965/brw_program.c
+++ b/src/mesa/drivers/dri/i965/brw_program.c
@@ -54,6 +54,7 @@
#include "brw_gs.h"
#include "brw_vs.h"
#include "brw_wm.h"
+#include "brw_state.h"
#include "main/shaderapi.h"
#include "main/shaderobj.h"
@@ -909,3 +910,22 @@ brw_populate_default_key(const struct gen_device_info *devinfo,
unreachable("Unsupported stage!");
}
}
+
+void
+brw_debug_recompile(struct brw_context *brw,
+ gl_shader_stage stage,
+ unsigned api_id,
+ unsigned key_program_string_id,
+ void *key)
+{
+ const struct brw_compiler *compiler = brw->screen->compiler;
+ enum brw_cache_id cache_id = brw_stage_cache_id(stage);
+
+ compiler->shader_perf_log(brw, "Recompiling %s shader for program %d\n",
+ _mesa_shader_stage_to_string(stage), api_id);
+
+ const void *old_key =
+ brw_find_previous_compile(&brw->cache, cache_id, key_program_string_id);
+
+ brw_debug_key_recompile(compiler, brw, stage, old_key, key);
+}
diff --git a/src/mesa/drivers/dri/i965/brw_program.h b/src/mesa/drivers/dri/i965/brw_program.h
index 32c87fa2321..fc10433f322 100644
--- a/src/mesa/drivers/dri/i965/brw_program.h
+++ b/src/mesa/drivers/dri/i965/brw_program.h
@@ -73,10 +73,8 @@ void brw_setup_tex_for_precompile(const struct gen_device_info *devinfo,
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(struct brw_context *brw,
- const struct brw_sampler_prog_key_data *old_key,
- const struct brw_sampler_prog_key_data *key);
-
+void brw_debug_recompile(struct brw_context *brw, gl_shader_stage stage,
+ unsigned api_id, unsigned prog_string_id, void *key);
uint32_t
brw_assign_common_binding_table_offsets(const struct gen_device_info *devinfo,
const struct gl_program *prog,
diff --git a/src/mesa/drivers/dri/i965/brw_tcs.c b/src/mesa/drivers/dri/i965/brw_tcs.c
index 86c09b92168..dbb469214b2 100644
--- a/src/mesa/drivers/dri/i965/brw_tcs.c
+++ b/src/mesa/drivers/dri/i965/brw_tcs.c
@@ -34,41 +34,6 @@
#include "program/prog_parameter.h"
#include "nir_builder.h"
-static void
-brw_tcs_debug_recompile(struct brw_context *brw, struct gl_program *prog,
- const struct brw_tcs_prog_key *key)
-{
- perf_debug("Recompiling tessellation control shader for program %d\n",
- prog->Id);
-
- bool found = false;
- const struct brw_tcs_prog_key *old_key =
- brw_find_previous_compile(&brw->cache, BRW_CACHE_TCS_PROG,
- key->program_string_id);
-
- if (!old_key) {
- perf_debug(" Didn't find previous compile in the shader cache for "
- "debug\n");
- return;
- }
-
- found |= key_debug(brw, "input vertices", old_key->input_vertices,
- key->input_vertices);
- found |= key_debug(brw, "outputs written", old_key->outputs_written,
- key->outputs_written);
- found |= key_debug(brw, "patch outputs written", old_key->patch_outputs_written,
- key->patch_outputs_written);
- found |= key_debug(brw, "TES primitive mode", old_key->tes_primitive_mode,
- key->tes_primitive_mode);
- found |= key_debug(brw, "quads and equal_spacing workaround",
- old_key->quads_workaround, key->quads_workaround);
- found |= brw_debug_recompile_sampler_key(brw, &old_key->tex, &key->tex);
-
- if (!found) {
- perf_debug(" Something else\n");
- }
-}
-
static bool
brw_codegen_tcs_prog(struct brw_context *brw, struct brw_program *tcp,
struct brw_program *tep, struct brw_tcs_prog_key *key)
@@ -161,7 +126,8 @@ brw_codegen_tcs_prog(struct brw_context *brw, struct brw_program *tcp,
if (unlikely(brw->perf_debug)) {
if (tcp) {
if (tcp->compiled_once) {
- brw_tcs_debug_recompile(brw, &tcp->program, key);
+ brw_debug_recompile(brw, MESA_SHADER_TESS_CTRL, tcp->program.Id,
+ key->program_string_id, key);
}
tcp->compiled_once = true;
}
diff --git a/src/mesa/drivers/dri/i965/brw_tes.c b/src/mesa/drivers/dri/i965/brw_tes.c
index 567fed6f808..6bdd9c0fdca 100644
--- a/src/mesa/drivers/dri/i965/brw_tes.c
+++ b/src/mesa/drivers/dri/i965/brw_tes.c
@@ -33,35 +33,6 @@
#include "brw_state.h"
#include "program/prog_parameter.h"
-static void
-brw_tes_debug_recompile(struct brw_context *brw, struct gl_program *prog,
- const struct brw_tes_prog_key *key)
-{
- perf_debug("Recompiling tessellation evaluation shader for program %d\n",
- prog->Id);
-
- bool found = false;
- const struct brw_tes_prog_key *old_key =
- brw_find_previous_compile(&brw->cache, BRW_CACHE_TES_PROG,
- key->program_string_id);
-
- if (!old_key) {
- perf_debug(" Didn't find previous compile in the shader cache for "
- "debug\n");
- return;
- }
-
- found |= brw_debug_recompile_sampler_key(brw, &old_key->tex, &key->tex);
- found |= key_debug(brw, "inputs read", old_key->inputs_read,
- key->inputs_read);
- found |= key_debug(brw, "patch inputs read", old_key->patch_inputs_read,
- key->patch_inputs_read);
-
- if (!found) {
- perf_debug(" Something else\n");
- }
-}
-
static bool
brw_codegen_tes_prog(struct brw_context *brw,
struct brw_program *tep,
@@ -119,7 +90,8 @@ brw_codegen_tes_prog(struct brw_context *brw,
if (unlikely(brw->perf_debug)) {
if (tep->compiled_once) {
- brw_tes_debug_recompile(brw, &tep->program, key);
+ brw_debug_recompile(brw, MESA_SHADER_TESS_EVAL, tep->program.Id,
+ key->program_string_id, key);
}
if (start_busy && !brw_bo_busy(brw->batch.last_bo)) {
perf_debug("TES 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 01ddf9a4851..12ab05c67c4 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -111,47 +111,6 @@ brw_vs_outputs_written(struct brw_context *brw, struct brw_vs_prog_key *key,
return outputs_written;
}
-static void
-brw_vs_debug_recompile(struct brw_context *brw, struct gl_program *prog,
- const struct brw_vs_prog_key *key)
-{
- perf_debug("Recompiling vertex shader for program %d\n", prog->Id);
-
- bool found = false;
- const struct brw_vs_prog_key *old_key =
- brw_find_previous_compile(&brw->cache, BRW_CACHE_VS_PROG,
- key->program_string_id);
-
- if (!old_key) {
- 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(brw, "Vertex attrib w/a flags",
- old_key->gl_attrib_wa_flags[i],
- key->gl_attrib_wa_flags[i]);
- }
-
- found |= key_debug(brw, "legacy user clipping",
- old_key->nr_userclip_plane_consts,
- key->nr_userclip_plane_consts);
-
- found |= key_debug(brw, "copy edgeflag",
- old_key->copy_edgeflag, key->copy_edgeflag);
- found |= key_debug(brw, "PointCoord replace",
- old_key->point_coord_replace, key->point_coord_replace);
- found |= key_debug(brw, "vertex color clamping",
- old_key->clamp_vertex_color, key->clamp_vertex_color);
-
- found |= brw_debug_recompile_sampler_key(brw, &old_key->tex, &key->tex);
-
- if (!found) {
- perf_debug(" Something else\n");
- }
-}
-
static bool
brw_codegen_vs_prog(struct brw_context *brw,
struct brw_program *vp,
@@ -237,7 +196,8 @@ brw_codegen_vs_prog(struct brw_context *brw,
if (unlikely(brw->perf_debug)) {
if (vp->compiled_once) {
- brw_vs_debug_recompile(brw, &vp->program, key);
+ brw_debug_recompile(brw, MESA_SHADER_VERTEX, vp->program.Id,
+ key->program_string_id, key);
}
if (start_busy && !brw_bo_busy(brw->batch.last_bo)) {
perf_debug("VS compile took %.03f ms and stalled the GPU\n",
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index d2d7974e841..996e7a9884c 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -68,70 +68,6 @@ assign_fs_binding_table_offsets(const struct gen_device_info *devinfo,
prog_data->base.binding_table.size_bytes = next_binding_table_offset * 4;
}
-static void
-brw_wm_debug_recompile(struct brw_context *brw, struct gl_program *prog,
- const struct brw_wm_prog_key *key)
-{
- perf_debug("Recompiling fragment shader for program %d\n", prog->Id);
-
- bool found = false;
- const struct brw_wm_prog_key *old_key =
- brw_find_previous_compile(&brw->cache, BRW_CACHE_FS_PROG,
- key->program_string_id);
-
- if (!old_key) {
- perf_debug(" Didn't find previous compile in the shader cache for debug\n");
- return;
- }
-
- found |= key_debug(brw, "alphatest, computed depth, depth test, or "
- "depth write",
- old_key->iz_lookup, key->iz_lookup);
- found |= key_debug(brw, "depth statistics",
- old_key->stats_wm, key->stats_wm);
- found |= key_debug(brw, "flat shading",
- old_key->flat_shade, key->flat_shade);
- found |= key_debug(brw, "number of color buffers",
- old_key->nr_color_regions, key->nr_color_regions);
- found |= key_debug(brw, "MRT alpha test",
- old_key->alpha_test_replicate_alpha,
- key->alpha_test_replicate_alpha);
- found |= key_debug(brw, "alpha to coverage",
- old_key->alpha_to_coverage, key->alpha_to_coverage);
- found |= key_debug(brw, "fragment color clamping",
- old_key->clamp_fragment_color, key->clamp_fragment_color);
- found |= key_debug(brw, "per-sample interpolation",
- old_key->persample_interp, key->persample_interp);
- found |= key_debug(brw, "multisampled FBO",
- old_key->multisample_fbo, key->multisample_fbo);
- found |= key_debug(brw, "frag coord adds sample pos",
- old_key->frag_coord_adds_sample_pos,
- key->frag_coord_adds_sample_pos);
- found |= key_debug(brw, "line smoothing",
- old_key->line_aa, key->line_aa);
- found |= key_debug(brw, "high quality derivatives",
- old_key->high_quality_derivatives,
- key->high_quality_derivatives);
- found |= key_debug(brw, "force dual color blending",
- old_key->force_dual_color_blend,
- key->force_dual_color_blend);
- found |= key_debug(brw, "coherent fb fetch",
- old_key->coherent_fb_fetch, key->coherent_fb_fetch);
-
- found |= key_debug(brw, "input slots valid",
- old_key->input_slots_valid, key->input_slots_valid);
- found |= key_debug(brw, "mrt alpha test function",
- old_key->alpha_test_func, key->alpha_test_func);
- found |= key_debug(brw, "mrt alpha test reference value",
- old_key->alpha_test_ref, key->alpha_test_ref);
-
- found |= brw_debug_recompile_sampler_key(brw, &old_key->tex, &key->tex);
-
- if (!found) {
- perf_debug(" Something else\n");
- }
-}
-
static bool
brw_codegen_wm_prog(struct brw_context *brw,
struct brw_program *fp,
@@ -203,8 +139,10 @@ brw_codegen_wm_prog(struct brw_context *brw,
}
if (unlikely(brw->perf_debug)) {
- if (fp->compiled_once)
- brw_wm_debug_recompile(brw, &fp->program, key);
+ if (fp->compiled_once) {
+ brw_debug_recompile(brw, MESA_SHADER_FRAGMENT, fp->program.Id,
+ key->program_string_id, key);
+ }
fp->compiled_once = true;
if (start_busy && !brw_bo_busy(brw->batch.last_bo)) {
@@ -232,65 +170,6 @@ brw_codegen_wm_prog(struct brw_context *brw,
return true;
}
-bool
-brw_debug_recompile_sampler_key(struct brw_context *brw,
- 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 < MAX_SAMPLERS; i++) {
- found |= key_debug(brw, "EXT_texture_swizzle or DEPTH_TEXTURE_MODE",
- old_key->swizzles[i], key->swizzles[i]);
- }
- found |= key_debug(brw, "GL_CLAMP enabled on any texture unit's 1st coordinate",
- old_key->gl_clamp_mask[0], key->gl_clamp_mask[0]);
- found |= key_debug(brw, "GL_CLAMP enabled on any texture unit's 2nd coordinate",
- old_key->gl_clamp_mask[1], key->gl_clamp_mask[1]);
- found |= key_debug(brw, "GL_CLAMP enabled on any texture unit's 3rd coordinate",
- old_key->gl_clamp_mask[2], key->gl_clamp_mask[2]);
- found |= key_debug(brw, "gather channel quirk on any texture unit",
- old_key->gather_channel_quirk_mask, key->gather_channel_quirk_mask);
- found |= key_debug(brw, "compressed multisample layout",
- old_key->compressed_multisample_layout_mask,
- key->compressed_multisample_layout_mask);
- found |= key_debug(brw, "16x msaa",
- old_key->msaa_16,
- key->msaa_16);
-
- found |= key_debug(brw, "y_uv image bound",
- old_key->y_uv_image_mask,
- key->y_uv_image_mask);
- found |= key_debug(brw, "y_u_v image bound",
- old_key->y_u_v_image_mask,
- key->y_u_v_image_mask);
- found |= key_debug(brw, "yx_xuxv image bound",
- old_key->yx_xuxv_image_mask,
- key->yx_xuxv_image_mask);
- found |= key_debug(brw, "xy_uxvx image bound",
- old_key->xy_uxvx_image_mask,
- key->xy_uxvx_image_mask);
- found |= key_debug(brw, "ayuv image bound",
- old_key->ayuv_image_mask,
- key->ayuv_image_mask);
- found |= key_debug(brw, "xyuv image bound",
- old_key->xyuv_image_mask,
- key->xyuv_image_mask);
-
- for (unsigned int i = 0; i < MAX_SAMPLERS; i++) {
- found |= key_debug(brw, "textureGather workarounds",
- old_key->gen6_gather_wa[i], key->gen6_gather_wa[i]);
- }
-
- for (unsigned int i = 0; i < MAX_SAMPLERS; i++) {
- found |= key_debug_float(brw, "scale factor",
- old_key->scale_factors[i],
- key->scale_factors[i]);
- }
-
- return found;
-}
-
static uint8_t
gen6_gather_workaround(GLenum internalformat)
{