From a56d47b0bae8487ac0c1cab26ac81da267b76365 Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Wed, 18 May 2022 12:42:04 -0700 Subject: [PATCH] microsoft/compiler: Fixup sampler derefs in tex instrs that don't *need* samplers 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 Part-of: --- src/microsoft/compiler/dxil_nir.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/microsoft/compiler/dxil_nir.c b/src/microsoft/compiler/dxil_nir.c index ec616facce9..350576aee98 100644 --- a/src/microsoft/compiler/dxil_nir.c +++ b/src/microsoft/compiler/dxil_nir.c @@ -1475,12 +1475,16 @@ redirect_sampler_derefs(struct nir_builder *b, nir_instr *instr, void *data) 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 */