diff --git a/dawn.json b/dawn.json index 7d8a79ee91..2e82ff3f75 100644 --- a/dawn.json +++ b/dawn.json @@ -1334,13 +1334,13 @@ {"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, "optional": true}, + "length": 12}, {"name": "src transfer function parameters", "type": "float", "annotation": "const*", - "length": 7, "optional": true}, + "length": 7}, {"name": "dst transfer function parameters", "type": "float", "annotation": "const*", - "length": 7, "optional": true}, + "length": 7}, {"name": "gamut conversion matrix", "type": "float", "annotation": "const*", - "length": 9, "optional": true}, + "length": 9}, {"name": "color space", "type": "predefined color space", "default": "srgb"} ] }, diff --git a/src/dawn/native/ExternalTexture.cpp b/src/dawn/native/ExternalTexture.cpp index 53029570b8..e9fa5a7a80 100644 --- a/src/dawn/native/ExternalTexture.cpp +++ b/src/dawn/native/ExternalTexture.cpp @@ -14,6 +14,7 @@ #include "dawn/native/ExternalTexture.h" +#include #include #include "dawn/native/Buffer.h" @@ -56,6 +57,18 @@ 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."); + + DAWN_INVALID_IF(!descriptor->srcTransferFunctionParameters, + "The source transfer function parameters must be non-null."); + + DAWN_INVALID_IF(!descriptor->dstTransferFunctionParameters, + "The destination transfer function parameters must be non-null."); + if (descriptor->plane1) { DAWN_INVALID_IF(descriptor->colorSpace != wgpu::PredefinedColorSpace::Srgb, "The specified color space (%s) is not %s.", descriptor->colorSpace, @@ -139,46 +152,34 @@ MaybeError ExternalTextureBase::Initialize(DeviceBase* device, DAWN_TRY_ASSIGN(mParamsBuffer, device->CreateBuffer(&bufferDesc)); - // Dawn & Tint's YUV-to-RGB conversion implementation is a simple 3x4 matrix multiplication - // using a standard conversion matrix. These matrices can be found in - // chromium/src/third_party/skia/src/core/SkYUVMath.cpp ExternalTextureParams params; params.numPlanes = descriptor->plane1 == nullptr ? 1 : 2; - // TODO(dawn:1082): Make this field configurable from outside of Dawn. - // Conversion matrix for BT.709 limited range. Columns 1, 2 and 3 are copied - // directly from the corresponding matrix in SkYUVMath.cpp. Column 4 is the range - // bias (for RGB) found in column 5 of the same SkYUVMath.cpp matrix. - params.yuvToRgbConversionMatrix = {1.164384f, 0.0f, 1.792741f, -0.972945f, - 1.164384f, -0.213249f, -0.532909f, 0.301483f, - 1.164384f, 2.112402f, 0.0f, -1.133402f}; + // 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()); - // TODO(dawn:1082): Make this field configurable from outside of Dawn. - // Use an identity matrix when converting BT.709 to sRGB because they shared the - // same primaries. - params.gamutConversionMatrix = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f}; + // Gamut correction is performed by multiplying a 3x3 matrix passed from Chromium. The + // matrix was computed by multiplying the appropriate source and destination gamut + // matrices sourced from ui/gfx/color_space.cc. + const float* gMat = descriptor->gamutConversionMatrix; + params.gamutConversionMatrix = {gMat[0], gMat[1], gMat[2], 0.0f, // + gMat[3], gMat[4], gMat[5], 0.0f, // + gMat[6], gMat[7], gMat[8], 0.0f}; - switch (descriptor->colorSpace) { - case wgpu::PredefinedColorSpace::Undefined: - // Undefined color space should eventually produce an error. For now, these - // constants will effectively perform no gamma correction so tests can continue - // passing. - params.gammaDecodingParams = {1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0}; - params.gammaEncodingParams = {1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0}; - break; - case wgpu::PredefinedColorSpace::Srgb: - // TODO(dawn:1082): Make this field configurable from outside of Dawn. - // These are the inverted parameters as specified by Rec. ITU-R BT.1886 for BT.709 - params.gammaDecodingParams = {2.2, 1.0 / 1.099, 0.099 / 1.099, 1 / 4.5, 0.081, - 0.0, 0.0}; + // Gamma decode/encode is performed by the logic: + // if (abs(v) < params.D) { + // return sign(v) * (params.C * abs(v) + params.F); + // } + // return pow(A * x + B, G) + E + // + // Constants are passed from Chromium and originally sourced from ui/gfx/color_space.cc + const float* srcFn = descriptor->srcTransferFunctionParameters; + std::copy(srcFn, srcFn + 7, params.gammaDecodingParams.begin()); - // Constants for sRGB transfer function pulled from - // https://en.wikipedia.org/wiki/SRGB - params.gammaEncodingParams = { - 1 / 2.4, 1.137119 /*1.055^2.4*/, 0.0, 12.92, 0.0031308, -0.055, 0.0}; - break; - } + const float* dstFn = descriptor->dstTransferFunctionParameters; + std::copy(dstFn, dstFn + 7, params.gammaEncodingParams.begin()); DAWN_TRY(device->GetQueue()->WriteBuffer(mParamsBuffer.Get(), 0, ¶ms, sizeof(ExternalTextureParams))); diff --git a/src/dawn/native/ExternalTexture.h b/src/dawn/native/ExternalTexture.h index fcb8390780..50f3b89885 100644 --- a/src/dawn/native/ExternalTexture.h +++ b/src/dawn/native/ExternalTexture.h @@ -26,23 +26,12 @@ namespace dawn::native { class TextureViewBase; -struct GammaTransferParams { - float G = 0.0; - float A = 0.0; - float B = 0.0; - float C = 0.0; - float D = 0.0; - float E = 0.0; - float F = 0.0; - uint32_t padding = 0; -}; - struct ExternalTextureParams { uint32_t numPlanes; std::array padding; std::array yuvToRgbConversionMatrix; - GammaTransferParams gammaDecodingParams = {}; - GammaTransferParams gammaEncodingParams = {}; + std::array gammaDecodingParams = {}; + std::array gammaEncodingParams = {}; std::array gamutConversionMatrix = {}; }; diff --git a/src/dawn/tests/end2end/ExternalTextureTests.cpp b/src/dawn/tests/end2end/ExternalTextureTests.cpp index 4215c7765a..6d15a41139 100644 --- a/src/dawn/tests/end2end/ExternalTextureTests.cpp +++ b/src/dawn/tests/end2end/ExternalTextureTests.cpp @@ -37,10 +37,28 @@ wgpu::Texture Create2DTexture(wgpu::Device device, class ExternalTextureTests : public DawnTest { protected: + wgpu::ExternalTextureDescriptor CreateDefaultExternalTextureDescriptor() { + wgpu::ExternalTextureDescriptor desc; + desc.yuvToRgbConversionMatrix = kYuvToRGBMatrixBT709.data(); + desc.gamutConversionMatrix = kGamutConversionMatrixBT709ToSrgb.data(); + desc.srcTransferFunctionParameters = kGammaDecodeBT709.data(); + desc.dstTransferFunctionParameters = kGammaEncodeSrgb.data(); + + return desc; + } + static constexpr uint32_t kWidth = 4; static constexpr uint32_t kHeight = 4; static constexpr wgpu::TextureFormat kFormat = wgpu::TextureFormat::RGBA8Unorm; static constexpr wgpu::TextureUsage kSampledUsage = wgpu::TextureUsage::TextureBinding; + std::array kYuvToRGBMatrixBT709 = {1.164384f, 0.0f, 1.792741f, -0.972945f, + 1.164384f, -0.213249f, -0.532909f, 0.301483f, + 1.164384f, 2.112402f, 0.0f, -1.133402f}; + std::array kGamutConversionMatrixBT709ToSrgb = {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + std::array kGammaDecodeBT709 = {2.2, 1.0 / 1.099, 0.099 / 1.099, 1 / 4.5, 0.081, + 0.0, 0.0}; + std::array kGammaEncodeSrgb = {1 / 2.4, 1.137119, 0.0, 12.92, 0.0031308, -0.055, 0.0}; }; } // anonymous namespace @@ -51,7 +69,7 @@ TEST_P(ExternalTextureTests, CreateExternalTextureSuccess) { wgpu::TextureView view = texture.CreateView(); // Create an ExternalTextureDescriptor from the texture view - wgpu::ExternalTextureDescriptor externalDesc; + wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor(); externalDesc.plane0 = view; // Import the external texture @@ -114,7 +132,7 @@ TEST_P(ExternalTextureTests, SampleExternalTexture) { wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); // Create an ExternalTextureDescriptor from the texture view - wgpu::ExternalTextureDescriptor externalDesc; + wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor(); externalDesc.plane0 = externalView; // Import the external texture @@ -225,7 +243,7 @@ TEST_P(ExternalTextureTests, SampleMultiplanarExternalTexture) { wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); // Create an ExternalTextureDescriptor from the texture views - wgpu::ExternalTextureDescriptor externalDesc; + wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor(); externalDesc.plane0 = externalViewPlane0; externalDesc.plane1 = externalViewPlane1; diff --git a/src/dawn/tests/unittests/validation/BindGroupValidationTests.cpp b/src/dawn/tests/unittests/validation/BindGroupValidationTests.cpp index e916ec7240..a4293cb0f8 100644 --- a/src/dawn/tests/unittests/validation/BindGroupValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/BindGroupValidationTests.cpp @@ -60,7 +60,8 @@ class BindGroupValidationTest : public ValidationTest { CreateTexture(wgpu::TextureUsage::TextureBinding, kDefaultTextureFormat, 1); mSampledTextureView = mSampledTexture.CreateView(); - wgpu::ExternalTextureDescriptor externalTextureDesc; + wgpu::ExternalTextureDescriptor externalTextureDesc = + CreateDefaultExternalTextureDescriptor(); externalTextureDesc.plane0 = mSampledTextureView; mExternalTexture = device.CreateExternalTexture(&externalTextureDesc); mExternalTextureBindingEntry.externalTexture = mExternalTexture; @@ -68,6 +69,15 @@ class BindGroupValidationTest : public ValidationTest { } protected: + wgpu::ExternalTextureDescriptor CreateDefaultExternalTextureDescriptor() { + wgpu::ExternalTextureDescriptor desc; + desc.yuvToRgbConversionMatrix = mPlaceholderConstantArray.data(); + desc.gamutConversionMatrix = mPlaceholderConstantArray.data(); + desc.srcTransferFunctionParameters = mPlaceholderConstantArray.data(); + desc.dstTransferFunctionParameters = mPlaceholderConstantArray.data(); + return desc; + } + wgpu::Buffer mUBO; wgpu::Buffer mSSBO; wgpu::Sampler mSampler; @@ -79,6 +89,7 @@ class BindGroupValidationTest : public ValidationTest { private: wgpu::ExternalTexture mExternalTexture; + std::array mPlaceholderConstantArray; }; // Test the validation of BindGroupDescriptor::nextInChain @@ -311,7 +322,7 @@ TEST_F(BindGroupValidationTest, ExternalTextureBindingType) { // Create an external texture wgpu::Texture texture = CreateTexture(wgpu::TextureUsage::TextureBinding, kDefaultTextureFormat, 1); - wgpu::ExternalTextureDescriptor externalDesc; + wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor(); externalDesc.plane0 = texture.CreateView(); wgpu::ExternalTexture externalTexture = device.CreateExternalTexture(&externalDesc); @@ -360,7 +371,8 @@ TEST_F(BindGroupValidationTest, ExternalTextureBindingType) { { wgpu::Texture errorTexture = CreateTexture(wgpu::TextureUsage::TextureBinding, wgpu::TextureFormat::RGBA8UnormSrgb, 1); - wgpu::ExternalTextureDescriptor errorExternalDesciptor; + wgpu::ExternalTextureDescriptor errorExternalDesciptor = + CreateDefaultExternalTextureDescriptor(); errorExternalDesciptor.plane0 = errorTexture.CreateView(); wgpu::ExternalTexture errorExternalTexture; diff --git a/src/dawn/tests/unittests/validation/ExternalTextureTests.cpp b/src/dawn/tests/unittests/validation/ExternalTextureTests.cpp index 340b8f774c..e4afd81b45 100644 --- a/src/dawn/tests/unittests/validation/ExternalTextureTests.cpp +++ b/src/dawn/tests/unittests/validation/ExternalTextureTests.cpp @@ -41,6 +41,16 @@ class ExternalTextureTest : public ValidationTest { queue = device.GetQueue(); } + wgpu::ExternalTextureDescriptor CreateDefaultExternalTextureDescriptor() { + wgpu::ExternalTextureDescriptor desc; + desc.yuvToRgbConversionMatrix = mPlaceholderConstantArray.data(); + desc.gamutConversionMatrix = mPlaceholderConstantArray.data(); + desc.srcTransferFunctionParameters = mPlaceholderConstantArray.data(); + desc.dstTransferFunctionParameters = mPlaceholderConstantArray.data(); + + return desc; + } + static constexpr uint32_t kWidth = 32; static constexpr uint32_t kHeight = 32; static constexpr uint32_t kDefaultDepth = 1; @@ -53,6 +63,8 @@ class ExternalTextureTest : public ValidationTest { static constexpr wgpu::TextureFormat kBiplanarPlane0Format = wgpu::TextureFormat::R8Unorm; static constexpr wgpu::TextureFormat kBiplanarPlane1Format = wgpu::TextureFormat::RG8Unorm; + std::array mPlaceholderConstantArray; + wgpu::Queue queue; }; @@ -62,7 +74,7 @@ TEST_F(ExternalTextureTest, CreateExternalTextureValidation) { wgpu::TextureDescriptor textureDescriptor = CreateTextureDescriptor(); wgpu::Texture texture = device.CreateTexture(&textureDescriptor); - wgpu::ExternalTextureDescriptor externalDesc; + wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor(); externalDesc.plane0 = texture.CreateView(); device.CreateExternalTexture(&externalDesc); } @@ -74,7 +86,7 @@ TEST_F(ExternalTextureTest, CreateExternalTextureValidation) { textureDescriptor.usage = wgpu::TextureUsage::TextureBinding; wgpu::Texture internalTexture = device.CreateTexture(&textureDescriptor); - wgpu::ExternalTextureDescriptor externalDesc; + wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor(); externalDesc.plane0 = internalTexture.CreateView(); ASSERT_DEVICE_ERROR(device.CreateExternalTexture(&externalDesc)); } @@ -85,7 +97,7 @@ TEST_F(ExternalTextureTest, CreateExternalTextureValidation) { textureDescriptor.mipLevelCount = 2; wgpu::Texture internalTexture = device.CreateTexture(&textureDescriptor); - wgpu::ExternalTextureDescriptor externalDesc; + wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor(); externalDesc.plane0 = internalTexture.CreateView(); ASSERT_DEVICE_ERROR(device.CreateExternalTexture(&externalDesc)); } @@ -97,7 +109,7 @@ TEST_F(ExternalTextureTest, CreateExternalTextureValidation) { textureDescriptor.mipLevelCount = 2; wgpu::Texture internalTexture = device.CreateTexture(&textureDescriptor); - wgpu::ExternalTextureDescriptor externalDesc; + wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor(); externalDesc.plane0 = internalTexture.CreateView(); ASSERT_DEVICE_ERROR(device.CreateExternalTexture(&externalDesc)); } @@ -108,7 +120,7 @@ TEST_F(ExternalTextureTest, CreateExternalTextureValidation) { textureDescriptor.format = wgpu::TextureFormat::R8Uint; wgpu::Texture internalTexture = device.CreateTexture(&textureDescriptor); - wgpu::ExternalTextureDescriptor externalDesc; + wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor(); externalDesc.plane0 = internalTexture.CreateView(); ASSERT_DEVICE_ERROR(device.CreateExternalTexture(&externalDesc)); } @@ -119,7 +131,7 @@ TEST_F(ExternalTextureTest, CreateExternalTextureValidation) { textureDescriptor.sampleCount = 4; wgpu::Texture internalTexture = device.CreateTexture(&textureDescriptor); - wgpu::ExternalTextureDescriptor externalDesc; + wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor(); externalDesc.plane0 = internalTexture.CreateView(); ASSERT_DEVICE_ERROR(device.CreateExternalTexture(&externalDesc)); } @@ -137,12 +149,59 @@ TEST_F(ExternalTextureTest, CreateExternalTextureValidation) { ASSERT_DEVICE_ERROR(wgpu::TextureView errorTextureView = internalTexture.CreateView(&errorViewDescriptor)); - wgpu::ExternalTextureDescriptor externalDesc; + wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor(); externalDesc.plane0 = errorTextureView; ASSERT_DEVICE_ERROR(device.CreateExternalTexture(&externalDesc)); } } +TEST_F(ExternalTextureTest, CreateExternalTextureConstantValueValidation) { + DAWN_SKIP_TEST_IF(UsesWire()); + // Creating an external texture without a YUV-to-RGB matrix should fail. + { + wgpu::TextureDescriptor textureDescriptor = CreateTextureDescriptor(); + wgpu::Texture texture = device.CreateTexture(&textureDescriptor); + + wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor(); + externalDesc.plane0 = texture.CreateView(); + externalDesc.yuvToRgbConversionMatrix = nullptr; + ASSERT_DEVICE_ERROR(device.CreateExternalTexture(&externalDesc)); + } + + // Creating an external texture without a gamut conversion matrix should fail. + { + wgpu::TextureDescriptor textureDescriptor = CreateTextureDescriptor(); + wgpu::Texture texture = device.CreateTexture(&textureDescriptor); + + wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor(); + externalDesc.plane0 = texture.CreateView(); + externalDesc.gamutConversionMatrix = nullptr; + ASSERT_DEVICE_ERROR(device.CreateExternalTexture(&externalDesc)); + } + + // Creating an external texture without source transfer function constants should fail. + { + wgpu::TextureDescriptor textureDescriptor = CreateTextureDescriptor(); + wgpu::Texture texture = device.CreateTexture(&textureDescriptor); + + wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor(); + externalDesc.plane0 = texture.CreateView(); + externalDesc.srcTransferFunctionParameters = nullptr; + ASSERT_DEVICE_ERROR(device.CreateExternalTexture(&externalDesc)); + } + + // Creating an external texture without destination transfer function constants should fail. + { + wgpu::TextureDescriptor textureDescriptor = CreateTextureDescriptor(); + wgpu::Texture texture = device.CreateTexture(&textureDescriptor); + + wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor(); + externalDesc.plane0 = texture.CreateView(); + externalDesc.dstTransferFunctionParameters = nullptr; + ASSERT_DEVICE_ERROR(device.CreateExternalTexture(&externalDesc)); + } +} + // Test that external texture creation works as expected in multiplane scenarios. TEST_F(ExternalTextureTest, CreateMultiplanarExternalTextureValidation) { // Creating an external texture from two 2D, single-subresource textures with a biplanar @@ -155,7 +214,7 @@ TEST_F(ExternalTextureTest, CreateMultiplanarExternalTextureValidation) { wgpu::Texture texture0 = device.CreateTexture(&plane0TextureDescriptor); wgpu::Texture texture1 = device.CreateTexture(&plane1TextureDescriptor); - wgpu::ExternalTextureDescriptor externalDesc; + wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor(); externalDesc.plane0 = texture0.CreateView(); externalDesc.plane1 = texture1.CreateView(); @@ -172,7 +231,7 @@ TEST_F(ExternalTextureTest, CreateMultiplanarExternalTextureValidation) { wgpu::Texture texture0 = device.CreateTexture(&plane0TextureDescriptor); wgpu::Texture texture1 = device.CreateTexture(&plane1TextureDescriptor); - wgpu::ExternalTextureDescriptor externalDesc; + wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor(); externalDesc.plane0 = texture0.CreateView(); externalDesc.plane1 = texture1.CreateView(); @@ -189,7 +248,7 @@ TEST_F(ExternalTextureTest, CreateMultiplanarExternalTextureValidation) { wgpu::Texture texture0 = device.CreateTexture(&plane0TextureDescriptor); wgpu::Texture texture1 = device.CreateTexture(&plane1TextureDescriptor); - wgpu::ExternalTextureDescriptor externalDesc; + wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor(); externalDesc.plane0 = texture0.CreateView(); externalDesc.plane1 = texture1.CreateView(); @@ -205,7 +264,7 @@ TEST_F(ExternalTextureTest, CreateMultiplanarExternalTextureValidation) { wgpu::Texture texture0 = device.CreateTexture(&plane0TextureDescriptor); wgpu::Texture texture1 = device.CreateTexture(&plane1TextureDescriptor); - wgpu::ExternalTextureDescriptor externalDesc; + wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor(); externalDesc.plane0 = texture0.CreateView(); externalDesc.plane1 = texture1.CreateView(); externalDesc.colorSpace = wgpu::PredefinedColorSpace::Undefined; @@ -219,7 +278,7 @@ TEST_F(ExternalTextureTest, SubmitDestroyedExternalTextureInRenderPass) { wgpu::TextureDescriptor textureDescriptor = CreateTextureDescriptor(); wgpu::Texture texture = device.CreateTexture(&textureDescriptor); - wgpu::ExternalTextureDescriptor externalDesc; + wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor(); externalDesc.plane0 = texture.CreateView(); wgpu::ExternalTexture externalTexture = device.CreateExternalTexture(&externalDesc); @@ -270,7 +329,7 @@ TEST_F(ExternalTextureTest, SubmitDereferencedExternalTextureInRenderPass) { wgpu::TextureDescriptor textureDescriptor = CreateTextureDescriptor(); wgpu::Texture texture = device.CreateTexture(&textureDescriptor); - wgpu::ExternalTextureDescriptor externalDesc; + wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor(); externalDesc.plane0 = texture.CreateView(); wgpu::ExternalTexture externalTexture = device.CreateExternalTexture(&externalDesc); @@ -321,7 +380,7 @@ TEST_F(ExternalTextureTest, SubmitDestroyedExternalTexturePlaneInRenderPass) { wgpu::TextureDescriptor textureDescriptor = CreateTextureDescriptor(); wgpu::Texture texture = device.CreateTexture(&textureDescriptor); - wgpu::ExternalTextureDescriptor externalDesc; + wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor(); externalDesc.plane0 = texture.CreateView(); wgpu::ExternalTexture externalTexture = device.CreateExternalTexture(&externalDesc); @@ -372,7 +431,7 @@ TEST_F(ExternalTextureTest, SubmitDestroyedExternalTextureInComputePass) { wgpu::TextureDescriptor textureDescriptor = CreateTextureDescriptor(); wgpu::Texture texture = device.CreateTexture(&textureDescriptor); - wgpu::ExternalTextureDescriptor externalDesc; + wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor(); externalDesc.plane0 = texture.CreateView(); wgpu::ExternalTexture externalTexture = device.CreateExternalTexture(&externalDesc); @@ -418,7 +477,7 @@ TEST_F(ExternalTextureTest, SubmitDestroyedExternalTexturePlaneInComputePass) { wgpu::TextureDescriptor textureDescriptor = CreateTextureDescriptor(); wgpu::Texture texture = device.CreateTexture(&textureDescriptor); - wgpu::ExternalTextureDescriptor externalDesc; + wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor(); externalDesc.plane0 = texture.CreateView(); wgpu::ExternalTexture externalTexture = device.CreateExternalTexture(&externalDesc); @@ -462,7 +521,7 @@ TEST_F(ExternalTextureTest, BindGroupDoesNotMatchLayout) { wgpu::TextureDescriptor textureDescriptor = CreateTextureDescriptor(); wgpu::Texture texture = device.CreateTexture(&textureDescriptor); - wgpu::ExternalTextureDescriptor externalDesc; + wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor(); externalDesc.plane0 = texture.CreateView(); wgpu::ExternalTexture externalTexture = device.CreateExternalTexture(&externalDesc); diff --git a/src/dawn/tests/unittests/validation/LabelTests.cpp b/src/dawn/tests/unittests/validation/LabelTests.cpp index ebecbf699b..3bba45f50d 100644 --- a/src/dawn/tests/unittests/validation/LabelTests.cpp +++ b/src/dawn/tests/unittests/validation/LabelTests.cpp @@ -229,6 +229,11 @@ TEST_F(LabelTest, ExternalTexture) { wgpu::ExternalTextureDescriptor descriptor; descriptor.plane0 = texture.CreateView(); + std::array mPlaceholderConstantArray; + descriptor.yuvToRgbConversionMatrix = mPlaceholderConstantArray.data(); + descriptor.gamutConversionMatrix = mPlaceholderConstantArray.data(); + descriptor.srcTransferFunctionParameters = mPlaceholderConstantArray.data(); + descriptor.dstTransferFunctionParameters = mPlaceholderConstantArray.data(); // The label should be empty if one was not set. {