From 4405e8a9e1482f455d0a6407f6b18e2cb0b6c425 Mon Sep 17 00:00:00 2001 From: Andres Calderon Jaramillo Date: Sat, 15 Apr 2023 06:34:14 +0000 Subject: [PATCH] r600: Report multi-plane formats as unsupported This is the analogous of https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9490 but for r600. Discoloration of NV12 video frames was observed in Chrome/ChromeOS and the problem was tracked down to the fact that Mesa was following the PIPE_FORMAT_R8_G8B8_420_UNORM/lower_yuv_external() path. The symptom is that (for an unknown reason) the YUV-to-RGB conversion is using the value of Y as the value of Y, U, and V. So, for example, if the input value is YUV = (50, 120, 130), then what actually gets converted to RGB is YUV = (50, 50, 50). Considering that PIPE_FORMAT_R8_G8B8_420_UNORM was introduced for freedreno (https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6693) and it is already being reported as unsupported for radeonsi, it's reasonable to assume that GPUs targeted by r600 don't support this path either. Note: I tested this patch with an AMD Palm device which follows the evergreen_is_format_supported() path. I did not have access to a device to test the r600_is_format_supported() path. v2: Changed >= 2 to > 1. Fixes: 826a10255f5 ("st/mesa: Add NV12 lowering to PIPE_FORMAT_R8_G8B8_420_UNORM") Tested-by: Andres Calderon Jaramillo Reviewed-by: Gert Wollny Part-of: --- src/gallium/drivers/r600/evergreen_state.c | 3 +++ src/gallium/drivers/r600/r600_state.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c index faa9339..0db74e0 100644 --- a/src/gallium/drivers/r600/evergreen_state.c +++ b/src/gallium/drivers/r600/evergreen_state.c @@ -254,6 +254,9 @@ bool evergreen_is_format_supported(struct pipe_screen *screen, return false; } + if (util_format_get_num_planes(format) > 1) + return false; + if (MAX2(1, sample_count) != MAX2(1, storage_sample_count)) return false; diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c index edbc0d3..a9673dd 100644 --- a/src/gallium/drivers/r600/r600_state.c +++ b/src/gallium/drivers/r600/r600_state.c @@ -173,6 +173,9 @@ bool r600_is_format_supported(struct pipe_screen *screen, return false; } + if (util_format_get_num_planes(format) > 1) + return false; + if (MAX2(1, sample_count) != MAX2(1, storage_sample_count)) return false; -- 2.7.4