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 <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Austin Eng 2019-05-24 22:31:36 +00:00 committed by Commit Bot service account
parent f56efdf0d1
commit 8aa036e9e4
2 changed files with 10 additions and 2 deletions

View File

@ -203,6 +203,12 @@ DawnTest::~DawnTest() {
swapchain = dawn::SwapChain(); swapchain = dawn::SwapChain();
device = dawn::Device(); device = dawn::Device();
mWireClient = nullptr;
mWireServer = nullptr;
if (gTestEnv->UsesWire()) {
backendProcs.deviceRelease(backendDevice);
}
dawnSetProcs(nullptr); dawnSetProcs(nullptr);
} }
@ -301,7 +307,6 @@ void DawnTest::SetUp() {
mPCIInfo = backendAdapter.GetPCIInfo(); mPCIInfo = backendAdapter.GetPCIInfo();
DawnDevice backendDevice;
const char* forceEnabledWorkaround = GetParam().forceEnabledWorkaround; const char* forceEnabledWorkaround = GetParam().forceEnabledWorkaround;
if (forceEnabledWorkaround != nullptr) { if (forceEnabledWorkaround != nullptr) {
ASSERT(gTestEnv->GetInstance()->GetToggleInfo(forceEnabledWorkaround) != nullptr); ASSERT(gTestEnv->GetInstance()->GetToggleInfo(forceEnabledWorkaround) != nullptr);
@ -311,7 +316,7 @@ void DawnTest::SetUp() {
backendDevice = backendAdapter.CreateDevice(nullptr); 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) // Get the test window and create the device using it (esp. for OpenGL)
GLFWwindow* testWindow = gTestEnv->GetWindowForBackend(backendType); GLFWwindow* testWindow = gTestEnv->GetWindowForBackend(backendType);

View File

@ -157,6 +157,9 @@ class DawnTest : public ::testing::TestWithParam<DawnTestParam> {
dawn::Queue queue; dawn::Queue queue;
dawn::SwapChain swapchain; dawn::SwapChain swapchain;
DawnProcTable backendProcs = {};
DawnDevice backendDevice = nullptr;
// Helper methods to implement the EXPECT_ macros // Helper methods to implement the EXPECT_ macros
std::ostringstream& AddBufferExpectation(const char* file, std::ostringstream& AddBufferExpectation(const char* file,
int line, int line,