Use RefCounted for DeviceBase

DeviceBase implemented its own Reference / Release methods for
historical reasons. Replace them with RefCounted's version that are
similar, just more thread safe.

Bug: dawn:723
Change-Id: Ib26f3e231eb12fe09612c8b5639576e2f26a3cfd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/46000
Commit-Queue: Stephen White <senorblanco@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
This commit is contained in:
Corentin Wallez 2021-03-25 23:50:24 +00:00 committed by Commit Bot service account
parent 1a232448d2
commit 1257152485
2 changed files with 1 additions and 18 deletions

View File

@ -902,19 +902,6 @@ namespace dawn_native {
return !IsDeviceIdle();
}
void DeviceBase::Reference() {
ASSERT(mRefCount != 0);
mRefCount++;
}
void DeviceBase::Release() {
ASSERT(mRefCount != 0);
mRefCount--;
if (mRefCount == 0) {
delete this;
}
}
QueueBase* DeviceBase::GetQueue() {
// Backends gave the primary queue during initialization.
ASSERT(mQueue != nullptr);

View File

@ -41,7 +41,7 @@ namespace dawn_native {
struct InternalPipelineStore;
struct ShaderModuleParseResult;
class DeviceBase {
class DeviceBase : public RefCounted {
public:
DeviceBase(AdapterBase* adapter, const DeviceDescriptor* descriptor);
virtual ~DeviceBase();
@ -183,9 +183,6 @@ namespace dawn_native {
PersistentCache* GetPersistentCache();
void Reference();
void Release();
virtual ResultOrError<std::unique_ptr<StagingBufferBase>> CreateStagingBuffer(
size_t size) = 0;
virtual MaybeError CopyFromStagingToBuffer(StagingBufferBase* source,
@ -390,7 +387,6 @@ namespace dawn_native {
struct DeprecationWarnings;
std::unique_ptr<DeprecationWarnings> mDeprecationWarnings;
uint32_t mRefCount = 1;
State mState = State::BeingCreated;
FormatTable mFormatTable;