From 2b40fa09f282b81588f1f62b3d6a9f9c68409b90 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Tue, 17 Jun 2025 13:59:56 -0400 Subject: [PATCH] nir: Move nir_steal_tex_src() to nir.h Reviewed-by: Christian Gmeiner Part-of: --- src/compiler/nir/nir.h | 17 +++++++++++++++++ src/compiler/nir/nir_builder.h | 17 ----------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index f7d475d0497..ab0cfae43a1 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2563,6 +2563,23 @@ void nir_tex_instr_add_src(nir_tex_instr *tex, /** Removes a source from a texture instruction */ void nir_tex_instr_remove_src(nir_tex_instr *tex, unsigned src_idx); +/* + * Find a texture source, remove it, and return its nir_def. If the texture + * source does not exist, return NULL. This is useful for texture lowering pass + * that consume their input sources and produce a new lowered source. + */ +static inline nir_def * +nir_steal_tex_src(nir_tex_instr *tex, nir_tex_src_type type_) +{ + int idx = nir_tex_instr_src_index(tex, type_); + if (idx < 0) + return NULL; + + nir_def *ssa = tex->src[idx].src.ssa; + nir_tex_instr_remove_src(tex, idx); + return ssa; +} + bool nir_tex_instr_has_explicit_tg4_offsets(nir_tex_instr *tex); typedef struct nir_load_const_instr { diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h index 83b817449b2..6bf4be84aa8 100644 --- a/src/compiler/nir/nir_builder.h +++ b/src/compiler/nir/nir_builder.h @@ -2146,23 +2146,6 @@ DEF_DERIV(ddy) DEF_DERIV(ddy_fine) DEF_DERIV(ddy_coarse) -/* - * Find a texture source, remove it, and return its nir_def. If the texture - * source does not exist, return NULL. This is useful for texture lowering pass - * that consume their input sources and produce a new lowered source. - */ -static inline nir_def * -nir_steal_tex_src(nir_tex_instr *tex, nir_tex_src_type type_) -{ - int idx = nir_tex_instr_src_index(tex, type_); - if (idx < 0) - return NULL; - - nir_def *ssa = tex->src[idx].src.ssa; - nir_tex_instr_remove_src(tex, idx); - return ssa; -} - static inline nir_def * nir_tex_deref(nir_builder *b, nir_deref_instr *t, nir_deref_instr *s, nir_def *coord)