[YUV AHB] Add PredefinedColorSpace::Rec2020Linear Fixed: 521496029 Change-Id: Ifcb9f95d7c00ba2ba707ae996d7ade369d859f0f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/314875 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: dan sinclair <dsinclair@chromium.org>
diff --git a/src/dawn/common/ExternalTextureParams.cpp b/src/dawn/common/ExternalTextureParams.cpp index cf62975..3517345 100644 --- a/src/dawn/common/ExternalTextureParams.cpp +++ b/src/dawn/common/ExternalTextureParams.cpp
@@ -40,7 +40,7 @@ // } // return (B + exp((v - C) / A)) / F constexpr TransferFunction kEOTF_HLG = { - .g = -1, // Mode HLG see XXX + .g = -1, // Mode HLG see src/dawn/native/ExternalTexture.cpp .a = 0.17883277, .b = 0.28466892, .c = 0.55991073, @@ -57,7 +57,7 @@ // v = max(v - C, 0) / (D - E * v) // return pow(v, 1.0 / A) constexpr TransferFunction kEOTF_PQ = { - .g = -2, // Mode HLG see XXX + .g = -2, // Mode PQ see src/dawn/native/ExternalTexture.cpp .a = (2610.0 / 16384.0), .b = (2523.0 / 4096.0) * 128.0, .c = (3424.0 / 4096.0), @@ -172,6 +172,10 @@ dstXYZToRGB = kXYZToRGB_DisplayP3; dstOETF = kEOTF_Identity; break; + case wgpu::PredefinedColorSpace::Rec2020Linear: + dstXYZToRGB = kXYZToRGB_Rec2020; + dstOETF = kEOTF_Identity; + break; default: return wgpu::Status::Error; }
diff --git a/src/dawn/dawn.json b/src/dawn/dawn.json index b5ec9a2..038434f 100644 --- a/src/dawn/dawn.json +++ b/src/dawn/dawn.json
@@ -4045,7 +4045,8 @@ {"value": 1, "name": "sRGB"}, {"value": 2, "name": "display p3"}, {"value": 3, "name": "sRGB linear", "tags": ["dawn", "art"]}, - {"value": 4, "name": "display p3 linear", "tags": ["dawn", "art"]} + {"value": 4, "name": "display p3 linear", "tags": ["dawn", "art"]}, + {"value": 5, "name": "rec 2020 linear", "tags": ["dawn", "art"]} ] }, "tone mapping mode": {
diff --git a/src/dawn/tests/end2end/ExternalTextureTests.cpp b/src/dawn/tests/end2end/ExternalTextureTests.cpp index 0d2538f..6db09a0 100644 --- a/src/dawn/tests/end2end/ExternalTextureTests.cpp +++ b/src/dawn/tests/end2end/ExternalTextureTests.cpp
@@ -2046,6 +2046,17 @@ wgpu::PredefinedColorSpace::SRGBLinear, {0.75, 0.75, 0.75, 1}, {1, 1, 1}); } +// Test that PredefinedColorSpace::Rec2020Linear is the same color space as using primaries of +// Rec2020 and an identity transfer function. (the Rec2020 primaries are tested as part of the PQ +// and HLG tests above). +TEST_P(ExternalTextureTests, ColorSpaceConversion_Rec2020_Rec2020Linear) { + CheckColorSpaceConversion( + { + .primaries = wgpu::ColorSpacePrimariesDawn::Rec2020, + }, + wgpu::PredefinedColorSpace::Rec2020Linear, {0.4, 0.2, 0.1, 1}, {0.4, 0.2, 0.1}); +} + // TODO(https://crbug.com/468988322): Add tests of ExternalTextures being used with a resource table // and with Vulkan's extended dynamic state as these are other interactions that could easily break.