nir: Add option to lower tex to txl when shader don't support implicit LOD
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Fri, 19 Apr 2019 04:01:15 +0000 (21:01 -0700)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Thu, 25 Apr 2019 19:13:06 +0000 (12:13 -0700)
We already add the LOD src, so go ahead and update the texop as well
when this option is set.

v2: Make it an option. (Rob Clark)

v3: Use a more concise name suggested by Jason.

Reviewed-by: Rob Clark <robdclark@gmail.com>
src/compiler/nir/nir.h
src/compiler/nir/nir_lower_tex.c

index 7d2062d3691513ae579188430f345cdc64b97f15..e878a63409d5ed4e4fae164c819bbdcdfdbae014 100644 (file)
@@ -3264,6 +3264,12 @@ typedef struct nir_lower_tex_options {
     */
    unsigned lower_srgb;
 
+   /**
+    * If true, lower nir_texop_tex on shaders that doesn't support implicit
+    * LODs to nir_texop_txl.
+    */
+   bool lower_tex_without_implicit_lod;
+
    /**
     * If true, lower nir_texop_txd on cube maps with nir_texop_txl.
     */
index c5762b860fd3b30264275e5a13cc04bc559903a2..e814e65bf2cd55fcc89ad4d48edf53f7a14698e2 100644 (file)
@@ -1127,6 +1127,8 @@ nir_lower_tex_block(nir_block *block, nir_builder *b,
            (tex->op == nir_texop_tex && !shader_supports_implicit_lod))) {
          b->cursor = nir_before_instr(&tex->instr);
          nir_tex_instr_add_src(tex, nir_tex_src_lod, nir_src_for_ssa(nir_imm_int(b, 0)));
+         if (tex->op == nir_texop_tex && options->lower_tex_without_implicit_lod)
+            tex->op = nir_texop_txl;
          progress = true;
          continue;
       }