Make the Device ref the Instance
This is needed before supporting instances, adapters, and devices on
the wire so that the client cannot free the instance before the device.
In Dawn native, the developer still needs to make sure the device is not
freed before all child objects.
Bug: dawn:384
Change-Id: I863d44c6a8acecc7b8ea0cc0ac483f7a864162fd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/37003
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn_native/Device.cpp b/src/dawn_native/Device.cpp
index 390ed57..0f86d22 100644
--- a/src/dawn_native/Device.cpp
+++ b/src/dawn_native/Device.cpp
@@ -84,7 +84,7 @@
// DeviceBase
DeviceBase::DeviceBase(AdapterBase* adapter, const DeviceDescriptor* descriptor)
- : mAdapter(adapter) {
+ : mInstance(adapter->GetInstance()), mAdapter(adapter) {
if (descriptor != nullptr) {
ApplyToggleOverrides(descriptor);
ApplyExtensions(descriptor);
@@ -94,8 +94,7 @@
SetDefaultToggles();
}
- DeviceBase::~DeviceBase() {
- }
+ DeviceBase::~DeviceBase() = default;
MaybeError DeviceBase::Initialize(QueueBase* defaultQueue) {
mDefaultQueue = AcquireRef(defaultQueue);