Add tolerances to pass several tests on Mac M1 and SwiftShader
Bug: none
Change-Id: I1fea9b59d3d151d2f94fda0793ad47493d98f6fb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105780
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/dawn/tests/DawnTest.cpp b/src/dawn/tests/DawnTest.cpp
index 4a6f9ea..7e18885 100644
--- a/src/dawn/tests/DawnTest.cpp
+++ b/src/dawn/tests/DawnTest.cpp
@@ -1607,6 +1607,18 @@
return testing::AssertionSuccess();
}
+template <>
+testing::AssertionResult CheckImpl<uint16_t>(const uint16_t& expected,
+ const uint16_t& actual,
+ const uint16_t& tolerance) {
+ if (abs(static_cast<int32_t>(expected) - static_cast<int32_t>(actual)) > tolerance) {
+ return tolerance == 0 ? testing::AssertionFailure() << expected << ", actual " << actual
+ : testing::AssertionFailure() << "within " << tolerance << " of "
+ << expected << ", actual " << actual;
+ }
+ return testing::AssertionSuccess();
+}
+
// Interpret uint16_t as float16
// This is mostly for reading float16 output from textures
template <>
diff --git a/src/dawn/tests/end2end/DepthStencilLoadOpTests.cpp b/src/dawn/tests/end2end/DepthStencilLoadOpTests.cpp
index 329f266..cd915b2 100644
--- a/src/dawn/tests/end2end/DepthStencilLoadOpTests.cpp
+++ b/src/dawn/tests/end2end/DepthStencilLoadOpTests.cpp
@@ -128,7 +128,8 @@
std::vector<uint16_t> expectedDepth(mipSize * mipSize,
kU16DepthValues[mipLevel]);
EXPECT_TEXTURE_EQ(expectedDepth.data(), texture, {0, 0}, {mipSize, mipSize},
- mipLevel, wgpu::TextureAspect::DepthOnly)
+ mipLevel, wgpu::TextureAspect::DepthOnly,
+ /* bytesPerRow */ 0, /* tolerance */ uint16_t(1))
<< "copy depth mip " << mipLevel;
} else {
std::vector<float> expectedDepth(mipSize * mipSize, kDepthValues[mipLevel]);
diff --git a/src/dawn/tests/end2end/MultisampledRenderingTests.cpp b/src/dawn/tests/end2end/MultisampledRenderingTests.cpp
index 8fbf961..407ae7c 100644
--- a/src/dawn/tests/end2end/MultisampledRenderingTests.cpp
+++ b/src/dawn/tests/end2end/MultisampledRenderingTests.cpp
@@ -191,7 +191,8 @@
utils::RGBA8 expectedColor = ExpectedMSAAColor(inputColor, msaaCoverage);
EXPECT_TEXTURE_EQ(&expectedColor, resolveTexture, {kMiddleX, kMiddleY, arrayLayer}, {1, 1},
- mipmapLevel);
+ mipmapLevel, wgpu::TextureAspect::All, /* bytesPerRow */ 0,
+ /* tolerance */ utils::RGBA8(1, 1, 1, 1));
}
constexpr static uint32_t kWidth = 3;
@@ -966,17 +967,17 @@
// using only the first one.
utils::RGBA8 expectedRed = ExpectedMSAAColor(kRed, kMSAACoverage);
utils::RGBA8 expectedGreen = ExpectedMSAAColor(kGreen, kMSAACoverage);
- EXPECT_TEXTURE_EQ(&expectedRed, mResolveTexture, {1, 0}, {1, 1});
- EXPECT_TEXTURE_EQ(&expectedGreen, resolveTexture2, {1, 0}, {1, 1});
+ EXPECT_TEXTURE_EQ(&expectedRed, mResolveTexture, {1, 0}, {1, 1},
+ /* level */ 0, wgpu::TextureAspect::All, /* bytesPerRow */ 0,
+ /* tolerance */ utils::RGBA8(1, 1, 1, 1));
+ EXPECT_TEXTURE_EQ(&expectedGreen, resolveTexture2, {1, 0}, {1, 1},
+ /* level */ 0, wgpu::TextureAspect::All, /* bytesPerRow */ 0,
+ /* tolerance */ utils::RGBA8(1, 1, 1, 1));
}
}
// Test multisampled rendering with depth test works correctly with alphaToCoverage.
TEST_P(MultisampledRenderingTest, MultisampledRenderingWithDepthTestAndAlphaToCoverage) {
- // This test fails because Swiftshader is off-by-one with its ((a+b)/2 + (c+d)/2)/2 fast resolve
- // algorithm.
- DAWN_SUPPRESS_TEST_IF(IsSwiftshader() || IsANGLE());
-
// TODO(dawn:1549) Fails on Qualcomm-based Android devices.
// TODO(dawn:1550) Fails on ARM-based Android devices.
DAWN_SUPPRESS_TEST_IF(IsAndroid());
@@ -1032,23 +1033,21 @@
(kGreen.a + kRed.a) / 2.0};
utils::RGBA8 expectedColor = ExpectedMSAAColor(kHalfGreenHalfRed, 1.0f);
- EXPECT_TEXTURE_EQ(&expectedColor, mResolveTexture, {1, 0}, {1, 1});
+ EXPECT_TEXTURE_EQ(&expectedColor, mResolveTexture, {1, 0}, {1, 1},
+ /* level */ 0, wgpu::TextureAspect::All, /* bytesPerRow */ 0,
+ /* tolerance */ utils::RGBA8(1, 1, 1, 1));
}
// Test using one multisampled color attachment with resolve target can render correctly
// with alphaToCoverageEnabled and a sample mask.
TEST_P(MultisampledRenderingTest, ResolveInto2DTextureWithAlphaToCoverageAndSampleMask) {
- // This test fails because Swiftshader is off-by-one with its ((a+b)/2 + (c+d)/2)/2 fast resolve
- // algorithm.
- DAWN_SUPPRESS_TEST_IF(IsSwiftshader() || IsANGLE());
-
// TODO(dawn:1550) Fails on ARM-based Android devices.
DAWN_SUPPRESS_TEST_IF(IsAndroid() && IsARM());
- // TODO(dawn:491): This doesn't work on Metal, because we're using both the shader-output
- // mask (emulting the sampleMask from RenderPipeline) and alpha-to-coverage at the same
- // time. See the issue: https://github.com/gpuweb/gpuweb/issues/959.
- DAWN_SUPPRESS_TEST_IF(IsMetal());
+ // TODO(dawn:491): This doesn't work on non-Apple GPU Metal, because we're using both
+ // the shader-output mask (emulting the sampleMask from RenderPipeline) and alpha-to-coverage
+ // at the same time. See the issue: https://github.com/gpuweb/gpuweb/issues/959.
+ DAWN_SUPPRESS_TEST_IF(IsMetal() && !IsApple());
constexpr bool kTestDepth = false;
constexpr float kMSAACoverage = 0.50f;
@@ -1079,17 +1078,15 @@
queue.Submit(1, &commandBuffer);
utils::RGBA8 expectedColor = ExpectedMSAAColor(kGreen, kMSAACoverage * alpha);
- EXPECT_TEXTURE_EQ(&expectedColor, mResolveTexture, {1, 0}, {1, 1});
+ EXPECT_TEXTURE_EQ(&expectedColor, mResolveTexture, {1, 0}, {1, 1},
+ /* level */ 0, wgpu::TextureAspect::All, /* bytesPerRow */ 0,
+ /* tolerance */ utils::RGBA8(1, 1, 1, 1));
}
}
// Test using one multisampled color attachment with resolve target can render correctly
// with alphaToCoverageEnabled and a rasterization mask.
TEST_P(MultisampledRenderingTest, ResolveInto2DTextureWithAlphaToCoverageAndRasterizationMask) {
- // This test fails because Swiftshader is off-by-one with its ((a+b)/2 + (c+d)/2)/2 fast resolve
- // algorithm.
- DAWN_SUPPRESS_TEST_IF(IsSwiftshader() || IsANGLE());
-
// TODO(dawn:1550) Fails on ARM-based Android devices.
DAWN_SUPPRESS_TEST_IF(IsAndroid() && IsARM());