st/mesa: add ST_DEBUG=nir to print NIR shaders
authorMarek Olšák <marek.olsak@amd.com>
Sat, 9 Nov 2019 00:40:44 +0000 (19:40 -0500)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 12 Nov 2019 00:45:10 +0000 (19:45 -0500)
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/mesa/state_tracker/st_debug.c
src/mesa/state_tracker/st_program.c

index 95564cbc3643312acaca00a5eb515d30cf3da5fb..66085b646c53f5f58045add03bdcffca2371790e 100644 (file)
@@ -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 },
index 41508710783e862bc48ba7011073b71e19411f48..9fa12c9f65db6c21d463f8e1a0436214bac7965f 100644 (file)
@@ -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;