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 <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Brandon Jones 2022-10-05 16:10:44 +00:00 committed by Dawn LUCI CQ
parent 761536d941
commit f35c719054
4 changed files with 29 additions and 10 deletions

View File

@ -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);
}

View File

@ -1581,6 +1581,20 @@ testing::AssertionResult CheckImpl(const T& expected, const U& actual, const T&
return testing::AssertionSuccess();
}
template <>
testing::AssertionResult CheckImpl<utils::RGBA8>(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<float>(const float& expected,
const float& actual,

View File

@ -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<T, U>(file, line, this->device, expectedData, texture, origin,
extent, level, aspect, bytesPerRow);
extent, level, aspect, bytesPerRow, tolerance);
}
template <typename T, typename U = T>
@ -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<T, U>(expectedData,
extent.width * extent.height * extent.depthOrArrayLayers),
new detail::ExpectEq<T, U>(
expectedData, extent.width * extent.height * extent.depthOrArrayLayers, tolerance),
texture, origin, extent, level, aspect, sizeof(U), bytesPerRow);
}

View File

@ -219,8 +219,13 @@ class CompressedTextureFormatTest : public DawnTestWithParams<CompressedTextureF
wgpu::CommandBuffer commands = encoder.Finish();
queue.Submit(1, &commands);
// Some mobile chipsets decode the compressed texture values with a lower precision, leading
// to color channels that are off by one from the expected result. This check is given a
// little bit of tolerance to account for it. See dawn:1562.
EXPECT_TEXTURE_EQ(expected.data(), renderPass.color, {expectedOrigin.x, expectedOrigin.y},
{expectedExtent.width, expectedExtent.height});
{expectedExtent.width, expectedExtent.height},
/* level */ 0, /* aspect */ wgpu::TextureAspect::All,
/* bytesPerRow */ 0, /* Tolerance */ utils::RGBA8(1, 1, 1, 1));
}
// Run the tests that copies pre-prepared format data into a texture and verifies if we can