0

[ChromeOS] gpu: Use BT.601 for any non-BT.2020 YUV Vulkan images

This CL tries to replicate the workaround first introduced in CL:3662321
but for Vulkan.

Some more context: whenever we promote a YUV resource to a hardware
overlay, we force the display controller to use the BT.601 matrix with
limited range [1]. This was deliberately introduced by CL:2336347 due to
concerns with compatibility for other settings. It's important to ensure
that there's no visual difference between promoting a quad to a hardware
overlay or compositing it. Otherwise, users might perceive flickering
if, e.g., a video goes in and out of hardware overlays repeateadly and
frequently. Therefore, any YUV quads that might be promoted to hardware
overlays will need to be composited assuming BT.601 with limited range,
even if that's slightly inconsistent with the actual content (e.g.,
maybe the original content uses BT.709). Note that we also avoid
promoting BT.2020 or full-range NV12/YV12/P010 quads to overlays [2],
but we still want to composite BT.2020 and full-range frames correctly.

With all this in mind, this CL makes it so that BT.2020 and full-range
YUV resources are tagged with the right Vulkan YCbCr conversion/range
settings, but everything else is tagged with the BT.601/limited-range
settings.

This workaround is guarded by BUILDFLAG(IS_CHROMEOS) to avoid impacting
color correctness in other platforms.

[1] https://source.chromium.org/chromium/chromium/src/+/main:ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.cc;l=191-192;drc=e857a19558861d81ad34cb22ed2cf49d6aa98ae3
[2] https://source.chromium.org/chromium/chromium/src/+/main:components/viz/service/display/overlay_processor_ozone.cc;l=148-158;drc=aaf19db38dc2303e055df0d45f03155d99dbde46

Bug: b:343793659
Test: tast.video.Contents.h264_1080p_composited_hw/total_distance on guybrush goes down from 12.737745466820988 to 1.2564356674382715 (disabling Vulkan in Chrome yields 0.9121117862654321)
Test: tast.video.Contents.h264_1080p_hw/total_distance on guybrush is unaffected (remains at 1.239231288580247)
Change-Id: Ie59d4520f32e6e651efc927204967b8c53a4a579
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5599625
Reviewed-by: Vasiliy Telezhnikov <vasilyt@chromium.org>
Commit-Queue: Andres Calderon Jaramillo <andrescj@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1310676}
This commit is contained in:
Andres Calderon Jaramillo
2024-06-05 16:35:11 +00:00
committed by Chromium LUCI CQ
parent 49e7f7af59
commit 424ce61433

@ -363,11 +363,42 @@ GPU_GLES2_EXPORT GrVkYcbcrConversionInfo CreateGrVkYcbcrConversionInfo(
return GrVkYcbcrConversionInfo();
}
// YCbCr sampler is required
// YCbCr sampler is required.
#if BUILDFLAG(IS_CHROMEOS)
// TODO(b/233667677): AllowColorSpaceCombination() in
// overlay_processor_ozone.cc ensures that the only NV12/YV12/P010 quads
// that we allow to be promoted to overlays are those that don't use
// the BT.2020 matrix and that don't use full range. Furthermore, since
// https://crrev.com/c/2336347, we force the DRM/KMS driver to use BT.601
// with limited range. Therefore, for compositing purposes, we need to
//
// a) Use VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601 for any YUV quads that
// might be promoted to overlays - we shouldn't use
// VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_709 because we might then see
// a slight difference in compositing vs. overlays (note that the BT.601
// and BT.709 primaries are close to each other, so this shouldn't be a
// huge correctness issue, though we'll need to address this at some
// point);
//
// and
//
// b) Use VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_2020 for BT.2020 quads in
// order to composite them correctly (and we won't need to worry about a
// difference in compositing vs. overlays in this case since those frames
// won't be promoted to overlays).
//
// We'll need to revisit this once we plumb the color space and range to
// DRM/KMS.
VkSamplerYcbcrModelConversion ycbcr_model =
(color_space.GetMatrixID() == gfx::ColorSpace::MatrixID::BT2020_NCL)
? VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_2020
: VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601;
#else
VkSamplerYcbcrModelConversion ycbcr_model =
(color_space.GetMatrixID() == gfx::ColorSpace::MatrixID::BT709)
? VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_709
: VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601;
#endif // BUILDFLAG(IS_CHROMEOS)
VkSamplerYcbcrRange ycbcr_range =
(color_space.GetRangeID() == gfx::ColorSpace::RangeID::FULL)
? VK_SAMPLER_YCBCR_RANGE_ITU_FULL