[Mesa-dev] [PATCH 1/2] nir: When asked to print with a NULL state, just us bare variable names.

Jason Ekstrand jason at jlekstrand.net
Fri Jan 23 16:44:25 PST 2015


Reviewed-by: Jason Ekstrand <jason.ekstrand at intel.com>

On Fri, Jan 23, 2015 at 4:35 PM, Eric Anholt <eric at anholt.net> wrote:

> ---
>  src/glsl/nir/nir_print.c | 22 ++++++++++++++++------
>  1 file changed, 16 insertions(+), 6 deletions(-)
>
> diff --git a/src/glsl/nir/nir_print.c b/src/glsl/nir/nir_print.c
> index 1a50ae9..2ef55ed 100644
> --- a/src/glsl/nir/nir_print.c
> +++ b/src/glsl/nir/nir_print.c
> @@ -210,7 +210,9 @@ print_var_decl(nir_variable *var, print_var_state
> *state, FILE *fp)
>
>     glsl_print_type(var->type, fp);
>
> -   struct set_entry *entry = _mesa_set_search(state->syms, var->name);
> +   struct set_entry *entry = NULL;
> +   if (state)
> +      entry = _mesa_set_search(state->syms, var->name);
>
>     char *name;
>
> @@ -231,18 +233,26 @@ print_var_decl(nir_variable *var, print_var_state
> *state, FILE *fp)
>
>     fprintf(fp, "\n");
>
> -   _mesa_set_add(state->syms, name);
> -   _mesa_hash_table_insert(state->ht, var, name);
> +   if (state) {
> +      _mesa_set_add(state->syms, name);
> +      _mesa_hash_table_insert(state->ht, var, name);
> +   }
>  }
>
>  static void
>  print_var(nir_variable *var, print_var_state *state, FILE *fp)
>  {
> -   struct hash_entry *entry = _mesa_hash_table_search(state->ht, var);
> +   const char *name;
> +   if (state) {
> +      struct hash_entry *entry = _mesa_hash_table_search(state->ht, var);
>
> -   assert(entry != NULL);
> +      assert(entry != NULL);
> +      name = entry->data;
> +   } else {
> +      name = var->name;
> +   }
>
> -   fprintf(fp, "%s", (char *) entry->data);
> +   fprintf(fp, "%s", name);
>  }
>
>  static void
> --
> 2.1.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150123/b90b65bd/attachment.html>


More information about the mesa-dev mailing list