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_base_recompile(const struct brw_compiler
*c
, void *log
,
91 const struct brw_base_prog_key
*old_key
,
92 const struct brw_base_prog_key
*key
)
94 return debug_sampler_recompile(c
, log
, &old_key
->tex
, &key
->tex
);
98 debug_vs_recompile(const struct brw_compiler
*c
, void *log
,
99 const struct brw_vs_prog_key
*old_key
,
100 const struct brw_vs_prog_key
*key
)
102 bool found
= debug_base_recompile(c
, log
, &old_key
->base
, &key
->base
);
104 for (unsigned i
= 0; i
< VERT_ATTRIB_MAX
; i
++) {
105 found
|= check("vertex attrib w/a flags", gl_attrib_wa_flags
[i
]);
108 found
|= check("legacy user clipping", nr_userclip_plane_consts
);
109 found
|= check("copy edgeflag", copy_edgeflag
);
110 found
|= check("pointcoord replace", point_coord_replace
);
111 found
|= check("vertex color clamping", clamp_vertex_color
);
114 c
->shader_perf_log(log
, " something else\n");
119 debug_tcs_recompile(const struct brw_compiler
*c
, void *log
,
120 const struct brw_tcs_prog_key
*old_key
,
121 const struct brw_tcs_prog_key
*key
)
123 bool found
= debug_base_recompile(c
, log
, &old_key
->base
, &key
->base
);
125 found
|= check("input vertices", input_vertices
);
126 found
|= check("outputs written", outputs_written
);
127 found
|= check("patch outputs written", patch_outputs_written
);
128 found
|= check("tes primitive mode", tes_primitive_mode
);
129 found
|= check("quads and equal_spacing workaround", quads_workaround
);
132 c
->shader_perf_log(log
, " something else\n");
137 debug_tes_recompile(const struct brw_compiler
*c
, void *log
,
138 const struct brw_tes_prog_key
*old_key
,
139 const struct brw_tes_prog_key
*key
)
141 bool found
= debug_base_recompile(c
, log
, &old_key
->base
, &key
->base
);
143 found
|= check("inputs read", inputs_read
);
144 found
|= check("patch inputs read", patch_inputs_read
);
147 c
->shader_perf_log(log
, " something else\n");
152 debug_gs_recompile(const struct brw_compiler
*c
, void *log
,
153 const struct brw_gs_prog_key
*old_key
,
154 const struct brw_gs_prog_key
*key
)
156 bool found
= debug_base_recompile(c
, log
, &old_key
->base
, &key
->base
);
159 c
->shader_perf_log(log
, " something else\n");
164 debug_fs_recompile(const struct brw_compiler
*c
, void *log
,
165 const struct brw_wm_prog_key
*old_key
,
166 const struct brw_wm_prog_key
*key
)
170 found
|= check("alphatest, computed depth, depth test, or depth write",
172 found
|= check("depth statistics", stats_wm
);
173 found
|= check("flat shading", flat_shade
);
174 found
|= check("number of color buffers", nr_color_regions
);
175 found
|= check("MRT alpha test", alpha_test_replicate_alpha
);
176 found
|= check("alpha to coverage", alpha_to_coverage
);
177 found
|= check("fragment color clamping", clamp_fragment_color
);
178 found
|= check("per-sample interpolation", persample_interp
);
179 found
|= check("multisampled FBO", multisample_fbo
);
180 found
|= check("frag coord adds sample pos", frag_coord_adds_sample_pos
);
181 found
|= check("line smoothing", line_aa
);
182 found
|= check("high quality derivatives", high_quality_derivatives
);
183 found
|= check("force dual color blending", force_dual_color_blend
);
184 found
|= check("coherent fb fetch", coherent_fb_fetch
);
186 found
|= check("input slots valid", input_slots_valid
);
187 found
|= check("mrt alpha test function", alpha_test_func
);
188 found
|= check("mrt alpha test reference value", alpha_test_ref
);
190 found
|= debug_base_recompile(c
, log
, &old_key
->base
, &key
->base
);
193 c
->shader_perf_log(log
, " something else\n");
198 debug_cs_recompile(const struct brw_compiler
*c
, void *log
,
199 const struct brw_cs_prog_key
*old_key
,
200 const struct brw_cs_prog_key
*key
)
202 bool found
= debug_base_recompile(c
, log
, &old_key
->base
, &key
->base
);
205 c
->shader_perf_log(log
, " something else\n");
210 brw_debug_key_recompile(const struct brw_compiler
*c
, void *log
,
211 gl_shader_stage stage
,
212 const struct brw_base_prog_key
*old_key
,
213 const struct brw_base_prog_key
*key
)
216 c
->shader_perf_log(log
, " No previous compile found...\n");
221 case MESA_SHADER_VERTEX
:
222 debug_vs_recompile(c
, log
, (const struct brw_vs_prog_key
*)old_key
,
223 (const struct brw_vs_prog_key
*)key
);
225 case MESA_SHADER_TESS_CTRL
:
226 debug_tcs_recompile(c
, log
, (const struct brw_tcs_prog_key
*)old_key
,
227 (const struct brw_tcs_prog_key
*)key
);
229 case MESA_SHADER_TESS_EVAL
:
230 debug_tes_recompile(c
, log
, (const struct brw_tes_prog_key
*)old_key
,
231 (const struct brw_tes_prog_key
*)key
);
233 case MESA_SHADER_GEOMETRY
:
234 debug_gs_recompile(c
, log
, (const struct brw_gs_prog_key
*)old_key
,
235 (const struct brw_gs_prog_key
*)key
);
237 case MESA_SHADER_FRAGMENT
:
238 debug_fs_recompile(c
, log
, (const struct brw_wm_prog_key
*)old_key
,
239 (const struct brw_wm_prog_key
*)key
);
241 case MESA_SHADER_COMPUTE
:
242 debug_cs_recompile(c
, log
, (const struct brw_cs_prog_key
*)old_key
,
243 (const struct brw_cs_prog_key
*)key
);