From a6e06f38adb933187605ac07ef7a0cb1940afa80 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Tue, 22 Feb 2022 20:42:23 -0800 Subject: [PATCH] Add notes about precision of YUV->RGB conversion factors for XFB --- Source/Core/VideoCommon/TextureConversionShader.cpp | 2 ++ Source/Core/VideoCommon/TextureDecoder_Common.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/Source/Core/VideoCommon/TextureConversionShader.cpp b/Source/Core/VideoCommon/TextureConversionShader.cpp index c1aac4482a..6cabb4ce88 100644 --- a/Source/Core/VideoCommon/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/TextureConversionShader.cpp @@ -968,6 +968,8 @@ static const std::map s_decoding_shader_info{ // We do the inverse BT.601 conversion for YCbCr to RGB // http://www.equasys.de/colorconversion.html#YCbCr-RGBColorFormatConversion + // TODO: Use more precise numbers for this conversion (although on real hardware, the XFB isn't + // in a real texture format, so does this conversion actually ever happen?) {TextureFormat::XFB, {TEXEL_BUFFER_FORMAT_RGBA8_UINT, 0, 8, 8, false, R"( diff --git a/Source/Core/VideoCommon/TextureDecoder_Common.cpp b/Source/Core/VideoCommon/TextureDecoder_Common.cpp index 51ea0572f2..30121aeb7b 100644 --- a/Source/Core/VideoCommon/TextureDecoder_Common.cpp +++ b/Source/Core/VideoCommon/TextureDecoder_Common.cpp @@ -629,6 +629,8 @@ void TexDecoder_DecodeTexel(u8* dst, const u8* src, int s, int t, int imageWidth // We do the inverse BT.601 conversion for YCbCr to RGB // http://www.equasys.de/colorconversion.html#YCbCr-RGBColorFormatConversion + // TODO: Use more precise numbers for this conversion (although on real hardware, the XFB isn't + // in a real texture format, so does this conversion actually ever happen?) u8 R = std::clamp(int(1.164f * Y + 1.596f * V), 0, 255); u8 G = std::clamp(int(1.164f * Y - 0.392f * U - 0.813f * V), 0, 255); u8 B = std::clamp(int(1.164f * Y + 2.017f * U), 0, 255); @@ -694,6 +696,8 @@ void TexDecoder_DecodeXFB(u8* dst, const u8* src, u32 width, u32 height, u32 str // We do the inverse BT.601 conversion for YCbCr to RGB // http://www.equasys.de/colorconversion.html#YCbCr-RGBColorFormatConversion + // TODO: Use more precise numbers for this conversion (although on real hardware, the XFB + // isn't in a real texture format, so does this conversion actually ever happen?) u8 R1 = static_cast(std::clamp(int(1.164f * Y1 + 1.596f * V), 0, 255)); u8 G1 = static_cast(std::clamp(int(1.164f * Y1 - 0.392f * U - 0.813f * V), 0, 255)); u8 B1 = static_cast(std::clamp(int(1.164f * Y1 + 2.017f * U), 0, 255));