Sometimes you can end up with tex instructions that have sampler deref srcs, even though
they don't need them, e.g. a txs. In this case, still fix up those derefs in the sampler
splitting pass rather than leaving them pointing to a typed sampler.
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16639>
return false;
nir_tex_instr *tex = nir_instr_as_tex(instr);
- if (!nir_tex_instr_need_sampler(tex))
- return false;
int sampler_idx = nir_tex_instr_src_index(tex, nir_tex_src_sampler_deref);
if (sampler_idx == -1) {
- /* No derefs, must be using indices */
+ /* No sampler deref - does this instruction even need a sampler? If not,
+ * sampler_index doesn't necessarily point to a sampler, so early-out.
+ */
+ if (!nir_tex_instr_need_sampler(tex))
+ return false;
+
+ /* No derefs but needs a sampler, must be using indices */
nir_variable *bare_sampler = _mesa_hash_table_u64_search(data, tex->sampler_index);
/* Already have a bare sampler here */