Change External Texture YUV-To-RGB Matrix To Be Optional
Changes the yuv-to-rgb constant matrix to be optional during external texture creation because it is not necessary for single-plane scenarios. Bug: dawn:1082 Change-Id: I543f4009e58f1571b0be80abb6b464b2b8c9d749 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91280 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
fb890c4122
commit
136a0a4269
|
@ -1345,7 +1345,7 @@
|
|||
{"name": "plane 0", "type": "texture view"},
|
||||
{"name": "plane 1", "type": "texture view", "optional": true},
|
||||
{"name": "yuv to rgb conversion matrix", "type": "float", "annotation": "const*",
|
||||
"length": 12},
|
||||
"length": 12, "optional": true},
|
||||
{"name": "src transfer function parameters", "type": "float", "annotation": "const*",
|
||||
"length": 7},
|
||||
{"name": "dst transfer function parameters", "type": "float", "annotation": "const*",
|
||||
|
|
|
@ -57,9 +57,6 @@ MaybeError ValidateExternalTextureDescriptor(const DeviceBase* device,
|
|||
|
||||
wgpu::TextureFormat plane0Format = descriptor->plane0->GetFormat().format;
|
||||
|
||||
DAWN_INVALID_IF(!descriptor->yuvToRgbConversionMatrix,
|
||||
"The YUV-to-RGB conversion matrix must be non-null.");
|
||||
|
||||
DAWN_INVALID_IF(!descriptor->gamutConversionMatrix,
|
||||
"The gamut conversion matrix must be non-null.");
|
||||
|
||||
|
@ -69,10 +66,14 @@ MaybeError ValidateExternalTextureDescriptor(const DeviceBase* device,
|
|||
DAWN_INVALID_IF(!descriptor->dstTransferFunctionParameters,
|
||||
"The destination transfer function parameters must be non-null.");
|
||||
|
||||
DAWN_INVALID_IF(descriptor->colorSpace != wgpu::PredefinedColorSpace::Srgb,
|
||||
"The specified color space (%s) is not %s.", descriptor->colorSpace,
|
||||
wgpu::PredefinedColorSpace::Srgb);
|
||||
|
||||
if (descriptor->plane1) {
|
||||
DAWN_INVALID_IF(descriptor->colorSpace != wgpu::PredefinedColorSpace::Srgb,
|
||||
"The specified color space (%s) is not %s.", descriptor->colorSpace,
|
||||
wgpu::PredefinedColorSpace::Srgb);
|
||||
DAWN_INVALID_IF(
|
||||
!descriptor->yuvToRgbConversionMatrix,
|
||||
"When more than one plane is set, the YUV-to-RGB conversion matrix must be non-null.");
|
||||
|
||||
DAWN_TRY(device->ValidateObject(descriptor->plane1));
|
||||
wgpu::TextureFormat plane1Format = descriptor->plane1->GetFormat().format;
|
||||
|
@ -157,8 +158,12 @@ MaybeError ExternalTextureBase::Initialize(DeviceBase* device,
|
|||
|
||||
// YUV-to-RGB conversion is performed by multiplying the source YUV values with a 4x3 matrix
|
||||
// passed from Chromium. The matrix was originally sourced from /skia/src/core/SkYUVMath.cpp.
|
||||
const float* yMat = descriptor->yuvToRgbConversionMatrix;
|
||||
std::copy(yMat, yMat + 12, params.yuvToRgbConversionMatrix.begin());
|
||||
// This matrix is only used in multiplanar scenarios.
|
||||
if (params.numPlanes == 2) {
|
||||
ASSERT(descriptor->yuvToRgbConversionMatrix);
|
||||
const float* yMat = descriptor->yuvToRgbConversionMatrix;
|
||||
std::copy(yMat, yMat + 12, params.yuvToRgbConversionMatrix.begin());
|
||||
}
|
||||
|
||||
// Gamut correction is performed by multiplying a 3x3 matrix passed from Chromium. The
|
||||
// matrix was computed by multiplying the appropriate source and destination gamut
|
||||
|
|
|
@ -157,7 +157,7 @@ TEST_F(ExternalTextureTest, CreateExternalTextureValidation) {
|
|||
|
||||
TEST_F(ExternalTextureTest, CreateExternalTextureConstantValueValidation) {
|
||||
DAWN_SKIP_TEST_IF(UsesWire());
|
||||
// Creating an external texture without a YUV-to-RGB matrix should fail.
|
||||
// Creating a single plane external texture without a YUV-to-RGB matrix should pass.
|
||||
{
|
||||
wgpu::TextureDescriptor textureDescriptor = CreateTextureDescriptor();
|
||||
wgpu::Texture texture = device.CreateTexture(&textureDescriptor);
|
||||
|
@ -165,6 +165,22 @@ TEST_F(ExternalTextureTest, CreateExternalTextureConstantValueValidation) {
|
|||
wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor();
|
||||
externalDesc.plane0 = texture.CreateView();
|
||||
externalDesc.yuvToRgbConversionMatrix = nullptr;
|
||||
device.CreateExternalTexture(&externalDesc);
|
||||
}
|
||||
|
||||
// Creating a multiplanar external texture without a YUV-to-RGB matrix should fail.
|
||||
{
|
||||
wgpu::TextureDescriptor plane0TextureDescriptor =
|
||||
CreateTextureDescriptor(kBiplanarPlane0Format);
|
||||
wgpu::TextureDescriptor plane1TextureDescriptor =
|
||||
CreateTextureDescriptor(kBiplanarPlane1Format);
|
||||
wgpu::Texture texture0 = device.CreateTexture(&plane0TextureDescriptor);
|
||||
wgpu::Texture texture1 = device.CreateTexture(&plane1TextureDescriptor);
|
||||
|
||||
wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor();
|
||||
externalDesc.plane0 = texture0.CreateView();
|
||||
externalDesc.plane1 = texture1.CreateView();
|
||||
externalDesc.yuvToRgbConversionMatrix = nullptr;
|
||||
ASSERT_DEVICE_ERROR(device.CreateExternalTexture(&externalDesc));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue