radeonsi: print shader-db stats with AMD_DEBUG=vs,ps,stats

Reviewed-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22833>
This commit is contained in:
Marek Olšák 2023-04-13 21:07:31 -04:00 committed by Marge Bot
parent 2bf839f0ae
commit 5066623b79
4 changed files with 22 additions and 1 deletions

View file

@ -46,6 +46,7 @@ static const struct debug_named_value radeonsi_debug_options[] = {
{"initaco", DBG(INIT_ACO), "Print initial ACO IR before optimizations"},
{"aco", DBG(ACO), "Print final ACO IR"},
{"asm", DBG(ASM), "Print final shaders in asm"},
{"stats", DBG(STATS), "Print shader-db stats to stderr"},
/* Shader compiler options the shader cache should be aware of: */
{"w32ge", DBG(W32_GE), "Use Wave32 for vertex, tessellation, and geometry shaders."},

View file

@ -181,6 +181,7 @@ enum
DBG_INIT_ACO,
DBG_ACO,
DBG_ASM,
DBG_STATS,
/* Shader compiler options the shader cache should be aware of: */
DBG_FS_CORRECT_DERIVS_AFTER_KILL,

View file

@ -1176,6 +1176,7 @@ bool si_can_dump_shader(struct si_screen *sscreen, gl_shader_stage stage,
[SI_DUMP_INIT_ACO_IR] = DBG(INIT_ACO),
[SI_DUMP_ACO_IR] = DBG(ACO),
[SI_DUMP_ASM] = DBG(ASM),
[SI_DUMP_STATS] = DBG(STATS),
[SI_DUMP_ALWAYS] = DBG(VS) | DBG(TCS) | DBG(TES) | DBG(GS) | DBG(PS) | DBG(CS),
};
assert(dump_type < ARRAY_SIZE(filter));
@ -2556,6 +2557,14 @@ si_set_spi_ps_input_config(struct si_shader *shader)
shader->config.spi_ps_input_addr = shader->config.spi_ps_input_ena;
}
static void
debug_message_stderr(void *data, unsigned *id, enum util_debug_type ptype,
const char *fmt, va_list args)
{
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
}
bool si_compile_shader(struct si_screen *sscreen, struct ac_llvm_compiler *compiler,
struct si_shader *shader, struct util_debug_callback *debug)
{
@ -2730,7 +2739,16 @@ bool si_compile_shader(struct si_screen *sscreen, struct ac_llvm_compiler *compi
}
si_calculate_max_simd_waves(shader);
si_shader_dump_stats_for_shader_db(sscreen, shader, debug);
if (si_can_dump_shader(sscreen, sel->stage, SI_DUMP_STATS)) {
struct util_debug_callback out_stderr = {
.debug_message = debug_message_stderr,
};
si_shader_dump_stats_for_shader_db(sscreen, shader, &out_stderr);
} else {
si_shader_dump_stats_for_shader_db(sscreen, shader, debug);
}
out:
if (free_nir)

View file

@ -313,6 +313,7 @@ enum si_shader_dump_type {
SI_DUMP_INIT_ACO_IR, /* initial ACO IR before optimizations */
SI_DUMP_ACO_IR, /* final ACO IR */
SI_DUMP_ASM, /* final asm shaders */
SI_DUMP_STATS, /* print statistics as shader-db */
SI_DUMP_ALWAYS,
};