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

Rob Clark robdclark at gmail.com
Thu Sep 8 18:14:58 UTC 2016


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)
+{
+   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



More information about the mesa-dev mailing list