mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-27 01:50:10 +01:00
nir/builder: Add steal_tex_src helper
I have this in the AGX compiler but I want to use it in more places. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Timur Kristóf <timur.kristof@gmail.com> Reviewed-by: Rhys Perry <pendingchaos02@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23513>
This commit is contained in:
parent
bbda9f7390
commit
36e779e4a9
1 changed files with 18 additions and 0 deletions
|
|
@ -1650,6 +1650,24 @@ nir_tex_src_for_ssa(nir_tex_src_type src_type, nir_ssa_def *def)
|
|||
return src;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find a texture source, remove it, and return its nir_ssa_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_ssa_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;
|
||||
|
||||
assert(tex->src[idx].src.is_ssa);
|
||||
nir_ssa_def *ssa = tex->src[idx].src.ssa;
|
||||
nir_tex_instr_remove_src(tex, idx);
|
||||
return ssa;
|
||||
}
|
||||
|
||||
static inline nir_ssa_def *
|
||||
nir_tex_deref(nir_builder *b, nir_deref_instr *t, nir_deref_instr *s,
|
||||
nir_ssa_def *coord)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue