From f35c7190540806030ce564db1cde3b84a3c8e7be Mon Sep 17 00:00:00 2001 From: Brandon Jones Date: Wed, 5 Oct 2022 16:10:44 +0000 Subject: [PATCH] Allow tolerance on compressed texture verification Qualcomm GPUs are apparently decoding textures with a lower precision, resulting in some of the rendered values when verifying the texture in a test to be off by +-1 on any given channel. This change adds a tolerance to those tests to allow a little wiggle room, since compressed textures are inherently lossy anyway. Allows Qualcomm GPUs to pass all compressed texture end2end tests. Bug: dawn:1562 Change-Id: I08a21b9ce361486c247c34640080b369ae2b799d Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104622 Reviewed-by: Austin Eng Reviewed-by: Corentin Wallez Commit-Queue: Brandon Jones Kokoro: Kokoro --- src/dawn/native/vulkan/AdapterVk.cpp | 6 ++---- src/dawn/tests/DawnTest.cpp | 14 ++++++++++++++ src/dawn/tests/DawnTest.h | 12 +++++++----- .../tests/end2end/CompressedTextureFormatTests.cpp | 7 ++++++- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/dawn/native/vulkan/AdapterVk.cpp b/src/dawn/native/vulkan/AdapterVk.cpp index a4dc1ddf94..3779f9b68c 100644 --- a/src/dawn/native/vulkan/AdapterVk.cpp +++ b/src/dawn/native/vulkan/AdapterVk.cpp @@ -135,13 +135,11 @@ MaybeError Adapter::InitializeSupportedFeaturesImpl() { mSupportedFeatures.EnableFeature(Feature::TextureCompressionBC); } - // TODO(dawn:1549) Fails on Qualcomm-based Android devices. - if (mDeviceInfo.features.textureCompressionETC2 == VK_TRUE && !IsAndroidQualcomm()) { + if (mDeviceInfo.features.textureCompressionETC2 == VK_TRUE) { mSupportedFeatures.EnableFeature(Feature::TextureCompressionETC2); } - // TODO(dawn:1549) Fails on Qualcomm-based Android devices. - if (mDeviceInfo.features.textureCompressionASTC_LDR == VK_TRUE && !IsAndroidQualcomm()) { + if (mDeviceInfo.features.textureCompressionASTC_LDR == VK_TRUE) { mSupportedFeatures.EnableFeature(Feature::TextureCompressionASTC); } diff --git a/src/dawn/tests/DawnTest.cpp b/src/dawn/tests/DawnTest.cpp index 0f0312468b..4a6f9eab66 100644 --- a/src/dawn/tests/DawnTest.cpp +++ b/src/dawn/tests/DawnTest.cpp @@ -1581,6 +1581,20 @@ testing::AssertionResult CheckImpl(const T& expected, const U& actual, const T& return testing::AssertionSuccess(); } +template <> +testing::AssertionResult CheckImpl(const utils::RGBA8& expected, + const utils::RGBA8& actual, + const utils::RGBA8& tolerance) { + if (abs(expected.r - actual.r) > tolerance.r || abs(expected.g - actual.g) > tolerance.g || + abs(expected.b - actual.b) > tolerance.b || abs(expected.a - actual.a) > tolerance.a) { + return tolerance == utils::RGBA8{} + ? testing::AssertionFailure() << expected << ", actual " << actual + : testing::AssertionFailure() + << "within " << tolerance << " of " << expected << ", actual " << actual; + } + return testing::AssertionSuccess(); +} + template <> testing::AssertionResult CheckImpl(const float& expected, const float& actual, diff --git a/src/dawn/tests/DawnTest.h b/src/dawn/tests/DawnTest.h index e1dfe09e9d..b81acc8fcf 100644 --- a/src/dawn/tests/DawnTest.h +++ b/src/dawn/tests/DawnTest.h @@ -360,10 +360,11 @@ class DawnTestBase { wgpu::Extent3D extent, uint32_t level = 0, wgpu::TextureAspect aspect = wgpu::TextureAspect::All, - uint32_t bytesPerRow = 0) { + uint32_t bytesPerRow = 0, + T tolerance = {}) { // No device passed explicitly. Default it, and forward the rest of the args. return AddTextureExpectation(file, line, this->device, expectedData, texture, origin, - extent, level, aspect, bytesPerRow); + extent, level, aspect, bytesPerRow, tolerance); } template @@ -376,11 +377,12 @@ class DawnTestBase { wgpu::Extent3D extent, uint32_t level = 0, wgpu::TextureAspect aspect = wgpu::TextureAspect::All, - uint32_t bytesPerRow = 0) { + uint32_t bytesPerRow = 0, + T tolerance = {}) { return AddTextureExpectationImpl( file, line, std::move(targetDevice), - new detail::ExpectEq(expectedData, - extent.width * extent.height * extent.depthOrArrayLayers), + new detail::ExpectEq( + expectedData, extent.width * extent.height * extent.depthOrArrayLayers, tolerance), texture, origin, extent, level, aspect, sizeof(U), bytesPerRow); } diff --git a/src/dawn/tests/end2end/CompressedTextureFormatTests.cpp b/src/dawn/tests/end2end/CompressedTextureFormatTests.cpp index aea386914c..923237d8bb 100644 --- a/src/dawn/tests/end2end/CompressedTextureFormatTests.cpp +++ b/src/dawn/tests/end2end/CompressedTextureFormatTests.cpp @@ -219,8 +219,13 @@ class CompressedTextureFormatTest : public DawnTestWithParams