diff --git a/src/dawn/tests/DawnTest.cpp b/src/dawn/tests/DawnTest.cpp index 4a6f9eab66..7e18885241 100644 --- a/src/dawn/tests/DawnTest.cpp +++ b/src/dawn/tests/DawnTest.cpp @@ -1607,6 +1607,18 @@ testing::AssertionResult CheckImpl(const float& expected, return testing::AssertionSuccess(); } +template <> +testing::AssertionResult CheckImpl(const uint16_t& expected, + const uint16_t& actual, + const uint16_t& tolerance) { + if (abs(static_cast(expected) - static_cast(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 329f2661bd..cd915b298c 100644 --- a/src/dawn/tests/end2end/DepthStencilLoadOpTests.cpp +++ b/src/dawn/tests/end2end/DepthStencilLoadOpTests.cpp @@ -128,7 +128,8 @@ class DepthStencilLoadOpTests : public DawnTestWithParams 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 expectedDepth(mipSize * mipSize, kDepthValues[mipLevel]); diff --git a/src/dawn/tests/end2end/MultisampledRenderingTests.cpp b/src/dawn/tests/end2end/MultisampledRenderingTests.cpp index 8fbf961828..407ae7c141 100644 --- a/src/dawn/tests/end2end/MultisampledRenderingTests.cpp +++ b/src/dawn/tests/end2end/MultisampledRenderingTests.cpp @@ -191,7 +191,8 @@ class MultisampledRenderingTest : public DawnTest { 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 @@ TEST_P(MultisampledRenderingTest, ResolveIntoMultipleResolveTargetsWithAlphaToCo // 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 @@ TEST_P(MultisampledRenderingTest, MultisampledRenderingWithDepthTestAndAlphaToCo (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 @@ TEST_P(MultisampledRenderingTest, ResolveInto2DTextureWithAlphaToCoverageAndSamp 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());