nir/constant_folding: Break TXB folding into a helper function

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16171>
This commit is contained in:
Jason Ekstrand
2022-04-26 11:28:36 -05:00
committed by Marge Bot
parent 4f7de83110
commit 9332598b26

View File

@@ -306,10 +306,10 @@ try_fold_intrinsic(nir_builder *b, nir_intrinsic_instr *intrin,
}
static bool
try_fold_tex(nir_builder *b, nir_tex_instr *tex)
try_fold_txb_to_tex(nir_builder *b, nir_tex_instr *tex)
{
/* txb with a bias of constant zero is just tex. */
if (tex->op == nir_texop_txb) {
assert(tex->op == nir_texop_txb);
const int bias_idx = nir_tex_instr_src_index(tex, nir_tex_src_bias);
/* nir_to_tgsi_lower_tex mangles many kinds of texture instructions,
@@ -325,11 +325,22 @@ try_fold_tex(nir_builder *b, nir_tex_instr *tex)
tex->op = nir_texop_tex;
return true;
}
}
return false;
}
static bool
try_fold_tex(nir_builder *b, nir_tex_instr *tex)
{
bool progress = false;
/* txb with a bias of constant zero is just tex. */
if (tex->op == nir_texop_txb)
progress |= try_fold_txb_to_tex(b, tex);
return progress;
}
static bool
try_fold_instr(nir_builder *b, nir_instr *instr, void *_state)
{