[Mesa-dev] [PATCH] nir: add/export nir_variable_clone()

Jason Ekstrand jason at jlekstrand.net
Wed Mar 23 20:55:20 UTC 2016


On Mar 23, 2016 1:15 PM, "Rob Clark" <robdclark at gmail.com> wrote:
>
> From: Rob Clark <robclark at freedesktop.org>
>
> Signed-off-by: Rob Clark <robclark at freedesktop.org>
> ---
>  src/compiler/nir/nir.h       |  1 +
>  src/compiler/nir/nir_clone.c | 16 ++++++++++++++++
>  2 files changed, 17 insertions(+)
>
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> index 69a3084..724aa77 100644
> --- a/src/compiler/nir/nir.h
> +++ b/src/compiler/nir/nir.h
> @@ -2053,6 +2053,7 @@ void nir_print_instr(const nir_instr *instr, FILE
*fp);
>
>  nir_shader * nir_shader_clone(void *mem_ctx, const nir_shader *s);
>  nir_function_impl *nir_function_impl_clone(const nir_function_impl *fi);
> +nir_variable * nir_variable_clone(nir_variable *var);
>
>  #ifdef DEBUG
>  void nir_validate_shader(nir_shader *shader);
> diff --git a/src/compiler/nir/nir_clone.c b/src/compiler/nir/nir_clone.c
> index 7444dfe..03b4fbd 100644
> --- a/src/compiler/nir/nir_clone.c
> +++ b/src/compiler/nir/nir_clone.c
> @@ -149,6 +149,22 @@ clone_variable(clone_state *state, const
nir_variable *var)
>     return nvar;
>  }
>
> +nir_variable *
> +nir_variable_clone(nir_variable *var)
> +{
> +   clone_state state;
> +   init_clone_state(&state, false);
> +
> +   /* We use the same shader */
> +   state.ns = ralloc_parent(var);
> +
> +   nir_variable *nvar = clone_variable(&state, var);

Do we really need a full-on clone state or can we just make clone_variable
not take a state?

> +
> +   free_clone_state(&state);
> +
> +   return nvar;
> +}
> +
>  /* clone list of nir_variable: */
>  static void
>  clone_var_list(clone_state *state, struct exec_list *dst,
> --
> 2.5.0
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160323/34df51d6/attachment.html>


More information about the mesa-dev mailing list