From d29a33286260ac2de3b7718d9133923c40eeb1f7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 8 Nov 2019 19:40:44 -0500 Subject: [PATCH] st/mesa: add ST_DEBUG=nir to print NIR shaders Reviewed-by: Timothy Arceri --- src/mesa/state_tracker/st_debug.c | 1 + src/mesa/state_tracker/st_program.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_debug.c b/src/mesa/state_tracker/st_debug.c index 95564cbc364..66085b646c5 100644 --- a/src/mesa/state_tracker/st_debug.c +++ b/src/mesa/state_tracker/st_debug.c @@ -47,6 +47,7 @@ int ST_DEBUG = 0; static const struct debug_named_value st_debug_flags[] = { { "mesa", DEBUG_MESA, NULL }, { "tgsi", DEBUG_PRINT_IR, NULL }, + { "nir", DEBUG_PRINT_IR, NULL }, { "constants",DEBUG_CONSTANTS, NULL }, { "pipe", DEBUG_PIPE, NULL }, { "tex", DEBUG_TEX, NULL }, diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 41508710783..9fa12c9f65d 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -741,6 +741,9 @@ st_create_vp_variant(struct st_context *st, nir_shader_get_entrypoint(state.ir.nir)); } + if (ST_DEBUG & DEBUG_PRINT_IR) + nir_print_shader(state.ir.nir, stderr); + vpv->driver_shader = pipe->create_vs_state(pipe, &state); /* When generating a NIR program, we usually don't have TGSI tokens. @@ -1359,6 +1362,9 @@ st_create_fp_variant(struct st_context *st, screen->finalize_nir(screen, state.ir.nir, false); } + if (ST_DEBUG & DEBUG_PRINT_IR) + nir_print_shader(state.ir.nir, stderr); + variant->driver_shader = pipe->create_fs_state(pipe, &state); variant->key = *key; @@ -1774,7 +1780,10 @@ st_get_common_variant(struct st_context *st, st_finalize_nir(st, &prog->Base, prog->shader_program, state.ir.nir, true); } - } else { + + if (ST_DEBUG & DEBUG_PRINT_IR) + nir_print_shader(state.ir.nir, stderr); + } else { if (key->lower_depth_clamp) { struct gl_program_parameter_list *params = prog->Base.Parameters; -- 2.30.2