nir/lower_tex: ignore saturate for txf ops
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Tue, 20 Jun 2023 17:48:05 +0000 (13:48 -0400)
committerMarge Bot <emma+marge@anholt.net>
Wed, 21 Jun 2023 23:13:50 +0000 (23:13 +0000)
saturate is used for GL_CLAMP emulation, and GL_CLAMP cannot be used
with txf

ref #9226

cc: mesa-stable

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23750>

src/compiler/nir/nir_lower_tex.c

index 16c335b..b01f18a 100644 (file)
@@ -1385,13 +1385,15 @@ nir_lower_tex_block(nir_block *block, nir_builder *b,
 
       /* mask of src coords to saturate (clamp): */
       unsigned sat_mask = 0;
-
-      if ((1 << tex->sampler_index) & options->saturate_r)
-         sat_mask |= (1 << 2);    /* .z */
-      if ((1 << tex->sampler_index) & options->saturate_t)
-         sat_mask |= (1 << 1);    /* .y */
-      if ((1 << tex->sampler_index) & options->saturate_s)
-         sat_mask |= (1 << 0);    /* .x */
+      /* ignore saturate for txf ops: these don't use samplers and can't GL_CLAMP */
+      if (nir_tex_instr_need_sampler(tex)) {
+         if ((1 << tex->sampler_index) & options->saturate_r)
+            sat_mask |= (1 << 2);    /* .z */
+         if ((1 << tex->sampler_index) & options->saturate_t)
+            sat_mask |= (1 << 1);    /* .y */
+         if ((1 << tex->sampler_index) & options->saturate_s)
+            sat_mask |= (1 << 0);    /* .x */
+      }
 
       if (options->lower_index_to_offset)
          progress |= lower_index_to_offset(b, tex);