[Mesa-dev] [PATCH 3/7] nir/lower_tex: Simplify lower_gradient logic

Jason Ekstrand jason at jlekstrand.net
Thu Oct 11 21:32:54 UTC 2018


Instead of having to call two different lower_gradient functions based
on whether or not it's a cube, just make lower_gradient handle cubes.
This significantly simplifies some of the logic.
---
 src/compiler/nir/nir_lower_tex.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/src/compiler/nir/nir_lower_tex.c b/src/compiler/nir/nir_lower_tex.c
index dc40d82b27f..c48ce114d46 100644
--- a/src/compiler/nir/nir_lower_tex.c
+++ b/src/compiler/nir/nir_lower_tex.c
@@ -543,6 +543,12 @@ lower_gradient_cube_map(nir_builder *b, nir_tex_instr *tex)
 static void
 lower_gradient(nir_builder *b, nir_tex_instr *tex)
 {
+   /* Cubes are more complicated and have their own function */
+   if (tex->sampler_dim == GLSL_SAMPLER_DIM_CUBE) {
+      lower_gradient_cube_map(b, tex);
+      return;
+   }
+
    assert(tex->sampler_dim != GLSL_SAMPLER_DIM_CUBE);
    assert(tex->op == nir_texop_txd);
    assert(tex->dest.is_ssa);
@@ -807,20 +813,11 @@ nir_lower_tex_block(nir_block *block, nir_builder *b,
          progress = true;
       }
 
-      if (tex->op == nir_texop_txd &&
-          tex->sampler_dim == GLSL_SAMPLER_DIM_CUBE &&
-          (options->lower_txd ||
-           options->lower_txd_cube_map ||
-           (tex->is_shadow && options->lower_txd_shadow))) {
-         lower_gradient_cube_map(b, tex);
-         progress = true;
-         continue;
-      }
-
       if (tex->op == nir_texop_txd &&
           (options->lower_txd ||
-           (options->lower_txd_shadow &&
-            tex->is_shadow && tex->sampler_dim != GLSL_SAMPLER_DIM_CUBE))) {
+           (options->lower_txd_shadow && tex->is_shadow) ||
+           (options->lower_txd_cube_map &&
+            tex->sampler_dim == GLSL_SAMPLER_DIM_CUBE))) {
          lower_gradient(b, tex);
          progress = true;
          continue;
-- 
2.19.1



More information about the mesa-dev mailing list