From 8aa036e9e498fb99756d507fc7a6b6f7ebce6767 Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Fri, 24 May 2019 22:31:36 +0000 Subject: [PATCH] Fix backend Device leak in dawn_end2end_tests harness with the wire Bug: dawn:158 Change-Id: I248ba66864d03c3366fc077fd89824a1233a230e Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7520 Reviewed-by: Corentin Wallez Reviewed-by: Kai Ninomiya Commit-Queue: Austin Eng --- src/tests/DawnTest.cpp | 9 +++++++-- src/tests/DawnTest.h | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/tests/DawnTest.cpp b/src/tests/DawnTest.cpp index e3752be297..9c9ab288e5 100644 --- a/src/tests/DawnTest.cpp +++ b/src/tests/DawnTest.cpp @@ -203,6 +203,12 @@ DawnTest::~DawnTest() { swapchain = dawn::SwapChain(); device = dawn::Device(); + mWireClient = nullptr; + mWireServer = nullptr; + if (gTestEnv->UsesWire()) { + backendProcs.deviceRelease(backendDevice); + } + dawnSetProcs(nullptr); } @@ -301,7 +307,6 @@ void DawnTest::SetUp() { mPCIInfo = backendAdapter.GetPCIInfo(); - DawnDevice backendDevice; const char* forceEnabledWorkaround = GetParam().forceEnabledWorkaround; if (forceEnabledWorkaround != nullptr) { ASSERT(gTestEnv->GetInstance()->GetToggleInfo(forceEnabledWorkaround) != nullptr); @@ -311,7 +316,7 @@ void DawnTest::SetUp() { backendDevice = backendAdapter.CreateDevice(nullptr); } - DawnProcTable backendProcs = dawn_native::GetProcs(); + backendProcs = dawn_native::GetProcs(); // Get the test window and create the device using it (esp. for OpenGL) GLFWwindow* testWindow = gTestEnv->GetWindowForBackend(backendType); diff --git a/src/tests/DawnTest.h b/src/tests/DawnTest.h index 591bd5c914..e31ec2eda7 100644 --- a/src/tests/DawnTest.h +++ b/src/tests/DawnTest.h @@ -157,6 +157,9 @@ class DawnTest : public ::testing::TestWithParam { dawn::Queue queue; dawn::SwapChain swapchain; + DawnProcTable backendProcs = {}; + DawnDevice backendDevice = nullptr; + // Helper methods to implement the EXPECT_ macros std::ostringstream& AddBufferExpectation(const char* file, int line,