intel/nir: Replace tg4 with txl/txb/tex when splitting texture residency
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

textureGather() returns the four taps that would have been filtered
together to produce the value that ordinary texturing operations
would return.  As such, it should access the same data, so we can use
either interchangeably when we're only checking for residency and not
returning the actual data.

This allows us to mask out some unneeded registers.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40590>
This commit is contained in:
Kenneth Graunke 2026-03-21 00:34:00 -07:00 committed by Marge Bot
parent 605ef577b3
commit 204af7e09f

View file

@ -130,6 +130,22 @@ split_tex_residency(nir_builder *b, nir_tex_instr *tex, int compare_idx)
tex->def.num_components, tex->def.bit_size);
nir_builder_instr_insert(b, &sparse_tex->instr);
/* txl/txb/tex and tg4 both access the same pixels for residency checking
* purposes, but using the former for residency-only queries lets us mask
* out unwanted color components, using fewer registers.
*/
if (sparse_tex->op == nir_texop_tg4) {
if (nir_tex_instr_src_index(sparse_tex, nir_tex_src_bias) >= 0)
sparse_tex->op = nir_texop_txb;
else if (sparse_tex->is_gather_implicit_lod)
sparse_tex->op = nir_texop_tex;
else
sparse_tex->op = nir_texop_txl;
sparse_tex->component = 0;
sparse_tex->is_gather_implicit_lod = false;
}
/* Drop the compare source on the cloned instruction */
if (compare_idx != -1)
nir_tex_instr_remove_src(sparse_tex, compare_idx);