On Mon, Jun 26, 2017 at 10:09 AM, Nicolai Hähnle <nhaeh...@gmail.com> wrote: > From: Nicolai Hähnle <nicolai.haeh...@amd.com> >
this is nicer than my old approach of just hacking in nir_print_shader() calls at various points and recompiling ;-) I suppose one thing that would be clever is if you could give a list of comma separated lowering stage names to control *which* stages you get prints.. either way, Reviewed-by: Rob Clark <robdcl...@gmail.com> > --- > src/compiler/nir/nir.h | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h > index ab7ba14..d1b90cb 100644 > --- a/src/compiler/nir/nir.h > +++ b/src/compiler/nir/nir.h > @@ -2301,47 +2301,66 @@ void nir_metadata_check_validation_flag(nir_shader > *shader); > > static inline bool > should_clone_nir(void) > { > static int should_clone = -1; > if (should_clone < 0) > should_clone = env_var_as_boolean("NIR_TEST_CLONE", false); > > return should_clone; > } > + > +static inline bool > +should_print_nir(void) > +{ > + static int should_print = -1; > + if (should_print < 0) > + should_print = env_var_as_boolean("NIR_PRINT", false); > + > + return should_print; > +} > #else > static inline void nir_validate_shader(nir_shader *shader) { (void) shader; } > static inline void nir_metadata_set_validation_flag(nir_shader *shader) { > (void) shader; } > static inline void nir_metadata_check_validation_flag(nir_shader *shader) { > (void) shader; } > static inline bool should_clone_nir(void) { return false; } > +static inline bool should_print_nir(void) { return false; } > #endif /* DEBUG */ > > #define _PASS(nir, do_pass) do { \ > do_pass \ > nir_validate_shader(nir); \ > if (should_clone_nir()) { \ > nir_shader *clone = nir_shader_clone(ralloc_parent(nir), nir); \ > ralloc_free(nir); \ > nir = clone; \ > } \ > } while (0) > > #define NIR_PASS(progress, nir, pass, ...) _PASS(nir, \ > nir_metadata_set_validation_flag(nir); \ > + if (should_print_nir()) \ > + printf("%s\n", #pass); \ > if (pass(nir, ##__VA_ARGS__)) { \ > progress = true; \ > + if (should_print_nir()) \ > + nir_print_shader(nir, stdout); \ > nir_metadata_check_validation_flag(nir); \ > } \ > ) > > #define NIR_PASS_V(nir, pass, ...) _PASS(nir, \ > + if (should_print_nir()) \ > + printf("%s\n", #pass); \ > pass(nir, ##__VA_ARGS__); \ > + if (should_print_nir()) \ > + nir_print_shader(nir, stdout); \ > ) > > void nir_calc_dominance_impl(nir_function_impl *impl); > void nir_calc_dominance(nir_shader *shader); > > nir_block *nir_dominance_lca(nir_block *b1, nir_block *b2); > bool nir_block_dominates(nir_block *parent, nir_block *child); > > void nir_dump_dom_tree_impl(nir_function_impl *impl, FILE *fp); > void nir_dump_dom_tree(nir_shader *shader, FILE *fp); > -- > 2.9.3 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev