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>
This commit is contained in:
parent
79f05996e1
commit
e9ad15ae7f
|
@ -1607,6 +1607,18 @@ testing::AssertionResult CheckImpl<float>(const float& expected,
|
|||
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 <>
|
||||
|
|
|
@ -128,7 +128,8 @@ class DepthStencilLoadOpTests : public DawnTestWithParams<DepthStencilLoadOpTest
|
|||
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]);
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
Loading…
Reference in New Issue