Mesa (master): nir/lower_tex: Add AYUV lowering support

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Nov 12 14:38:17 UTC 2018


Module: Mesa
Branch: master
Commit: 8a15f06d19d143198cb92321fcc5dc741783c01c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8a15f06d19d143198cb92321fcc5dc741783c01c

Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date:   Thu Nov  8 16:28:20 2018 +0000

nir/lower_tex: Add AYUV lowering support

Byte ordering is :

0: V
1: U
2: Y
3: A

v2: Split refactoring of alpha channel (Lionel)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Reviewed-by: Tapani Pälli <tapani.palli at intel.com> (v1)
Acked-by: Eric Engestrom <eric.engestrom at intel.com> (v2)

---

 src/compiler/nir/nir.h           |  1 +
 src/compiler/nir/nir_lower_tex.c | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index dc3c729dee..f984c76fe6 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2905,6 +2905,7 @@ typedef struct nir_lower_tex_options {
    unsigned lower_y_u_v_external;
    unsigned lower_yx_xuxv_external;
    unsigned lower_xy_uxvx_external;
+   unsigned lower_ayuv_external;
 
    /**
     * To emulate certain texture wrap modes, this can be used
diff --git a/src/compiler/nir/nir_lower_tex.c b/src/compiler/nir/nir_lower_tex.c
index c16a32f54e..e10d4ea62f 100644
--- a/src/compiler/nir/nir_lower_tex.c
+++ b/src/compiler/nir/nir_lower_tex.c
@@ -348,6 +348,20 @@ lower_xy_uxvx_external(nir_builder *b, nir_tex_instr *tex)
                      nir_imm_float(b, 1.0f));
 }
 
+static void
+lower_ayuv_external(nir_builder *b, nir_tex_instr *tex)
+{
+  b->cursor = nir_after_instr(&tex->instr);
+
+  nir_ssa_def *ayuv = sample_plane(b, tex, 0);
+
+  convert_yuv_to_rgb(b, tex,
+                     nir_channel(b, ayuv, 2),
+                     nir_channel(b, ayuv, 1),
+                     nir_channel(b, ayuv, 0),
+                     nir_channel(b, ayuv, 3));
+}
+
 /*
  * Emits a textureLod operation used to replace an existing
  * textureGrad instruction.
@@ -793,6 +807,11 @@ nir_lower_tex_block(nir_block *block, nir_builder *b,
          progress = true;
       }
 
+      if ((1 << tex->texture_index) & options->lower_ayuv_external) {
+         lower_ayuv_external(b, tex);
+         progress = true;
+      }
+
       if (sat_mask) {
          saturate_src(b, tex, sat_mask);
          progress = true;




More information about the mesa-commit mailing list