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

@@ -18,6 +18,7 @@
#include "dawn_native/BindGroup.h"
#include "dawn_native/BindGroupLayout.h"
#include "dawn_native/DynamicUploader.h"
#include "dawn_native/ErrorData.h"
#include "dawn_native/opengl/BufferGL.h"
#include "dawn_native/opengl/CommandBufferGL.h"
#include "dawn_native/opengl/ComputePipelineGL.h"
@@ -42,17 +43,7 @@ namespace dawn_native { namespace opengl {
}
Device::~Device() {
CheckPassedFences();
ASSERT(mFencesInFlight.empty());
// Some operations might have been started since the last submit and waiting
// on a serial that doesn't have a corresponding fence enqueued. Force all
// operations to look as if they were completed (because they were).
mCompletedSerial = mLastSubmittedSerial + 1;
mDynamicUploader = nullptr;
Tick();
BaseDestructor();
}
const GLFormat& Device::GetGLFormat(const Format& format) {
@@ -170,4 +161,21 @@ namespace dawn_native { namespace opengl {
return DAWN_UNIMPLEMENTED_ERROR("Device unable to copy from staging buffer.");
}
void Device::Destroy() {
// Some operations might have been started since the last submit and waiting
// on a serial that doesn't have a corresponding fence enqueued. Force all
// operations to look as if they were completed (because they were).
mCompletedSerial = mLastSubmittedSerial + 1;
mDynamicUploader = nullptr;
}
MaybeError Device::WaitForIdleForDestruction() {
gl.Finish();
CheckPassedFences();
ASSERT(mFencesInFlight.empty());
Tick();
return {};
}
}} // namespace dawn_native::opengl

View File

@@ -86,6 +86,8 @@ namespace dawn_native { namespace opengl {
const TextureViewDescriptor* descriptor) override;
void CheckPassedFences();
void Destroy() override;
MaybeError WaitForIdleForDestruction() override;
Serial mCompletedSerial = 0;
Serial mLastSubmittedSerial = 0;