Path: blob/21.2-virgl/src/intel/compiler/brw_debug_recompile.c
4550 views
/*1* Copyright © 2019 Intel Corporation2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice shall be included11* in all copies or substantial portions of the Software.12*13* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS14* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL16* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER17* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING18* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER19* DEALINGS IN THE SOFTWARE.20*/2122/**23* @file brw_debug_recompiles.c24*/2526#include <stdio.h>2728#include "brw_compiler.h"2930static bool31key_debug(const struct brw_compiler *c, void *log,32const char *name, int a, int b)33{34if (a != b) {35c->shader_perf_log(log, " %s %d->%d\n", name, a, b);36return true;37}38return false;39}4041static bool42key_debug_float(const struct brw_compiler *c, void *log,43const char *name, float a, float b)44{45if (a != b) {46c->shader_perf_log(log, " %s %f->%f\n", name, a, b);47return true;48}49return false;50}5152#define check(name, field) \53key_debug(c, log, name, old_key->field, key->field)54#define check_float(name, field) \55key_debug_float(c, log, name, old_key->field, key->field)5657static bool58debug_sampler_recompile(const struct brw_compiler *c, void *log,59const struct brw_sampler_prog_key_data *old_key,60const struct brw_sampler_prog_key_data *key)61{62bool found = false;6364found |= check("gather channel quirk", gather_channel_quirk_mask);65found |= check("compressed multisample layout",66compressed_multisample_layout_mask);67found |= check("16x msaa", msaa_16);68found |= check("y_uv image bound", y_uv_image_mask);69found |= check("y_u_v image bound", y_u_v_image_mask);70found |= check("yx_xuxv image bound", yx_xuxv_image_mask);71found |= check("xy_uxvx image bound", xy_uxvx_image_mask);72found |= check("ayuv image bound", ayuv_image_mask);73found |= check("xyuv image bound", xyuv_image_mask);7475for (unsigned i = 0; i < MAX_SAMPLERS; i++) {76found |= check("EXT_texture_swizzle or DEPTH_TEXTURE_MODE", swizzles[i]);77found |= check("textureGather workarounds", gfx6_gather_wa[i]);78found |= check_float("scale factor", scale_factors[i]);79}8081for (unsigned i = 0; i < 3; i++) {82found |= check("GL_CLAMP enabled on any texture unit", gl_clamp_mask[i]);83}8485return found;86}8788static bool89debug_base_recompile(const struct brw_compiler *c, void *log,90const struct brw_base_prog_key *old_key,91const struct brw_base_prog_key *key)92{93return debug_sampler_recompile(c, log, &old_key->tex, &key->tex);94}9596static void97debug_vs_recompile(const struct brw_compiler *c, void *log,98const struct brw_vs_prog_key *old_key,99const struct brw_vs_prog_key *key)100{101bool found = debug_base_recompile(c, log, &old_key->base, &key->base);102103for (unsigned i = 0; i < VERT_ATTRIB_MAX; i++) {104found |= check("vertex attrib w/a flags", gl_attrib_wa_flags[i]);105}106107found |= check("legacy user clipping", nr_userclip_plane_consts);108found |= check("copy edgeflag", copy_edgeflag);109found |= check("pointcoord replace", point_coord_replace);110found |= check("vertex color clamping", clamp_vertex_color);111112if (!found) {113c->shader_perf_log(log, " something else\n");114}115}116117static void118debug_tcs_recompile(const struct brw_compiler *c, void *log,119const struct brw_tcs_prog_key *old_key,120const struct brw_tcs_prog_key *key)121{122bool found = debug_base_recompile(c, log, &old_key->base, &key->base);123124found |= check("input vertices", input_vertices);125found |= check("outputs written", outputs_written);126found |= check("patch outputs written", patch_outputs_written);127found |= check("tes primitive mode", tes_primitive_mode);128found |= check("quads and equal_spacing workaround", quads_workaround);129130if (!found) {131c->shader_perf_log(log, " something else\n");132}133}134135static void136debug_tes_recompile(const struct brw_compiler *c, void *log,137const struct brw_tes_prog_key *old_key,138const struct brw_tes_prog_key *key)139{140bool found = debug_base_recompile(c, log, &old_key->base, &key->base);141142found |= check("inputs read", inputs_read);143found |= check("patch inputs read", patch_inputs_read);144145if (!found) {146c->shader_perf_log(log, " something else\n");147}148}149150static void151debug_gs_recompile(const struct brw_compiler *c, void *log,152const struct brw_gs_prog_key *old_key,153const struct brw_gs_prog_key *key)154{155bool found = debug_base_recompile(c, log, &old_key->base, &key->base);156157if (!found) {158c->shader_perf_log(log, " something else\n");159}160}161162static void163debug_fs_recompile(const struct brw_compiler *c, void *log,164const struct brw_wm_prog_key *old_key,165const struct brw_wm_prog_key *key)166{167bool found = false;168169found |= check("alphatest, computed depth, depth test, or depth write",170iz_lookup);171found |= check("depth statistics", stats_wm);172found |= check("flat shading", flat_shade);173found |= check("number of color buffers", nr_color_regions);174found |= check("MRT alpha test", alpha_test_replicate_alpha);175found |= check("alpha to coverage", alpha_to_coverage);176found |= check("fragment color clamping", clamp_fragment_color);177found |= check("per-sample interpolation", persample_interp);178found |= check("multisampled FBO", multisample_fbo);179found |= check("frag coord adds sample pos", frag_coord_adds_sample_pos);180found |= check("line smoothing", line_aa);181found |= check("high quality derivatives", high_quality_derivatives);182found |= check("force dual color blending", force_dual_color_blend);183found |= check("coherent fb fetch", coherent_fb_fetch);184185found |= check("input slots valid", input_slots_valid);186found |= check("mrt alpha test function", alpha_test_func);187found |= check("mrt alpha test reference value", alpha_test_ref);188189found |= debug_base_recompile(c, log, &old_key->base, &key->base);190191if (!found) {192c->shader_perf_log(log, " something else\n");193}194}195196static void197debug_cs_recompile(const struct brw_compiler *c, void *log,198const struct brw_cs_prog_key *old_key,199const struct brw_cs_prog_key *key)200{201bool found = debug_base_recompile(c, log, &old_key->base, &key->base);202203if (!found) {204c->shader_perf_log(log, " something else\n");205}206}207208void209brw_debug_key_recompile(const struct brw_compiler *c, void *log,210gl_shader_stage stage,211const struct brw_base_prog_key *old_key,212const struct brw_base_prog_key *key)213{214if (!old_key) {215c->shader_perf_log(log, " No previous compile found...\n");216return;217}218219switch (stage) {220case MESA_SHADER_VERTEX:221debug_vs_recompile(c, log, (const struct brw_vs_prog_key *)old_key,222(const struct brw_vs_prog_key *)key);223break;224case MESA_SHADER_TESS_CTRL:225debug_tcs_recompile(c, log, (const struct brw_tcs_prog_key *)old_key,226(const struct brw_tcs_prog_key *)key);227break;228case MESA_SHADER_TESS_EVAL:229debug_tes_recompile(c, log, (const struct brw_tes_prog_key *)old_key,230(const struct brw_tes_prog_key *)key);231break;232case MESA_SHADER_GEOMETRY:233debug_gs_recompile(c, log, (const struct brw_gs_prog_key *)old_key,234(const struct brw_gs_prog_key *)key);235break;236case MESA_SHADER_FRAGMENT:237debug_fs_recompile(c, log, (const struct brw_wm_prog_key *)old_key,238(const struct brw_wm_prog_key *)key);239break;240case MESA_SHADER_COMPUTE:241debug_cs_recompile(c, log, (const struct brw_cs_prog_key *)old_key,242(const struct brw_cs_prog_key *)key);243break;244default:245break;246}247}248249250