Refactor Device destructors to WaitForIdleForDestruction + Destroy

To help with Device Loss, this splits Device backend destructors
to WaitForIdleForDestruction and Destroy.

WaitForIdleForDestruction waits for GPU to finish, checks errors and gets
ready for destruction.

Destroy is used to clean up and release resources used by device,
does not wait for GPU or check errors.

Bug: dawn:68
Change-Id: I054fd735e8d5b289365604209f38e616c723a4e7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14560
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Rafael Cintron <rafael.cintron@microsoft.com>
Commit-Queue: Natasha Lee <natlee@microsoft.com>
This commit is contained in:
Natasha Lee
2019-12-16 23:36:16 +00:00
committed by Commit Bot service account
parent 1bbbe8f52d
commit 2c8a17ecc7
12 changed files with 209 additions and 135 deletions

View File

@@ -17,6 +17,7 @@
#include "dawn_native/BackendConnection.h"
#include "dawn_native/Commands.h"
#include "dawn_native/DynamicUploader.h"
#include "dawn_native/ErrorData.h"
#include "dawn_native/Instance.h"
#include <spirv_cross.hpp>
@@ -85,10 +86,7 @@ namespace dawn_native { namespace null {
}
Device::~Device() {
mDynamicUploader = nullptr;
mPendingOperations.clear();
ASSERT(mMemoryUsage == 0);
BaseDestructor();
}
ResultOrError<BindGroupBase*> Device::CreateBindGroupImpl(
@@ -167,6 +165,17 @@ namespace dawn_native { namespace null {
return std::move(stagingBuffer);
}
void Device::Destroy() {
mDynamicUploader = nullptr;
mPendingOperations.clear();
ASSERT(mMemoryUsage == 0);
}
MaybeError Device::WaitForIdleForDestruction() {
return {};
}
MaybeError Device::CopyFromStagingToBuffer(StagingBufferBase* source,
uint64_t sourceOffset,
BufferBase* destination,

View File

@@ -130,6 +130,9 @@ namespace dawn_native { namespace null {
TextureBase* texture,
const TextureViewDescriptor* descriptor) override;
void Destroy() override;
MaybeError WaitForIdleForDestruction() override;
Serial mCompletedSerial = 0;
Serial mLastSubmittedSerial = 0;
std::vector<std::unique_ptr<PendingOperation>> mPendingOperations;