diff --git a/src/dawn/common/Log.cpp b/src/dawn/common/Log.cpp index ab1eb07e8b..799b8f99e3 100644 --- a/src/dawn/common/Log.cpp +++ b/src/dawn/common/Log.cpp @@ -66,6 +66,10 @@ android_LogPriority AndroidLogPriority(LogSeverity severity) { LogMessage::LogMessage(LogSeverity severity) : mSeverity(severity) {} +LogMessage::LogMessage(LogMessage&& other) = default; + +LogMessage& LogMessage::operator=(LogMessage&& other) = default; + LogMessage::~LogMessage() { std::string fullMessage = mStream.str(); diff --git a/src/dawn/common/Log.h b/src/dawn/common/Log.h index 3b338b3827..2f56ce53ae 100644 --- a/src/dawn/common/Log.h +++ b/src/dawn/common/Log.h @@ -62,8 +62,8 @@ class LogMessage { explicit LogMessage(LogSeverity severity); ~LogMessage(); - LogMessage(LogMessage&& other) = default; - LogMessage& operator=(LogMessage&& other) = default; + LogMessage(LogMessage&& other); + LogMessage& operator=(LogMessage&& other); template LogMessage& operator<<(T&& value) { diff --git a/src/dawn/common/SystemUtils.cpp b/src/dawn/common/SystemUtils.cpp index 2d47fd12db..dcdb6f02b2 100644 --- a/src/dawn/common/SystemUtils.cpp +++ b/src/dawn/common/SystemUtils.cpp @@ -205,6 +205,8 @@ std::optional GetModuleDirectory() { // ScopedEnvironmentVar +ScopedEnvironmentVar::ScopedEnvironmentVar() = default; + ScopedEnvironmentVar::ScopedEnvironmentVar(const char* variableName, const char* value) : mName(variableName), mOriginalValue(GetEnvironmentVar(variableName)), diff --git a/src/dawn/common/SystemUtils.h b/src/dawn/common/SystemUtils.h index ddb74e4467..021e70e2d2 100644 --- a/src/dawn/common/SystemUtils.h +++ b/src/dawn/common/SystemUtils.h @@ -40,7 +40,7 @@ bool IsMacOSVersionAtLeast(uint32_t majorVersion, uint32_t minorVersion = 0); class ScopedEnvironmentVar { public: - ScopedEnvironmentVar() = default; + ScopedEnvironmentVar(); ScopedEnvironmentVar(const char* variableName, const char* value); ~ScopedEnvironmentVar(); diff --git a/src/dawn/native/BUILD.gn b/src/dawn/native/BUILD.gn index d0a33e95d3..0c176e0621 100644 --- a/src/dawn/native/BUILD.gn +++ b/src/dawn/native/BUILD.gn @@ -253,6 +253,7 @@ source_set("sources") { "ObjectBase.h", "ObjectContentHasher.cpp", "ObjectContentHasher.h", + "PassResourceUsage.cpp", "PassResourceUsage.h", "PassResourceUsageTracker.cpp", "PassResourceUsageTracker.h", diff --git a/src/dawn/native/CMakeLists.txt b/src/dawn/native/CMakeLists.txt index 29a263fdee..9f067a1ba0 100644 --- a/src/dawn/native/CMakeLists.txt +++ b/src/dawn/native/CMakeLists.txt @@ -119,6 +119,7 @@ target_sources(dawn_native PRIVATE "Limits.h" "ObjectBase.cpp" "ObjectBase.h" + "PassResourceUsage.cpp" "PassResourceUsage.h" "PassResourceUsageTracker.cpp" "PassResourceUsageTracker.h" diff --git a/src/dawn/native/CommandBufferStateTracker.cpp b/src/dawn/native/CommandBufferStateTracker.cpp index b0624a3fcf..eb3affb88a 100644 --- a/src/dawn/native/CommandBufferStateTracker.cpp +++ b/src/dawn/native/CommandBufferStateTracker.cpp @@ -70,6 +70,20 @@ static constexpr CommandBufferStateTracker::ValidationAspects kLazyAspects = 1 << VALIDATION_ASPECT_BIND_GROUPS | 1 << VALIDATION_ASPECT_VERTEX_BUFFERS | 1 << VALIDATION_ASPECT_INDEX_BUFFER; +CommandBufferStateTracker::CommandBufferStateTracker() = default; + +CommandBufferStateTracker::CommandBufferStateTracker(const CommandBufferStateTracker&) = default; + +CommandBufferStateTracker::CommandBufferStateTracker(CommandBufferStateTracker&&) = default; + +CommandBufferStateTracker::~CommandBufferStateTracker() = default; + +CommandBufferStateTracker& CommandBufferStateTracker::operator=(const CommandBufferStateTracker&) = + default; + +CommandBufferStateTracker& CommandBufferStateTracker::operator=(CommandBufferStateTracker&&) = + default; + MaybeError CommandBufferStateTracker::ValidateCanDispatch() { return ValidateOperation(kDispatchAspects); } diff --git a/src/dawn/native/CommandBufferStateTracker.h b/src/dawn/native/CommandBufferStateTracker.h index a29d8d19ae..43ac23834b 100644 --- a/src/dawn/native/CommandBufferStateTracker.h +++ b/src/dawn/native/CommandBufferStateTracker.h @@ -28,6 +28,14 @@ namespace dawn::native { class CommandBufferStateTracker { public: + CommandBufferStateTracker(); + CommandBufferStateTracker(const CommandBufferStateTracker&); + CommandBufferStateTracker(CommandBufferStateTracker&&); + ~CommandBufferStateTracker(); + + CommandBufferStateTracker& operator=(const CommandBufferStateTracker&); + CommandBufferStateTracker& operator=(CommandBufferStateTracker&&); + // Non-state-modifying validation functions MaybeError ValidateCanDispatch(); MaybeError ValidateCanDraw(); diff --git a/src/dawn/native/CompilationMessages.cpp b/src/dawn/native/CompilationMessages.cpp index 0eae1a6b44..b02ee95e13 100644 --- a/src/dawn/native/CompilationMessages.cpp +++ b/src/dawn/native/CompilationMessages.cpp @@ -42,6 +42,8 @@ OwnedCompilationMessages::OwnedCompilationMessages() { mCompilationInfo.messages = nullptr; } +OwnedCompilationMessages::~OwnedCompilationMessages() = default; + void OwnedCompilationMessages::AddMessageForTesting(std::string message, wgpu::CompilationMessageType type, uint64_t lineNum, diff --git a/src/dawn/native/CompilationMessages.h b/src/dawn/native/CompilationMessages.h index 188d1caa96..13d30b2ddc 100644 --- a/src/dawn/native/CompilationMessages.h +++ b/src/dawn/native/CompilationMessages.h @@ -32,7 +32,7 @@ namespace dawn::native { class OwnedCompilationMessages : public NonCopyable { public: OwnedCompilationMessages(); - ~OwnedCompilationMessages() = default; + ~OwnedCompilationMessages(); void AddMessageForTesting( std::string message, diff --git a/src/dawn/native/ErrorData.cpp b/src/dawn/native/ErrorData.cpp index 951200b653..ee962403b4 100644 --- a/src/dawn/native/ErrorData.cpp +++ b/src/dawn/native/ErrorData.cpp @@ -35,6 +35,8 @@ std::unique_ptr ErrorData::Create(InternalErrorType type, ErrorData::ErrorData(InternalErrorType type, std::string message) : mType(type), mMessage(std::move(message)) {} +ErrorData::~ErrorData() = default; + void ErrorData::AppendBacktrace(const char* file, const char* function, int line) { BacktraceRecord record; record.file = file; diff --git a/src/dawn/native/ErrorData.h b/src/dawn/native/ErrorData.h index 30e33c6e8a..936252f827 100644 --- a/src/dawn/native/ErrorData.h +++ b/src/dawn/native/ErrorData.h @@ -41,6 +41,7 @@ class [[nodiscard]] ErrorData { const char* function, int line); ErrorData(InternalErrorType type, std::string message); + ~ErrorData(); struct BacktraceRecord { const char* file; diff --git a/src/dawn/native/PassResourceUsage.cpp b/src/dawn/native/PassResourceUsage.cpp new file mode 100644 index 0000000000..fc9ed33de8 --- /dev/null +++ b/src/dawn/native/PassResourceUsage.cpp @@ -0,0 +1,23 @@ +// Copyright 2022 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "dawn/native/PassResourceUsage.h" + +namespace dawn::native { + +ComputePassResourceUsage::ComputePassResourceUsage() = default; + +ComputePassResourceUsage::ComputePassResourceUsage(ComputePassResourceUsage&&) = default; + +} // namespace dawn::native diff --git a/src/dawn/native/PassResourceUsage.h b/src/dawn/native/PassResourceUsage.h index 1fa4130503..c22498fb32 100644 --- a/src/dawn/native/PassResourceUsage.h +++ b/src/dawn/native/PassResourceUsage.h @@ -58,8 +58,8 @@ struct ComputePassResourceUsage { // Somehow without this defaulted constructor, MSVC or its STDlib have an issue where they // use the copy constructor (that's deleted) when doing operations on a // vector - ComputePassResourceUsage(ComputePassResourceUsage&&) = default; - ComputePassResourceUsage() = default; + ComputePassResourceUsage(ComputePassResourceUsage&&); + ComputePassResourceUsage(); std::vector dispatchUsages; diff --git a/src/dawn/native/PassResourceUsageTracker.cpp b/src/dawn/native/PassResourceUsageTracker.cpp index 2c476cc124..e1f1ae6b32 100644 --- a/src/dawn/native/PassResourceUsageTracker.cpp +++ b/src/dawn/native/PassResourceUsageTracker.cpp @@ -26,6 +26,14 @@ namespace dawn::native { +SyncScopeUsageTracker::SyncScopeUsageTracker() = default; + +SyncScopeUsageTracker::SyncScopeUsageTracker(SyncScopeUsageTracker&&) = default; + +SyncScopeUsageTracker::~SyncScopeUsageTracker() = default; + +SyncScopeUsageTracker& SyncScopeUsageTracker::operator=(SyncScopeUsageTracker&&) = default; + void SyncScopeUsageTracker::BufferUsedAs(BufferBase* buffer, wgpu::BufferUsage usage) { // std::map's operator[] will create the key and return 0 if the key didn't exist // before. @@ -165,6 +173,10 @@ SyncScopeResourceUsage SyncScopeUsageTracker::AcquireSyncScopeUsage() { return result; } +ComputePassResourceUsageTracker::ComputePassResourceUsageTracker() = default; + +ComputePassResourceUsageTracker::~ComputePassResourceUsageTracker() = default; + void ComputePassResourceUsageTracker::AddDispatch(SyncScopeResourceUsage scope) { mUsage.dispatchUsages.push_back(std::move(scope)); } @@ -206,6 +218,16 @@ ComputePassResourceUsage ComputePassResourceUsageTracker::AcquireResourceUsage() return std::move(mUsage); } +RenderPassResourceUsageTracker::RenderPassResourceUsageTracker() = default; + +RenderPassResourceUsageTracker::RenderPassResourceUsageTracker(RenderPassResourceUsageTracker&&) = + default; + +RenderPassResourceUsageTracker::~RenderPassResourceUsageTracker() = default; + +RenderPassResourceUsageTracker& RenderPassResourceUsageTracker::operator=( + RenderPassResourceUsageTracker&&) = default; + RenderPassResourceUsage RenderPassResourceUsageTracker::AcquireResourceUsage() { RenderPassResourceUsage result; *static_cast(&result) = AcquireSyncScopeUsage(); diff --git a/src/dawn/native/PassResourceUsageTracker.h b/src/dawn/native/PassResourceUsageTracker.h index 89ae2a9fc8..c18d52efba 100644 --- a/src/dawn/native/PassResourceUsageTracker.h +++ b/src/dawn/native/PassResourceUsageTracker.h @@ -36,6 +36,12 @@ using QueryAvailabilityMap = std::map>; // Helper class to build SyncScopeResourceUsages class SyncScopeUsageTracker { public: + SyncScopeUsageTracker(); + SyncScopeUsageTracker(SyncScopeUsageTracker&&); + ~SyncScopeUsageTracker(); + + SyncScopeUsageTracker& operator=(SyncScopeUsageTracker&&); + void BufferUsedAs(BufferBase* buffer, wgpu::BufferUsage usage); void TextureViewUsedAs(TextureViewBase* texture, wgpu::TextureUsage usage); void AddRenderBundleTextureUsage(TextureBase* texture, @@ -56,6 +62,9 @@ class SyncScopeUsageTracker { // Helper class to build ComputePassResourceUsages class ComputePassResourceUsageTracker { public: + ComputePassResourceUsageTracker(); + ~ComputePassResourceUsageTracker(); + void AddDispatch(SyncScopeResourceUsage scope); void AddReferencedBuffer(BufferBase* buffer); void AddResourcesReferencedByBindGroup(BindGroupBase* group); @@ -69,6 +78,12 @@ class ComputePassResourceUsageTracker { // Helper class to build RenderPassResourceUsages class RenderPassResourceUsageTracker : public SyncScopeUsageTracker { public: + RenderPassResourceUsageTracker(); + RenderPassResourceUsageTracker(RenderPassResourceUsageTracker&&); + ~RenderPassResourceUsageTracker(); + + RenderPassResourceUsageTracker& operator=(RenderPassResourceUsageTracker&&); + void TrackQueryAvailability(QuerySetBase* querySet, uint32_t queryIndex); const QueryAvailabilityMap& GetQueryAvailabilityMap() const; diff --git a/src/dawn/native/Texture.cpp b/src/dawn/native/Texture.cpp index 8784cf99f0..457e76d91e 100644 --- a/src/dawn/native/Texture.cpp +++ b/src/dawn/native/Texture.cpp @@ -546,6 +546,8 @@ TextureBase::TextureBase(DeviceBase* device, TrackInDevice(); } +TextureBase::~TextureBase() = default; + static Format kUnusedFormat; TextureBase::TextureBase(DeviceBase* device, TextureState state) @@ -789,6 +791,8 @@ TextureViewBase::TextureViewBase(TextureBase* texture) TextureViewBase::TextureViewBase(DeviceBase* device, ObjectBase::ErrorTag tag) : ApiObjectBase(device, tag), mFormat(kUnusedFormat) {} +TextureViewBase::~TextureViewBase() = default; + void TextureViewBase::DestroyImpl() {} // static diff --git a/src/dawn/native/Texture.h b/src/dawn/native/Texture.h index 9cf5f53fd6..1712d7e34e 100644 --- a/src/dawn/native/Texture.h +++ b/src/dawn/native/Texture.h @@ -46,7 +46,9 @@ class TextureBase : public ApiObjectBase { public: enum class TextureState { OwnedInternal, OwnedExternal, Destroyed }; enum class ClearValue { Zero, NonZero }; + TextureBase(DeviceBase* device, const TextureDescriptor* descriptor, TextureState state); + ~TextureBase() override; static TextureBase* MakeError(DeviceBase* device); @@ -124,6 +126,7 @@ class TextureBase : public ApiObjectBase { class TextureViewBase : public ApiObjectBase { public: TextureViewBase(TextureBase* texture, const TextureViewDescriptor* descriptor); + ~TextureViewBase() override; static TextureViewBase* MakeError(DeviceBase* device); diff --git a/src/dawn/utils/WGPUHelpers.cpp b/src/dawn/utils/WGPUHelpers.cpp index e2126f006c..dda2cabe2b 100644 --- a/src/dawn/utils/WGPUHelpers.cpp +++ b/src/dawn/utils/WGPUHelpers.cpp @@ -118,6 +118,8 @@ ComboRenderPassDescriptor::ComboRenderPassDescriptor( } } +ComboRenderPassDescriptor::~ComboRenderPassDescriptor() = default; + ComboRenderPassDescriptor::ComboRenderPassDescriptor(const ComboRenderPassDescriptor& other) { *this = other; } @@ -349,6 +351,11 @@ BindingInitializationHelper::BindingInitializationHelper(uint32_t binding, uint64_t size) : binding(binding), buffer(buffer), offset(offset), size(size) {} +BindingInitializationHelper::BindingInitializationHelper(const BindingInitializationHelper&) = + default; + +BindingInitializationHelper::~BindingInitializationHelper() = default; + wgpu::BindGroupEntry BindingInitializationHelper::GetAsBinding() const { wgpu::BindGroupEntry result; diff --git a/src/dawn/utils/WGPUHelpers.h b/src/dawn/utils/WGPUHelpers.h index fb6ddd5c48..24864e6265 100644 --- a/src/dawn/utils/WGPUHelpers.h +++ b/src/dawn/utils/WGPUHelpers.h @@ -59,6 +59,7 @@ struct ComboRenderPassDescriptor : public wgpu::RenderPassDescriptor { public: ComboRenderPassDescriptor(std::initializer_list colorAttachmentInfo, wgpu::TextureView depthStencil = wgpu::TextureView()); + ~ComboRenderPassDescriptor(); ComboRenderPassDescriptor(const ComboRenderPassDescriptor& otherRenderPass); const ComboRenderPassDescriptor& operator=(const ComboRenderPassDescriptor& otherRenderPass); @@ -158,6 +159,8 @@ struct BindingInitializationHelper { const wgpu::Buffer& buffer, uint64_t offset = 0, uint64_t size = wgpu::kWholeSize); + BindingInitializationHelper(const BindingInitializationHelper&); + ~BindingInitializationHelper(); wgpu::BindGroupEntry GetAsBinding() const; diff --git a/src/dawn/wire/BUILD.gn b/src/dawn/wire/BUILD.gn index bff2136e0f..4c20cd8473 100644 --- a/src/dawn/wire/BUILD.gn +++ b/src/dawn/wire/BUILD.gn @@ -89,6 +89,8 @@ dawn_component("wire") { "client/LimitsAndFeatures.cpp", "client/LimitsAndFeatures.h", "client/ObjectAllocator.h", + "client/ObjectBase.cpp", + "client/ObjectBase.h", "client/Queue.cpp", "client/Queue.h", "client/RequestTracker.h", diff --git a/src/dawn/wire/CMakeLists.txt b/src/dawn/wire/CMakeLists.txt index bce614cded..b69eea14da 100644 --- a/src/dawn/wire/CMakeLists.txt +++ b/src/dawn/wire/CMakeLists.txt @@ -62,6 +62,8 @@ target_sources(dawn_wire PRIVATE "client/LimitsAndFeatures.cpp" "client/LimitsAndFeatures.h" "client/ObjectAllocator.h" + "client/ObjectBase.cpp" + "client/ObjectBase.h" "client/Queue.cpp" "client/Queue.h" "client/RequestTracker.h" diff --git a/src/dawn/wire/client/Adapter.cpp b/src/dawn/wire/client/Adapter.cpp index 3f55044188..3e9cbd2ac7 100644 --- a/src/dawn/wire/client/Adapter.cpp +++ b/src/dawn/wire/client/Adapter.cpp @@ -19,6 +19,8 @@ namespace dawn::wire::client { +Adapter::Adapter(Client* c, uint32_t r, uint32_t i) : ObjectBase(c, r, i) {} + Adapter::~Adapter() { mRequestDeviceRequests.CloseAll([](RequestDeviceData* request) { request->callback(WGPURequestDeviceStatus_Unknown, nullptr, diff --git a/src/dawn/wire/client/Adapter.h b/src/dawn/wire/client/Adapter.h index d2ae70607a..5c2adf5279 100644 --- a/src/dawn/wire/client/Adapter.h +++ b/src/dawn/wire/client/Adapter.h @@ -29,7 +29,9 @@ class Adapter final : public ObjectBase { public: using ObjectBase::ObjectBase; + Adapter(Client* client, uint32_t refcount, uint32_t id); ~Adapter(); + void CancelCallbacksForDisconnect() override; bool GetLimits(WGPUSupportedLimits* limits) const; diff --git a/src/dawn/wire/client/Buffer.cpp b/src/dawn/wire/client/Buffer.cpp index 9760e3dc07..850d822997 100644 --- a/src/dawn/wire/client/Buffer.cpp +++ b/src/dawn/wire/client/Buffer.cpp @@ -137,6 +137,8 @@ WGPUBuffer Buffer::CreateError(Device* device) { return ToAPI(allocation->object.get()); } +Buffer::Buffer(Client* c, uint32_t r, uint32_t i) : ObjectBase(c, r, i) {} + Buffer::~Buffer() { ClearAllCallbacks(WGPUBufferMapAsyncStatus_DestroyedBeforeCallback); FreeMappedData(); diff --git a/src/dawn/wire/client/Buffer.h b/src/dawn/wire/client/Buffer.h index be11598cfc..21ec8a6804 100644 --- a/src/dawn/wire/client/Buffer.h +++ b/src/dawn/wire/client/Buffer.h @@ -33,6 +33,7 @@ class Buffer final : public ObjectBase { static WGPUBuffer Create(Device* device, const WGPUBufferDescriptor* descriptor); static WGPUBuffer CreateError(Device* device); + Buffer(Client* client, uint32_t refcount, uint32_t id); ~Buffer(); bool OnMapAsyncCallback(uint64_t requestSerial, diff --git a/src/dawn/wire/client/Instance.cpp b/src/dawn/wire/client/Instance.cpp index b3a996f8c7..8e441d9727 100644 --- a/src/dawn/wire/client/Instance.cpp +++ b/src/dawn/wire/client/Instance.cpp @@ -18,6 +18,8 @@ namespace dawn::wire::client { +Instance::Instance(Client* c, uint32_t r, uint32_t i) : ObjectBase(c, r, i) {} + Instance::~Instance() { mRequestAdapterRequests.CloseAll([](RequestAdapterData* request) { request->callback(WGPURequestAdapterStatus_Unknown, nullptr, diff --git a/src/dawn/wire/client/Instance.h b/src/dawn/wire/client/Instance.h index a4c74dcdfc..1eee1fffa7 100644 --- a/src/dawn/wire/client/Instance.h +++ b/src/dawn/wire/client/Instance.h @@ -28,7 +28,9 @@ class Instance final : public ObjectBase { public: using ObjectBase::ObjectBase; + Instance(Client* client, uint32_t refcount, uint32_t id); ~Instance(); + void CancelCallbacksForDisconnect() override; void RequestAdapter(const WGPURequestAdapterOptions* options, diff --git a/src/dawn/wire/client/LimitsAndFeatures.cpp b/src/dawn/wire/client/LimitsAndFeatures.cpp index 95460cdc68..03a65004ec 100644 --- a/src/dawn/wire/client/LimitsAndFeatures.cpp +++ b/src/dawn/wire/client/LimitsAndFeatures.cpp @@ -19,6 +19,10 @@ namespace dawn::wire::client { +LimitsAndFeatures::LimitsAndFeatures() = default; + +LimitsAndFeatures::~LimitsAndFeatures() = default; + bool LimitsAndFeatures::GetLimits(WGPUSupportedLimits* limits) const { ASSERT(limits != nullptr); if (limits->nextInChain != nullptr) { diff --git a/src/dawn/wire/client/LimitsAndFeatures.h b/src/dawn/wire/client/LimitsAndFeatures.h index d97b8330b8..cfe9353ff0 100644 --- a/src/dawn/wire/client/LimitsAndFeatures.h +++ b/src/dawn/wire/client/LimitsAndFeatures.h @@ -23,6 +23,9 @@ namespace dawn::wire::client { class LimitsAndFeatures { public: + LimitsAndFeatures(); + ~LimitsAndFeatures(); + bool GetLimits(WGPUSupportedLimits* limits) const; bool HasFeature(WGPUFeatureName feature) const; size_t EnumerateFeatures(WGPUFeatureName* features) const; diff --git a/src/dawn/wire/client/ObjectBase.cpp b/src/dawn/wire/client/ObjectBase.cpp new file mode 100644 index 0000000000..1d581ef58f --- /dev/null +++ b/src/dawn/wire/client/ObjectBase.cpp @@ -0,0 +1,26 @@ +// Copyright 2022 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "dawn/wire/client/ObjectBase.h" + +namespace dawn::wire::client { + +ObjectBase::ObjectBase(Client* client, uint32_t refcount, uint32_t id) + : client(client), refcount(refcount), id(id) {} + +ObjectBase::~ObjectBase() { + RemoveFromList(); +} + +} // namespace dawn::wire::client diff --git a/src/dawn/wire/client/ObjectBase.h b/src/dawn/wire/client/ObjectBase.h index a404444666..417c7c7b64 100644 --- a/src/dawn/wire/client/ObjectBase.h +++ b/src/dawn/wire/client/ObjectBase.h @@ -30,10 +30,8 @@ class Client; // - An ID that is used to refer to this object when talking with the server side // - A next/prev pointer. They are part of a linked list of objects of the same type. struct ObjectBase : public LinkNode { - ObjectBase(Client* client, uint32_t refcount, uint32_t id) - : client(client), refcount(refcount), id(id) {} - - ~ObjectBase() { RemoveFromList(); } + ObjectBase(Client* client, uint32_t refcount, uint32_t id); + ~ObjectBase(); virtual void CancelCallbacksForDisconnect() {} diff --git a/src/dawn/wire/client/Queue.cpp b/src/dawn/wire/client/Queue.cpp index 79f5632433..618f99c65a 100644 --- a/src/dawn/wire/client/Queue.cpp +++ b/src/dawn/wire/client/Queue.cpp @@ -19,6 +19,8 @@ namespace dawn::wire::client { +Queue::Queue(Client* c, uint32_t r, uint32_t i) : ObjectBase(c, r, i) {} + Queue::~Queue() { ClearAllCallbacks(WGPUQueueWorkDoneStatus_Unknown); } diff --git a/src/dawn/wire/client/Queue.h b/src/dawn/wire/client/Queue.h index 6b59d96b4e..130a825909 100644 --- a/src/dawn/wire/client/Queue.h +++ b/src/dawn/wire/client/Queue.h @@ -26,6 +26,8 @@ namespace dawn::wire::client { class Queue final : public ObjectBase { public: using ObjectBase::ObjectBase; + + Queue(Client* client, uint32_t refcount, uint32_t id); ~Queue(); bool OnWorkDoneCallback(uint64_t requestSerial, WGPUQueueWorkDoneStatus status); diff --git a/src/dawn/wire/client/ShaderModule.cpp b/src/dawn/wire/client/ShaderModule.cpp index e7cbb4ec15..63bc534b37 100644 --- a/src/dawn/wire/client/ShaderModule.cpp +++ b/src/dawn/wire/client/ShaderModule.cpp @@ -18,6 +18,8 @@ namespace dawn::wire::client { +ShaderModule::ShaderModule(Client* c, uint32_t r, uint32_t i) : ObjectBase(c, r, i) {} + ShaderModule::~ShaderModule() { ClearAllCallbacks(WGPUCompilationInfoRequestStatus_Unknown); } diff --git a/src/dawn/wire/client/ShaderModule.h b/src/dawn/wire/client/ShaderModule.h index d8869ba8e6..4e89c629ad 100644 --- a/src/dawn/wire/client/ShaderModule.h +++ b/src/dawn/wire/client/ShaderModule.h @@ -25,6 +25,8 @@ namespace dawn::wire::client { class ShaderModule final : public ObjectBase { public: using ObjectBase::ObjectBase; + + ShaderModule(Client* client, uint32_t refcount, uint32_t id); ~ShaderModule(); void GetCompilationInfo(WGPUCompilationInfoCallback callback, void* userdata);