From 93db59e0664fbbc9d711b43145f18e6e6bce16fa Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Wed, 26 Aug 2020 14:22:07 -0700 Subject: [PATCH] nir: Add an internal flag to shader_info Don't print the shader if it's marked internal, unless NIR_PRINT has been explicitly set to 2 (or higher). Reviewed-by: Jason Ekstrand Part-of: --- src/compiler/nir/nir.h | 17 ++++++++++------- src/compiler/shader_info.h | 3 +++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 1741f4f9bbf..368e7be7e2c 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -3937,11 +3937,14 @@ should_serialize_deserialize_nir(void) } static inline bool -should_print_nir(void) +should_print_nir(nir_shader *shader) { static int should_print = -1; if (should_print < 0) - should_print = env_var_as_boolean("NIR_PRINT", false); + should_print = env_var_as_unsigned("NIR_PRINT", 0); + + if (should_print == 1) + return !shader->info.internal; return should_print; } @@ -3953,7 +3956,7 @@ static inline void nir_metadata_check_validation_flag(nir_shader *shader) { (voi static inline bool should_skip_nir(UNUSED const char *pass_name) { return false; } static inline bool should_clone_nir(void) { return false; } static inline bool should_serialize_deserialize_nir(void) { return false; } -static inline bool should_print_nir(void) { return false; } +static inline bool should_print_nir(nir_shader *shader) { return false; } #endif /* NDEBUG */ #define _PASS(pass, nir, do_pass) do { \ @@ -3974,21 +3977,21 @@ static inline bool should_print_nir(void) { return false; } #define NIR_PASS(progress, nir, pass, ...) _PASS(pass, nir, \ nir_metadata_set_validation_flag(nir); \ - if (should_print_nir()) \ + if (should_print_nir(nir)) \ printf("%s\n", #pass); \ if (pass(nir, ##__VA_ARGS__)) { \ progress = true; \ - if (should_print_nir()) \ + if (should_print_nir(nir)) \ nir_print_shader(nir, stdout); \ nir_metadata_check_validation_flag(nir); \ } \ ) #define NIR_PASS_V(nir, pass, ...) _PASS(pass, nir, \ - if (should_print_nir()) \ + if (should_print_nir(nir)) \ printf("%s\n", #pass); \ pass(nir, ##__VA_ARGS__); \ - if (should_print_nir()) \ + if (should_print_nir(nir)) \ nir_print_shader(nir, stdout); \ ) diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h index 23d174af1a7..bee2847b304 100644 --- a/src/compiler/shader_info.h +++ b/src/compiler/shader_info.h @@ -98,6 +98,9 @@ typedef struct shader_info { /* Descriptive name provided by the client; may be NULL */ const char *label; + /* Shader is internal, and should be ignored by things like NIR_PRINT */ + bool internal; + /** The shader stage, such as MESA_SHADER_VERTEX. */ gl_shader_stage stage:8;