[Mesa-dev] [PATCH 2/2] nir: move tex_instr_remove_src

Jason Ekstrand jason at jlekstrand.net
Thu Sep 8 18:21:03 UTC 2016


On Thu, Sep 8, 2016 at 11:14 AM, Rob Clark <robdclark at gmail.com> wrote:

> I want to re-use this in a different pass, so move to nir.h
>
> Signed-off-by: Rob Clark <robdclark at gmail.com>
> ---
>  src/compiler/nir/nir.h           | 16 ++++++++++++++++
>  src/compiler/nir/nir_lower_tex.c | 20 ++------------------
>  2 files changed, 18 insertions(+), 18 deletions(-)
>
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> index c1cf940..e907bc9 100644
> --- a/src/compiler/nir/nir.h
> +++ b/src/compiler/nir/nir.h
> @@ -2297,6 +2297,22 @@ unsigned nir_index_instrs(nir_function_impl *impl);
>
>  void nir_index_blocks(nir_function_impl *impl);
>
> +static inline void
> +nir_tex_instr_remove_src(nir_tex_instr *tex, unsigned src_idx)
>

This one is complex enough, I think I'd rather have it in nir.c.  That also
allows us to put the declaration up with the other nir_tex_instr helpers
which would be nice.


> +{
> +   assert(src_idx < tex->num_srcs);
> +
> +   /* First rewrite the source to NIR_SRC_INIT */
> +   nir_instr_rewrite_src(&tex->instr, &tex->src[src_idx].src,
> NIR_SRC_INIT);
> +
> +   /* Now, move all of the other sources down */
> +   for (unsigned i = src_idx + 1; i < tex->num_srcs; i++) {
> +      tex->src[i-1].src_type = tex->src[i].src_type;
> +      nir_instr_move_src(&tex->instr, &tex->src[i-1].src,
> &tex->src[i].src);
> +   }
> +   tex->num_srcs--;
> +}
> +
>  void nir_print_shader(nir_shader *shader, FILE *fp);
>  void nir_print_shader_annotated(nir_shader *shader, FILE *fp, struct
> hash_table *errors);
>  void nir_print_instr(const nir_instr *instr, FILE *fp);
> diff --git a/src/compiler/nir/nir_lower_tex.c
> b/src/compiler/nir/nir_lower_tex.c
> index b570598..a405758 100644
> --- a/src/compiler/nir/nir_lower_tex.c
> +++ b/src/compiler/nir/nir_lower_tex.c
> @@ -39,22 +39,6 @@
>  #include "nir_builder.h"
>
>  static void
> -tex_instr_remove_src(nir_tex_instr *tex, unsigned src_idx)
> -{
> -   assert(src_idx < tex->num_srcs);
> -
> -   /* First rewrite the source to NIR_SRC_INIT */
> -   nir_instr_rewrite_src(&tex->instr, &tex->src[src_idx].src,
> NIR_SRC_INIT);
> -
> -   /* Now, move all of the other sources down */
> -   for (unsigned i = src_idx + 1; i < tex->num_srcs; i++) {
> -      tex->src[i-1].src_type = tex->src[i].src_type;
> -      nir_instr_move_src(&tex->instr, &tex->src[i-1].src,
> &tex->src[i].src);
> -   }
> -   tex->num_srcs--;
> -}
> -
> -static void
>  project_src(nir_builder *b, nir_tex_instr *tex)
>  {
>     /* Find the projector in the srcs list, if present. */
> @@ -114,7 +98,7 @@ project_src(nir_builder *b, nir_tex_instr *tex)
>                              nir_src_for_ssa(projected));
>     }
>
> -   tex_instr_remove_src(tex, proj_index);
> +   nir_tex_instr_remove_src(tex, proj_index);
>  }
>
>  static bool
> @@ -159,7 +143,7 @@ lower_offset(nir_builder *b, nir_tex_instr *tex)
>     nir_instr_rewrite_src(&tex->instr, &tex->src[coord_index].src,
>                           nir_src_for_ssa(offset_coord));
>
> -   tex_instr_remove_src(tex, offset_index);
> +   nir_tex_instr_remove_src(tex, offset_index);
>
>     return true;
>  }
> --
> 2.7.4
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160908/da029e7c/attachment.html>


More information about the mesa-dev mailing list