pan/bi: Add a noopt debug option

To rule out buggy optimization passes when debugging.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12328>
This commit is contained in:
Alyssa Rosenzweig 2021-08-11 10:31:48 -04:00 committed by Marge Bot
parent ff03f096bf
commit 3958f00215
2 changed files with 19 additions and 11 deletions

View File

@ -38,6 +38,7 @@
#define BIFROST_DBG_NOSCHED 0x0020 #define BIFROST_DBG_NOSCHED 0x0020
#define BIFROST_DBG_INORDER 0x0040 #define BIFROST_DBG_INORDER 0x0040
#define BIFROST_DBG_NOVALIDATE 0x0080 #define BIFROST_DBG_NOVALIDATE 0x0080
#define BIFROST_DBG_NOOPT 0x0100
extern int bifrost_debug; extern int bifrost_debug;

View File

@ -46,6 +46,7 @@ static const struct debug_named_value bifrost_debug_options[] = {
{"nosched", BIFROST_DBG_NOSCHED, "Force trivial bundling"}, {"nosched", BIFROST_DBG_NOSCHED, "Force trivial bundling"},
{"inorder", BIFROST_DBG_INORDER, "Force in-order bundling"}, {"inorder", BIFROST_DBG_INORDER, "Force in-order bundling"},
{"novalidate",BIFROST_DBG_NOVALIDATE, "Skip IR validation"}, {"novalidate",BIFROST_DBG_NOVALIDATE, "Skip IR validation"},
{"noopt", BIFROST_DBG_NOOPT, "Skip optimization passes"},
DEBUG_NAMED_VALUE_END DEBUG_NAMED_VALUE_END
}; };
@ -3676,17 +3677,19 @@ bifrost_compile_shader_nir(nir_shader *nir,
bi_emit_atest(&b, bi_zero()); bi_emit_atest(&b, bi_zero());
} }
bool optimize = !(bifrost_debug & BIFROST_DBG_NOOPT);
/* Runs before constant folding */ /* Runs before constant folding */
bi_lower_swizzle(ctx); bi_lower_swizzle(ctx);
bi_validate(ctx, "Early lowering"); bi_validate(ctx, "Early lowering");
/* Runs before copy prop */ /* Runs before copy prop */
if (!ctx->inputs->no_ubo_to_push) { if (optimize && !ctx->inputs->no_ubo_to_push) {
bi_opt_push_ubo(ctx); bi_opt_push_ubo(ctx);
} }
if (likely(optimize)) {
bi_opt_constant_fold(ctx); bi_opt_constant_fold(ctx);
bi_opt_copy_prop(ctx); bi_opt_copy_prop(ctx);
bi_opt_mod_prop_forward(ctx); bi_opt_mod_prop_forward(ctx);
bi_opt_mod_prop_backward(ctx); bi_opt_mod_prop_backward(ctx);
@ -3694,6 +3697,7 @@ bifrost_compile_shader_nir(nir_shader *nir,
bi_opt_cse(ctx); bi_opt_cse(ctx);
bi_opt_dead_code_eliminate(ctx); bi_opt_dead_code_eliminate(ctx);
bi_validate(ctx, "Optimization passes"); bi_validate(ctx, "Optimization passes");
}
bi_foreach_block(ctx, block) { bi_foreach_block(ctx, block) {
bi_lower_branch(block); bi_lower_branch(block);
@ -3710,7 +3714,10 @@ bifrost_compile_shader_nir(nir_shader *nir,
bi_validate(ctx, "Late lowering"); bi_validate(ctx, "Late lowering");
bi_register_allocate(ctx); bi_register_allocate(ctx);
if (likely(optimize))
bi_opt_post_ra(ctx); bi_opt_post_ra(ctx);
if (bifrost_debug & BIFROST_DBG_SHADERS && !skip_internal) if (bifrost_debug & BIFROST_DBG_SHADERS && !skip_internal)
bi_print_shader(ctx, stdout); bi_print_shader(ctx, stdout);