diff options
author | fuzzard <fuzzard@users.noreply.github.com> | 2024-03-01 13:13:04 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-01 13:13:04 +1000 |
commit | 36c6d1449858c4d5fa3299af82ae3cf2341b3db3 (patch) | |
tree | c1bcfde54162899471c074c1de02df08a901fbad | |
parent | d1f2c5368247663b53e5bcac0c3b4459b9a60f4f (diff) | |
parent | 19c6aae0445b7476939816586a8ad3e219934cbb (diff) |
Merge pull request #24739 from thexai/fix-pixel-shaders
[Windows] Fix inaccurate 10-bit SDR / HDR color using Pixel Shaders
3 files changed, 13 insertions, 13 deletions
diff --git a/system/shaders/output_d3d.fx b/system/shaders/output_d3d.fx index fd5fff1d53..e3a66abbe1 100644 --- a/system/shaders/output_d3d.fx +++ b/system/shaders/output_d3d.fx @@ -194,7 +194,7 @@ float4 OUTPUT_PS(VS_OUTPUT In) : SV_TARGET { float4 color = g_Texture.Sample(KernelSampler, In.TextureUV); [flatten] if (m_params.x) - color = saturate(0.0625 + color * 219.0 / 255.0); + color = saturate((64.0 / 1023.0) + color * (940.0 - 64.0) / 1023.0); color *= m_params.y * 2.0; color += m_params.z - 0.5; diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/ConversionMatrix.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/ConversionMatrix.cpp index 270c263af6..c7ed7471b0 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/ConversionMatrix.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/ConversionMatrix.cpp @@ -515,15 +515,15 @@ const CGlMatrix& CConvertMatrix::GenMat() { if (m_srcBits >= 12) { - CScale scale(4080.0f / (3760 - 256), 4080.0f / (3840 - 256), 4080.0f / (3840 - 256)); - CTranslate trans(- 256.0f / 4080, - 256.0f / 4080, - 256.0f / 4080); + CScale scale(4095.0f / (3760 - 256), 4095.0f / (3840 - 256), 4095.0f / (3840 - 256)); + CTranslate trans(-256.0f / 4095.0f, -256.0f / 4095.0f, -256.0f / 4095.0f); mat *= scale; mat *= trans; } else if (m_srcBits == 10) { - CScale scale(1020.0f / (940 - 64), 1020.0f / (960 - 64), 1020.0f / (960 - 64)); - CTranslate trans(- 64.0f / 1020, - 64.0f / 1020, - 64.0f / 1020); + CScale scale(1023.0f / (940 - 64), 1023.0f / (960 - 64), 1023.0f / (960 - 64)); + CTranslate trans(-64.0f / 1023.0f, -64.0f / 1023.0f, -64.0f / 1023.0f); mat *= scale; mat *= trans; } @@ -559,8 +559,8 @@ Matrix4 CConvertMatrix::GetYuvMat() ret *= black; if (m_limitedDst) { - float valScale = (235 - 16) / 255.0f; - float valTrans = 16.0f / 255; + float valScale = (940.0f - 64.0f) / 1023.0f; + float valTrans = 64.0f / 1023.0f; CScale scale(valScale, valScale, valScale); CTranslate trans(valTrans, valTrans, valTrans); ret *= trans; diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/test/TestConversionMatrix.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/test/TestConversionMatrix.cpp index 709887e67e..cdc8b91e0e 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/test/TestConversionMatrix.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/test/TestConversionMatrix.cpp @@ -88,9 +88,9 @@ Matrix4 bt709Mat_8bit(bt709_8bit); std::array<std::array<float, 4>, 4> bt709_10bit = {{ - {1.1643834114, 1.1643834114, 1.1643834114, 0.0000000000}, - {0.0000000000, -0.2132485956, 2.1124014854, 0.0000000000}, - {1.7927408218, -0.5329092145, 0.0000000000, 0.0000000000}, + {1.1678080559, 1.1678080559, 1.1678080559, 0.0000000000}, + {0.0000000000, -0.2138758004, 2.1186144352, 0.0000000000}, + {1.7980136871, -0.5344766378, 0.0000000000, 0.0000000000}, {-0.9729449749, 0.3014826477, -1.1334021091, 1.0000000000}, }}; @@ -98,9 +98,9 @@ Matrix4 bt709Mat_10bit(bt709_10bit); std::array<std::array<float, 4>, 4> bt709_10bit_texture = {{ - {74.5922470093, 74.5922470093, 74.5922470093, 0.0000000000}, - {0.0000000000, -13.6610431671, 135.3237915039, 0.0000000000}, - {114.8458175659, -34.1390075684, 0.0000000000, 0.0000000000}, + {74.8116378784, 74.8116378784, 74.8116378784, 0.0000000000}, + {0.0000000000, -13.7012224197, 135.7218017578, 0.0000000000}, + {115.1836090088, -34.2394218445, 0.0000000000, 0.0000000000}, {-0.9729449749, 0.3014826477, -1.1334021091, 1.0000000000}, }}; |