From 44fa9c8326b4e545499f2eecb3a5654355d3ea24 Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Sun, 22 Mar 2026 14:58:37 +0100 Subject: [PATCH] nir/lower_tex: Reinstate LSB to MSB shift lower_sx10_external and lower_sx12_external are used for LSB aligned formats such as DRM_FORMAT_S010, which are typically used by software decoders. Unlike MSB aligned 10/12 bit formats used by hardware decoders such as P010 they need to manually get "shifted" in order to correctly map to the 0-1 range. In the commit mentioned below the corresponding code got removed, probably because it got confused with similar sounding code in the common path - and because we don't have tests on the CI for the affected formats yet. Note: the formats in question are not yet supported in Vulkan. Fixes: 5127568b98f ("compiler/nir: use common ycbcr math") Signed-off-by: Robert Mader Part-of: --- src/compiler/nir/nir_lower_tex.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/compiler/nir/nir_lower_tex.c b/src/compiler/nir/nir_lower_tex.c index d5962826dee..3d4623b9d0e 100644 --- a/src/compiler/nir/nir_lower_tex.c +++ b/src/compiler/nir/nir_lower_tex.c @@ -397,6 +397,16 @@ convert_yuv_to_rgb(nir_builder *b, nir_tex_instr *tex, nir_def *m1 = nir_f2fN(b, nir_build_imm(b, 4, 32, m.v[1]), bit_size); nir_def *m2 = nir_f2fN(b, nir_build_imm(b, 4, 32, m.v[2]), bit_size); + if (options->lower_sx10_external & (1u << texture_index)) { + m0 = nir_fmul_imm(b, m0, 65535.0f / 1023.0f); + m1 = nir_fmul_imm(b, m1, 65535.0f / 1023.0f); + m2 = nir_fmul_imm(b, m2, 65535.0f / 1023.0f); + } else if (options->lower_sx12_external & (1u << texture_index)) { + m0 = nir_fmul_imm(b, m0, 65535.0f / 4095.0f); + m1 = nir_fmul_imm(b, m1, 65535.0f / 4095.0f); + m2 = nir_fmul_imm(b, m2, 65535.0f / 4095.0f); + } + nir_def *result = nir_ffma(b, y, m0, nir_ffma(b, u, m1, nir_ffma(b, v, m2, offset)));