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 <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Jiawei Shao 2022-06-30 14:57:52 +00:00 committed by Dawn LUCI CQ
parent 830e75b401
commit fd7390a587
3 changed files with 21 additions and 11 deletions

View File

@ -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<dawn::platform::Platform> 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;
}

View File

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

View File

@ -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<wgpu::TextureFormat, 11> 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();
}
}
}