[Mesa-dev] [PATCH] nir_print: Fix printing of variable mode

Jason Ekstrand jason at jlekstrand.net
Fri Apr 15 13:53:06 UTC 2016


Thanks. R-B
On Apr 15, 2016 1:00 AM, "Eduardo Lima Mitev" <elima at igalia.com> wrote:

> nir_variable_mode is currently a bitflag enum, while
> nir_print::print_var_decl() assumes is still a numbered list.
> ---
>  src/compiler/nir/nir_print.c | 34 +++++++++++++++++++++++++++-------
>  1 file changed, 27 insertions(+), 7 deletions(-)
>
> diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
> index 84e9269..229539d 100644
> --- a/src/compiler/nir/nir_print.c
> +++ b/src/compiler/nir/nir_print.c
> @@ -315,6 +315,30 @@ print_constant(nir_constant *c, const struct
> glsl_type *type, print_state *state
>     }
>  }
>
> +static const char *
> +get_variable_mode_str(nir_variable_mode mode)
> +{
> +   switch (mode) {
> +   case nir_var_shader_in:
> +      return "shader_in";
> +   case nir_var_shader_out:
> +      return "shader_out";
> +   case nir_var_uniform:
> +      return "uniform";
> +   case nir_var_shader_storage:
> +      return "shader_storage";
> +   case nir_var_system_value:
> +      return "system";
> +   case nir_var_shared:
> +      return "shared";
> +   case nir_var_param:
> +   case nir_var_global:
> +   case nir_var_local:
> +   default:
> +      return "";
> +   }
> +}
> +
>  static void
>  print_var_decl(nir_variable *var, print_state *state)
>  {
> @@ -326,13 +350,9 @@ print_var_decl(nir_variable *var, print_state *state)
>     const char *const samp = (var->data.sample) ? "sample " : "";
>     const char *const patch = (var->data.patch) ? "patch " : "";
>     const char *const inv = (var->data.invariant) ? "invariant " : "";
> -   const char *const mode[] = { "shader_in ", "shader_out ", "", "",
> -                                "uniform ", "shader_storage ", "shared ",
> -                                "system "};
> -
> -   fprintf(fp, "%s%s%s%s%s%s ",
> -      cent, samp, patch, inv, mode[var->data.mode],
> -         glsl_interp_qualifier_name(var->data.interpolation));
> +   fprintf(fp, "%s%s%s%s%s %s ",
> +           cent, samp, patch, inv, get_variable_mode_str(var->data.mode),
> +           glsl_interp_qualifier_name(var->data.interpolation));
>
>     glsl_print_type(var->type, fp);
>
> --
> 2.7.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160415/40a0d9a7/attachment.html>


More information about the mesa-dev mailing list