2 * Copyright © 2019 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
24 * @file brw_debug_recompiles.c
29 #include "brw_compiler.h"
32 key_debug(const struct brw_compiler
*c
, void *log
,
33 const char *name
, int a
, int b
)
36 c
->shader_perf_log(log
, " %s %d->%d\n", name
, a
, b
);
43 key_debug_float(const struct brw_compiler
*c
, void *log
,
44 const char *name
, float a
, float b
)
47 c
->shader_perf_log(log
, " %s %f->%f\n", name
, a
, b
);
53 #define check(name, field) \
54 key_debug(c, log, name, old_key->field, key->field)
55 #define check_float(name, field) \
56 key_debug_float(c, log, name, old_key->field, key->field)
59 debug_sampler_recompile(const struct brw_compiler
*c
, void *log
,
60 const struct brw_sampler_prog_key_data
*old_key
,
61 const struct brw_sampler_prog_key_data
*key
)
65 found
|= check("gather channel quirk", gather_channel_quirk_mask
);
66 found
|= check("compressed multisample layout",
67 compressed_multisample_layout_mask
);
68 found
|= check("16x msaa", msaa_16
);
69 found
|= check("y_uv image bound", y_uv_image_mask
);
70 found
|= check("y_u_v image bound", y_u_v_image_mask
);
71 found
|= check("yx_xuxv image bound", yx_xuxv_image_mask
);
72 found
|= check("xy_uxvx image bound", xy_uxvx_image_mask
);
73 found
|= check("ayuv image bound", ayuv_image_mask
);
74 found
|= check("xyuv image bound", xyuv_image_mask
);
76 for (unsigned i
= 0; i
< MAX_SAMPLERS
; i
++) {
77 found
|= check("EXT_texture_swizzle or DEPTH_TEXTURE_MODE", swizzles
[i
]);
78 found
|= check("textureGather workarounds", gen6_gather_wa
[i
]);
79 found
|= check_float("scale factor", scale_factors
[i
]);
82 for (unsigned i
= 0; i
< 3; i
++) {
83 found
|= check("GL_CLAMP enabled on any texture unit", gl_clamp_mask
[i
]);
90 debug_vs_recompile(const struct brw_compiler
*c
, void *log
,
91 const struct brw_vs_prog_key
*old_key
,
92 const struct brw_vs_prog_key
*key
)
94 bool found
= debug_sampler_recompile(c
, log
, &old_key
->tex
, &key
->tex
);
96 for (unsigned i
= 0; i
< VERT_ATTRIB_MAX
; i
++) {
97 found
|= check("vertex attrib w/a flags", gl_attrib_wa_flags
[i
]);
100 found
|= check("legacy user clipping", nr_userclip_plane_consts
);
101 found
|= check("copy edgeflag", copy_edgeflag
);
102 found
|= check("pointcoord replace", point_coord_replace
);
103 found
|= check("vertex color clamping", clamp_vertex_color
);
106 c
->shader_perf_log(log
, " something else\n");
111 debug_tcs_recompile(const struct brw_compiler
*c
, void *log
,
112 const struct brw_tcs_prog_key
*old_key
,
113 const struct brw_tcs_prog_key
*key
)
115 bool found
= debug_sampler_recompile(c
, log
, &old_key
->tex
, &key
->tex
);
117 found
|= check("input vertices", input_vertices
);
118 found
|= check("outputs written", outputs_written
);
119 found
|= check("patch outputs written", patch_outputs_written
);
120 found
|= check("tes primitive mode", tes_primitive_mode
);
121 found
|= check("quads and equal_spacing workaround", quads_workaround
);
124 c
->shader_perf_log(log
, " something else\n");
129 debug_tes_recompile(const struct brw_compiler
*c
, void *log
,
130 const struct brw_tes_prog_key
*old_key
,
131 const struct brw_tes_prog_key
*key
)
133 bool found
= debug_sampler_recompile(c
, log
, &old_key
->tex
, &key
->tex
);
135 found
|= check("inputs read", inputs_read
);
136 found
|= check("patch inputs read", patch_inputs_read
);
139 c
->shader_perf_log(log
, " something else\n");
144 debug_gs_recompile(const struct brw_compiler
*c
, void *log
,
145 const struct brw_gs_prog_key
*old_key
,
146 const struct brw_gs_prog_key
*key
)
148 bool found
= debug_sampler_recompile(c
, log
, &old_key
->tex
, &key
->tex
);
151 c
->shader_perf_log(log
, " something else\n");
156 debug_fs_recompile(const struct brw_compiler
*c
, void *log
,
157 const struct brw_wm_prog_key
*old_key
,
158 const struct brw_wm_prog_key
*key
)
162 found
|= check("alphatest, computed depth, depth test, or depth write",
164 found
|= check("depth statistics", stats_wm
);
165 found
|= check("flat shading", flat_shade
);
166 found
|= check("number of color buffers", nr_color_regions
);
167 found
|= check("MRT alpha test", alpha_test_replicate_alpha
);
168 found
|= check("alpha to coverage", alpha_to_coverage
);
169 found
|= check("fragment color clamping", clamp_fragment_color
);
170 found
|= check("per-sample interpolation", persample_interp
);
171 found
|= check("multisampled FBO", multisample_fbo
);
172 found
|= check("frag coord adds sample pos", frag_coord_adds_sample_pos
);
173 found
|= check("line smoothing", line_aa
);
174 found
|= check("high quality derivatives", high_quality_derivatives
);
175 found
|= check("force dual color blending", force_dual_color_blend
);
176 found
|= check("coherent fb fetch", coherent_fb_fetch
);
178 found
|= check("input slots valid", input_slots_valid
);
179 found
|= check("mrt alpha test function", alpha_test_func
);
180 found
|= check("mrt alpha test reference value", alpha_test_ref
);
182 found
|= debug_sampler_recompile(c
, log
, &old_key
->tex
, &key
->tex
);
185 c
->shader_perf_log(log
, " something else\n");
190 debug_cs_recompile(const struct brw_compiler
*c
, void *log
,
191 const struct brw_cs_prog_key
*old_key
,
192 const struct brw_cs_prog_key
*key
)
194 bool found
= debug_sampler_recompile(c
, log
, &old_key
->tex
, &key
->tex
);
197 c
->shader_perf_log(log
, " something else\n");
202 brw_debug_key_recompile(const struct brw_compiler
*c
, void *log
,
203 gl_shader_stage stage
,
204 const void *old_key
, const void *key
)
207 c
->shader_perf_log(log
, " No previous compile found...\n");
212 case MESA_SHADER_VERTEX
:
213 debug_vs_recompile(c
, log
, old_key
, key
);
215 case MESA_SHADER_TESS_CTRL
:
216 debug_tcs_recompile(c
, log
, old_key
, key
);
218 case MESA_SHADER_TESS_EVAL
:
219 debug_tes_recompile(c
, log
, old_key
, key
);
221 case MESA_SHADER_GEOMETRY
:
222 debug_gs_recompile(c
, log
, old_key
, key
);
224 case MESA_SHADER_FRAGMENT
:
225 debug_fs_recompile(c
, log
, old_key
, key
);
227 case MESA_SHADER_COMPUTE
:
228 debug_cs_recompile(c
, log
, old_key
, key
);