diff --git a/dawn.json b/dawn.json index 97cff4a410..e9eea726cb 100644 --- a/dawn.json +++ b/dawn.json @@ -881,14 +881,12 @@ {"name": "alpha op", "type": "alpha op", "default": "dont change", "tags": ["deprecated"]}, {"name": "needs color space conversion", "type": "bool", "default": "false"}, {"name": "src alpha mode", "type": "alpha mode", "default": "unpremultiplied"}, - {"name": "transfer function parameters count", "type": "uint32_t", "default": "0"}, {"name": "src transfer function parameters", "type": "float", "annotation": "const*", - "length": "transfer function parameters count", "default": "nullptr"}, - {"name": "conversion matrix elements count", "type": "uint32_t", "default": "0"}, + "length": 7, "optional": true}, {"name": "conversion matrix", "type": "float", "annotation": "const*", - "length": "conversion matrix elements count", "default": "nullptr"}, + "length": 9, "optional": true}, {"name": "dst transfer function parameters", "type": "float", "annotation": "const*", - "length": "transfer function parameters count", "default": "nullptr"}, + "length": 7, "optional": true}, {"name": "dst alpha mode", "type": "alpha mode", "default": "unpremultiplied"} ] }, diff --git a/generator/dawn_json_generator.py b/generator/dawn_json_generator.py index 18c0e95c06..b7efbb0dd5 100644 --- a/generator/dawn_json_generator.py +++ b/generator/dawn_json_generator.py @@ -297,6 +297,10 @@ def linked_record_members(json_data, types): assert False elif m['length'] == 'strlen': member.length = 'strlen' + elif isinstance(m['length'], int): + assert m['length'] > 0 + member.length = "constant" + member.constant_length = m['length'] else: member.length = members_by_name[m['length']] diff --git a/src/dawn_native/CopyTextureForBrowserHelper.cpp b/src/dawn_native/CopyTextureForBrowserHelper.cpp index baf5ed2e47..f9ab3fd766 100644 --- a/src/dawn_native/CopyTextureForBrowserHelper.cpp +++ b/src/dawn_native/CopyTextureForBrowserHelper.cpp @@ -354,13 +354,6 @@ namespace dawn_native { DAWN_TRY(ValidateAlphaMode(options->dstAlphaMode)); if (options->needsColorSpaceConversion) { - DAWN_INVALID_IF(options->transferFunctionParametersCount != 7u, - "Invalid transfer" - " function parameter count (%u).", - options->transferFunctionParametersCount); - DAWN_INVALID_IF(options->conversionMatrixElementsCount != 9u, - "Invalid conversion matrix elements count (%u).", - options->conversionMatrixElementsCount); DAWN_INVALID_IF(options->srcTransferFunctionParameters == nullptr, "srcTransferFunctionParameters is nullptr when doing color conversion"); DAWN_INVALID_IF(options->conversionMatrix == nullptr, @@ -368,7 +361,6 @@ namespace dawn_native { DAWN_INVALID_IF(options->dstTransferFunctionParameters == nullptr, "dstTransferFunctionParameters is nullptr when doing color conversion"); } - return {}; } diff --git a/src/tests/end2end/CopyTextureForBrowserTests.cpp b/src/tests/end2end/CopyTextureForBrowserTests.cpp index 829a23b1a9..f0284e4328 100644 --- a/src/tests/end2end/CopyTextureForBrowserTests.cpp +++ b/src/tests/end2end/CopyTextureForBrowserTests.cpp @@ -916,9 +916,7 @@ class CopyTextureForBrowser_ColorSpace wgpu::CopyTextureForBrowserOptions options = {}; options.needsColorSpaceConversion = srcColorSpace != dstColorSpace; options.srcAlphaMode = GetParam().mSrcAlphaMode; - options.transferFunctionParametersCount = 7; options.srcTransferFunctionParameters = srcColorSpaceInfo.gammaDecodingParams.data(); - options.conversionMatrixElementsCount = 9; options.conversionMatrix = matrix.data(); options.dstTransferFunctionParameters = dstColorSpaceInfo.gammaEncodingParams.data(); options.dstAlphaMode = GetParam().mDstAlphaMode; diff --git a/src/tests/unittests/validation/CopyTextureForBrowserTests.cpp b/src/tests/unittests/validation/CopyTextureForBrowserTests.cpp index 395d19c0f0..74041d9779 100644 --- a/src/tests/unittests/validation/CopyTextureForBrowserTests.cpp +++ b/src/tests/unittests/validation/CopyTextureForBrowserTests.cpp @@ -265,19 +265,17 @@ TEST_F(CopyTextureForBrowserTest, ColorSpaceConversion_ColorSpace) { wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::RenderAttachment); wgpu::CopyTextureForBrowserOptions options = {}; - std::array srcTransferFunctionParameters = {}; - std::array dstTransferFunctionParameters = {}; - std::array conversionMatrix = {}; options.needsColorSpaceConversion = true; - options.srcTransferFunctionParameters = srcTransferFunctionParameters.data(); - options.dstTransferFunctionParameters = dstTransferFunctionParameters.data(); - options.conversionMatrix = conversionMatrix.data(); - options.conversionMatrixElementsCount = 9; - options.transferFunctionParametersCount = 7; // Valid cases { wgpu::CopyTextureForBrowserOptions validOptions = options; + std::array srcTransferFunctionParameters = {}; + std::array dstTransferFunctionParameters = {}; + std::array conversionMatrix = {}; + validOptions.srcTransferFunctionParameters = srcTransferFunctionParameters.data(); + validOptions.dstTransferFunctionParameters = dstTransferFunctionParameters.data(); + validOptions.conversionMatrix = conversionMatrix.data(); TestCopyTextureForBrowser(utils::Expectation::Success, source, 0, {0, 0, 0}, destination, 0, {0, 0, 0}, {4, 4, 1}, wgpu::TextureAspect::All, validOptions); @@ -289,51 +287,51 @@ TEST_F(CopyTextureForBrowserTest, ColorSpaceConversion_ColorSpace) { noColorSpaceConversion); } - // Invalid cases: wrong transferFunctionParametersCount - { - // wrong: transferFunctionParametersCount must be 7 - wgpu::CopyTextureForBrowserOptions invalidOptions = options; - invalidOptions.transferFunctionParametersCount = 6; - TestCopyTextureForBrowser(utils::Expectation::Failure, source, 0, {0, 0, 0}, destination, 0, - {0, 0, 0}, {4, 4, 1}, wgpu::TextureAspect::All, invalidOptions); - } - - // Invalid cases: wrong conversionMatrixElementsCount - { - // wrong: conversionMatrixElementsCount - wgpu::CopyTextureForBrowserOptions invalidOptions = options; - invalidOptions.transferFunctionParametersCount = 10; - TestCopyTextureForBrowser(utils::Expectation::Failure, source, 0, {0, 0, 0}, destination, 0, - {0, 0, 0}, {4, 4, 1}, wgpu::TextureAspect::All, invalidOptions); - } - // Invalid cases: srcTransferFunctionParameters, dstTransferFunctionParameters or - // conversionMatrix is nullptr + // conversionMatrix is nullptr or not set { + // not set srcTransferFunctionParameters wgpu::CopyTextureForBrowserOptions invalidOptions = options; - if (UsesWire()) { - invalidOptions.transferFunctionParametersCount = 0; - } + std::array dstTransferFunctionParameters = {}; + std::array conversionMatrix = {}; + invalidOptions.dstTransferFunctionParameters = dstTransferFunctionParameters.data(); + invalidOptions.conversionMatrix = conversionMatrix.data(); + TestCopyTextureForBrowser(utils::Expectation::Failure, source, 0, {0, 0, 0}, destination, 0, + {0, 0, 0}, {4, 4, 1}, wgpu::TextureAspect::All, invalidOptions); + + // set to nullptr invalidOptions.srcTransferFunctionParameters = nullptr; TestCopyTextureForBrowser(utils::Expectation::Failure, source, 0, {0, 0, 0}, destination, 0, {0, 0, 0}, {4, 4, 1}, wgpu::TextureAspect::All, invalidOptions); } { + // not set dstTransferFunctionParameters wgpu::CopyTextureForBrowserOptions invalidOptions = options; - if (UsesWire()) { - invalidOptions.transferFunctionParametersCount = 0; - } + std::array srcTransferFunctionParameters = {}; + std::array conversionMatrix = {}; + invalidOptions.srcTransferFunctionParameters = srcTransferFunctionParameters.data(); + invalidOptions.conversionMatrix = conversionMatrix.data(); + TestCopyTextureForBrowser(utils::Expectation::Failure, source, 0, {0, 0, 0}, destination, 0, + {0, 0, 0}, {4, 4, 1}, wgpu::TextureAspect::All, invalidOptions); + + // set to nullptr invalidOptions.dstTransferFunctionParameters = nullptr; TestCopyTextureForBrowser(utils::Expectation::Failure, source, 0, {0, 0, 0}, destination, 0, {0, 0, 0}, {4, 4, 1}, wgpu::TextureAspect::All, invalidOptions); } { + // not set conversionMatrix wgpu::CopyTextureForBrowserOptions invalidOptions = options; - if (UsesWire()) { - invalidOptions.conversionMatrixElementsCount = 0; - } + std::array srcTransferFunctionParameters = {}; + std::array dstTransferFunctionParameters = {}; + invalidOptions.srcTransferFunctionParameters = srcTransferFunctionParameters.data(); + invalidOptions.dstTransferFunctionParameters = dstTransferFunctionParameters.data(); + TestCopyTextureForBrowser(utils::Expectation::Failure, source, 0, {0, 0, 0}, destination, 0, + {0, 0, 0}, {4, 4, 1}, wgpu::TextureAspect::All, invalidOptions); + + // set to nullptr invalidOptions.conversionMatrix = nullptr; TestCopyTextureForBrowser(utils::Expectation::Failure, source, 0, {0, 0, 0}, destination, 0, {0, 0, 0}, {4, 4, 1}, wgpu::TextureAspect::All, invalidOptions);