From fd7390a5874d9354dc9ea68d5d3df8f9c5c2e650 Mon Sep 17 00:00:00 2001 From: Jiawei Shao Date: Thu, 30 Jun 2022 14:57:52 +0000 Subject: [PATCH] Implement ResolveDeferredExpectationsNow() for dawn_end2end_tests This patch adds ResolveDeferredExpectationsNow() as a helper function of dawn_end2end_tests to let all the deferred expectations be resolved and cleared immediately to avoid consuming too much memory for all the deferred expectations before the exit of the test body. We use ResolveDeferredExpectationsNow() in the end2end test CopyFromNonZeroMipLevelWithTexelBlockSizeLessThan4Bytes because previously because this test will always consume too much memory to allocate vectors and the allocation of std:vector will sometimes fail on the bots. Bug: chromium:1312066 Test: dawn_end2end_tests Change-Id: I5a87338b0683a3a821eef888fb6469e6ac2dc075 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94986 Kokoro: Kokoro Reviewed-by: Corentin Wallez Reviewed-by: Austin Eng Commit-Queue: Austin Eng --- src/dawn/tests/DawnTest.cpp | 21 +++++++++++++-------- src/dawn/tests/DawnTest.h | 4 ++++ src/dawn/tests/end2end/CopyTests.cpp | 7 ++++--- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/dawn/tests/DawnTest.cpp b/src/dawn/tests/DawnTest.cpp index 605ced5c5d..2d686d8f68 100644 --- a/src/dawn/tests/DawnTest.cpp +++ b/src/dawn/tests/DawnTest.cpp @@ -1084,14 +1084,7 @@ void DawnTestBase::SetUp() { } void DawnTestBase::TearDown() { - FlushWire(); - - MapSlotsSynchronously(); - ResolveExpectations(); - - for (size_t i = 0; i < mReadbackSlots.size(); ++i) { - mReadbackSlots[i].buffer.Unmap(); - } + ResolveDeferredExpectationsNow(); if (!UsesWire() && device) { EXPECT_EQ(mLastWarningCount, @@ -1605,6 +1598,18 @@ std::unique_ptr DawnTestBase::CreateTestPlatform() { return nullptr; } +void DawnTestBase::ResolveDeferredExpectationsNow() { + FlushWire(); + + MapSlotsSynchronously(); + ResolveExpectations(); + + mDeferredExpectations.clear(); + for (size_t i = 0; i < mReadbackSlots.size(); ++i) { + mReadbackSlots[i].buffer.Unmap(); + } +} + bool RGBA8::operator==(const RGBA8& other) const { return r == other.r && g == other.g && b == other.b && a == other.a; } diff --git a/src/dawn/tests/DawnTest.h b/src/dawn/tests/DawnTest.h index 6cbbfe8765..197e80ec91 100644 --- a/src/dawn/tests/DawnTest.h +++ b/src/dawn/tests/DawnTest.h @@ -343,6 +343,10 @@ class DawnTestBase { std::string mTest; }; + // Resolve all the deferred expectations in mDeferredExpectations now to avoid letting + // mDeferredExpectations get too big. + void ResolveDeferredExpectationsNow(); + protected: wgpu::Device device; wgpu::Queue queue; diff --git a/src/dawn/tests/end2end/CopyTests.cpp b/src/dawn/tests/end2end/CopyTests.cpp index c0cba981cc..8e6721620a 100644 --- a/src/dawn/tests/end2end/CopyTests.cpp +++ b/src/dawn/tests/end2end/CopyTests.cpp @@ -2185,9 +2185,6 @@ TEST_P(CopyTests_T2T, CopyFromNonZeroMipLevelWithTexelBlockSizeLessThan4Bytes) { // try bots. DAWN_SUPPRESS_TEST_IF(IsVulkan() && IsWindows() && IsIntel()); - // This test also fails on D3D12 on Intel Windows. See http://crbug.com/1312066 for details. - DAWN_SUPPRESS_TEST_IF(IsD3D12() && IsWindows() && IsIntel()); - constexpr std::array kFormats = { {wgpu::TextureFormat::RG8Sint, wgpu::TextureFormat::RG8Uint, wgpu::TextureFormat::RG8Snorm, wgpu::TextureFormat::RG8Unorm, wgpu::TextureFormat::R16Float, wgpu::TextureFormat::R16Sint, @@ -2235,6 +2232,10 @@ TEST_P(CopyTests_T2T, CopyFromNonZeroMipLevelWithTexelBlockSizeLessThan4Bytes) { DoTest(srcSpec, dstSpec, kUploadSize); } } + + // Resolve all the deferred expectations now to avoid allocating too much memory + // in mDeferredExpectations. + ResolveDeferredExpectationsNow(); } } }