Mesa (main): microsoft/compiler: Fixup sampler derefs in tex instrs that don't *need* samplers

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon May 30 07:37:32 UTC 2022


Module: Mesa
Branch: main
Commit: a56d47b0bae8487ac0c1cab26ac81da267b76365
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a56d47b0bae8487ac0c1cab26ac81da267b76365

Author: Jesse Natalie <jenatali at microsoft.com>
Date:   Wed May 18 12:42:04 2022 -0700

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 <erik.faye-lund at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16639>

---

 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 */



More information about the mesa-commit mailing list