Signed-off-by: Lionel Landwerlin <lionel.g.landwer...@intel.com> --- src/compiler/nir/nir.h | 1 + src/compiler/nir/nir_lower_tex.c | 36 ++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index f4f6b106505..2a843de8ae1 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2904,6 +2904,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 dc40d82b27f..e10d4ea62f6 100644 --- a/src/compiler/nir/nir_lower_tex.c +++ b/src/compiler/nir/nir_lower_tex.c @@ -261,7 +261,8 @@ sample_plane(nir_builder *b, nir_tex_instr *tex, int plane) static void convert_yuv_to_rgb(nir_builder *b, nir_tex_instr *tex, - nir_ssa_def *y, nir_ssa_def *u, nir_ssa_def *v) + nir_ssa_def *y, nir_ssa_def *u, nir_ssa_def *v, + nir_ssa_def *a) { nir_const_value m[3] = { { .f32 = { 1.0f, 0.0f, 1.59602678f, 0.0f } }, @@ -281,7 +282,7 @@ convert_yuv_to_rgb(nir_builder *b, nir_tex_instr *tex, nir_ssa_def *green = nir_fdot4(b, yuv, nir_build_imm(b, 4, 32, m[1])); nir_ssa_def *blue = nir_fdot4(b, yuv, nir_build_imm(b, 4, 32, m[2])); - nir_ssa_def *result = nir_vec4(b, red, green, blue, nir_imm_float(b, 1.0f)); + nir_ssa_def *result = nir_vec4(b, red, green, blue, a); nir_ssa_def_rewrite_uses(&tex->dest.ssa, nir_src_for_ssa(result)); } @@ -297,7 +298,8 @@ lower_y_uv_external(nir_builder *b, nir_tex_instr *tex) convert_yuv_to_rgb(b, tex, nir_channel(b, y, 0), nir_channel(b, uv, 0), - nir_channel(b, uv, 1)); + nir_channel(b, uv, 1), + nir_imm_float(b, 1.0f)); } static void @@ -312,7 +314,8 @@ lower_y_u_v_external(nir_builder *b, nir_tex_instr *tex) convert_yuv_to_rgb(b, tex, nir_channel(b, y, 0), nir_channel(b, u, 0), - nir_channel(b, v, 0)); + nir_channel(b, v, 0), + nir_imm_float(b, 1.0f)); } static void @@ -326,7 +329,8 @@ lower_yx_xuxv_external(nir_builder *b, nir_tex_instr *tex) convert_yuv_to_rgb(b, tex, nir_channel(b, y, 0), nir_channel(b, xuxv, 1), - nir_channel(b, xuxv, 3)); + nir_channel(b, xuxv, 3), + nir_imm_float(b, 1.0f)); } static void @@ -340,7 +344,22 @@ lower_xy_uxvx_external(nir_builder *b, nir_tex_instr *tex) convert_yuv_to_rgb(b, tex, nir_channel(b, y, 1), nir_channel(b, uxvx, 0), - nir_channel(b, uxvx, 2)); + nir_channel(b, uxvx, 2), + 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)); } /* @@ -788,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; -- 2.19.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev