nir/lower_tex: Reinstate LSB to MSB shift
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

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: 5127568b98 ("compiler/nir: use common ycbcr math")
Signed-off-by: Robert Mader <robert.mader@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40561>
This commit is contained in:
Robert Mader 2026-03-22 14:58:37 +01:00 committed by Marge Bot
parent 8483acdc29
commit 44fa9c8326

View file

@ -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)));