diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2021-03-10 19:49:05 -0800 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2021-04-05 17:38:52 -0700 |
commit | b36925a97a367d4710c3b071e8cb0c43c4988d68 (patch) | |
tree | b2047f9d73919fe44d42a58fec867d29e8863d30 | |
parent | d74a3a126487265cc2829504130b1e4a17c00bbb (diff) |
nir/lower_tex: Add support for lowering Y41x formats
These are similar to AYUV, but the channel ordering is different... in
such a way that there's no RGBA format that will make the channels line
up right.
v2: Rebase on bc438c91d9b ("nir/lower_tex: ignore texture_index if
tex_instr has deref src")
-rw-r--r-- | src/compiler/nir/nir.h | 1 | ||||
-rw-r--r-- | src/compiler/nir/nir_lower_tex.c | 23 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 2f01cbaa375..0a271da3ce6 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -4709,6 +4709,7 @@ typedef struct nir_lower_tex_options { unsigned lower_ayuv_external; unsigned lower_xyuv_external; unsigned lower_yuv_external; + unsigned lower_y41x_external; unsigned bt709_external; unsigned bt2020_external; diff --git a/src/compiler/nir/nir_lower_tex.c b/src/compiler/nir/nir_lower_tex.c index 857bc9391e5..95b81a2562a 100644 --- a/src/compiler/nir/nir_lower_tex.c +++ b/src/compiler/nir/nir_lower_tex.c @@ -437,6 +437,24 @@ lower_ayuv_external(nir_builder *b, nir_tex_instr *tex, } static void +lower_y41x_external(nir_builder *b, nir_tex_instr *tex, + const nir_lower_tex_options *options, + unsigned texture_index) +{ + b->cursor = nir_after_instr(&tex->instr); + + nir_ssa_def *y41x = sample_plane(b, tex, 0, options); + + convert_yuv_to_rgb(b, tex, + nir_channel(b, y41x, 1), + nir_channel(b, y41x, 0), + nir_channel(b, y41x, 2), + nir_channel(b, y41x, 3), + options, + texture_index); +} + +static void lower_xyuv_external(nir_builder *b, nir_tex_instr *tex, const nir_lower_tex_options *options, unsigned texture_index) @@ -1206,6 +1224,11 @@ nir_lower_tex_block(nir_block *block, nir_builder *b, progress = true; } + if ((1 << tex->texture_index) & options->lower_y41x_external) { + lower_y41x_external(b, tex, options, texture_index); + progress = true; + } + if (sat_mask) { tex = saturate_src(b, tex, sat_mask); progress = true; |