From 61f30bad1ea99ef57c8f86e17b799105b321a42e Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Mon, 9 May 2022 22:22:18 +0000 Subject: [PATCH] [chromium-style] Adding/moving constructors and destructors. This CL adds missing constructors and destructors. Others are moved from the header file to implementation files. Bug: dawn:1405 Change-Id: I06657d4a4faa437ca5a95a0067a8f9f9bbc89d12 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/89181 Commit-Queue: Dan Sinclair Kokoro: Kokoro Reviewed-by: Austin Eng --- src/dawn/native/AsyncTask.cpp | 4 ++++ src/dawn/native/AsyncTask.h | 3 +++ src/dawn/native/BlobCache.cpp | 6 ++++++ src/dawn/native/BlobCache.h | 4 ++++ src/dawn/native/BuddyMemoryAllocator.cpp | 2 ++ src/dawn/native/BuddyMemoryAllocator.h | 2 +- src/dawn/native/CallbackTaskManager.cpp | 4 ++++ src/dawn/native/CallbackTaskManager.h | 3 +++ src/dawn/native/CreatePipelineAsyncTask.cpp | 10 ++++++++++ src/dawn/native/CreatePipelineAsyncTask.h | 5 +++++ src/dawn/native/ErrorScope.cpp | 4 ++++ src/dawn/native/ErrorScope.h | 3 +++ src/dawn/native/Features.cpp | 2 ++ src/dawn/native/Features.h | 1 + src/dawn/native/Instance.cpp | 4 ++++ src/dawn/native/Instance.h | 4 ++-- src/dawn/native/PooledResourceMemoryAllocator.cpp | 2 ++ src/dawn/native/PooledResourceMemoryAllocator.h | 2 +- src/dawn/native/RingBufferAllocator.cpp | 8 ++++++++ src/dawn/native/RingBufferAllocator.h | 9 +++++---- src/dawn/native/Toggles.cpp | 4 ++++ src/dawn/native/Toggles.h | 3 +++ src/dawn/native/metal/BackendMTL.h | 1 + src/dawn/native/metal/BackendMTL.mm | 2 ++ src/dawn/native/metal/BindGroupLayoutMTL.h | 2 +- src/dawn/native/metal/BindGroupLayoutMTL.mm | 2 ++ src/dawn/native/metal/BufferMTL.h | 4 ++++ src/dawn/native/metal/BufferMTL.mm | 2 ++ src/dawn/native/metal/CommandBufferMTL.h | 3 +++ src/dawn/native/metal/CommandBufferMTL.mm | 5 +++++ src/dawn/native/metal/ComputePipelineMTL.h | 3 +++ src/dawn/native/metal/ComputePipelineMTL.mm | 5 +++++ src/dawn/native/metal/PipelineLayoutMTL.h | 2 +- src/dawn/native/metal/PipelineLayoutMTL.mm | 2 ++ src/dawn/native/metal/QuerySetMTL.h | 5 ++++- src/dawn/native/metal/QuerySetMTL.mm | 2 ++ src/dawn/native/metal/QueueMTL.h | 1 + src/dawn/native/metal/QueueMTL.mm | 2 ++ src/dawn/native/metal/RenderPipelineMTL.h | 3 +++ src/dawn/native/metal/RenderPipelineMTL.mm | 5 +++++ src/dawn/native/metal/SamplerMTL.h | 3 +++ src/dawn/native/metal/SamplerMTL.mm | 4 ++++ src/dawn/native/metal/ShaderModuleMTL.h | 2 +- src/dawn/native/metal/ShaderModuleMTL.mm | 2 ++ src/dawn/native/metal/StagingBufferMTL.h | 1 + src/dawn/native/metal/StagingBufferMTL.mm | 2 ++ src/dawn/native/metal/SwapChainMTL.h | 2 ++ src/dawn/native/metal/SwapChainMTL.mm | 3 +++ src/dawn/native/metal/TextureMTL.h | 2 ++ src/dawn/native/metal/TextureMTL.mm | 3 +++ src/dawn/native/vulkan/AdapterVk.cpp | 2 ++ src/dawn/native/vulkan/AdapterVk.h | 2 +- src/dawn/wire/ChunkedCommandHandler.cpp | 2 ++ src/dawn/wire/ChunkedCommandHandler.h | 4 +++- src/dawn/wire/server/Server.cpp | 3 +++ src/dawn/wire/server/Server.h | 3 +-- 56 files changed, 164 insertions(+), 16 deletions(-) diff --git a/src/dawn/native/AsyncTask.cpp b/src/dawn/native/AsyncTask.cpp index 00e6a6466c..2f0facef3e 100644 --- a/src/dawn/native/AsyncTask.cpp +++ b/src/dawn/native/AsyncTask.cpp @@ -77,4 +77,8 @@ void AsyncTaskManager::DoWaitableTask(void* task) { waitableTask->taskManager->HandleTaskCompletion(waitableTask.Get()); } +AsyncTaskManager::WaitableTask::WaitableTask() = default; + +AsyncTaskManager::WaitableTask::~WaitableTask() = default; + } // namespace dawn::native diff --git a/src/dawn/native/AsyncTask.h b/src/dawn/native/AsyncTask.h index d2c28fa890..e1d130e87e 100644 --- a/src/dawn/native/AsyncTask.h +++ b/src/dawn/native/AsyncTask.h @@ -47,6 +47,9 @@ class AsyncTaskManager { private: class WaitableTask : public RefCounted { public: + WaitableTask(); + ~WaitableTask(); + AsyncTask asyncTask; AsyncTaskManager* taskManager; std::unique_ptr waitableEvent; diff --git a/src/dawn/native/BlobCache.cpp b/src/dawn/native/BlobCache.cpp index 9ec4750244..878ded69f3 100644 --- a/src/dawn/native/BlobCache.cpp +++ b/src/dawn/native/BlobCache.cpp @@ -27,6 +27,12 @@ CachedBlob::CachedBlob(size_t size) { } } +CachedBlob::CachedBlob(CachedBlob&&) = default; + +CachedBlob::~CachedBlob() = default; + +CachedBlob& CachedBlob::operator=(CachedBlob&&) = default; + bool CachedBlob::Empty() const { return mSize == 0; } diff --git a/src/dawn/native/BlobCache.h b/src/dawn/native/BlobCache.h index 8565429799..b1c0a6375a 100644 --- a/src/dawn/native/BlobCache.h +++ b/src/dawn/native/BlobCache.h @@ -31,6 +31,10 @@ class InstanceBase; class CachedBlob { public: explicit CachedBlob(size_t size = 0); + CachedBlob(CachedBlob&&); + ~CachedBlob(); + + CachedBlob& operator=(CachedBlob&&); bool Empty() const; const uint8_t* Data() const; diff --git a/src/dawn/native/BuddyMemoryAllocator.cpp b/src/dawn/native/BuddyMemoryAllocator.cpp index d21ecf1ab3..f744440f3a 100644 --- a/src/dawn/native/BuddyMemoryAllocator.cpp +++ b/src/dawn/native/BuddyMemoryAllocator.cpp @@ -34,6 +34,8 @@ BuddyMemoryAllocator::BuddyMemoryAllocator(uint64_t maxSystemSize, mTrackedSubAllocations.resize(maxSystemSize / mMemoryBlockSize); } +BuddyMemoryAllocator::~BuddyMemoryAllocator() = default; + uint64_t BuddyMemoryAllocator::GetMemoryIndex(uint64_t offset) const { ASSERT(offset != BuddyAllocator::kInvalidOffset); return offset / mMemoryBlockSize; diff --git a/src/dawn/native/BuddyMemoryAllocator.h b/src/dawn/native/BuddyMemoryAllocator.h index a58cbaecbc..adbcc96074 100644 --- a/src/dawn/native/BuddyMemoryAllocator.h +++ b/src/dawn/native/BuddyMemoryAllocator.h @@ -42,7 +42,7 @@ class BuddyMemoryAllocator { BuddyMemoryAllocator(uint64_t maxSystemSize, uint64_t memoryBlockSize, ResourceHeapAllocator* heapAllocator); - ~BuddyMemoryAllocator() = default; + ~BuddyMemoryAllocator(); ResultOrError Allocate(uint64_t allocationSize, uint64_t alignment); void Deallocate(const ResourceMemoryAllocation& allocation); diff --git a/src/dawn/native/CallbackTaskManager.cpp b/src/dawn/native/CallbackTaskManager.cpp index 40146f87cf..51a9b86b61 100644 --- a/src/dawn/native/CallbackTaskManager.cpp +++ b/src/dawn/native/CallbackTaskManager.cpp @@ -18,6 +18,10 @@ namespace dawn::native { +CallbackTaskManager::CallbackTaskManager() = default; + +CallbackTaskManager::~CallbackTaskManager() = default; + bool CallbackTaskManager::IsEmpty() { std::lock_guard lock(mCallbackTaskQueueMutex); return mCallbackTaskQueue.empty(); diff --git a/src/dawn/native/CallbackTaskManager.h b/src/dawn/native/CallbackTaskManager.h index 479ba01ff0..aceea0a49e 100644 --- a/src/dawn/native/CallbackTaskManager.h +++ b/src/dawn/native/CallbackTaskManager.h @@ -31,6 +31,9 @@ struct CallbackTask { class CallbackTaskManager { public: + CallbackTaskManager(); + ~CallbackTaskManager(); + void AddCallbackTask(std::unique_ptr callbackTask); bool IsEmpty(); std::vector> AcquireCallbackTasks(); diff --git a/src/dawn/native/CreatePipelineAsyncTask.cpp b/src/dawn/native/CreatePipelineAsyncTask.cpp index 9ecd048602..e7319abc27 100644 --- a/src/dawn/native/CreatePipelineAsyncTask.cpp +++ b/src/dawn/native/CreatePipelineAsyncTask.cpp @@ -30,6 +30,8 @@ CreatePipelineAsyncCallbackTaskBase::CreatePipelineAsyncCallbackTaskBase(std::st void* userdata) : mErrorMessage(errorMessage), mUserData(userdata) {} +CreatePipelineAsyncCallbackTaskBase::~CreatePipelineAsyncCallbackTaskBase() = default; + CreateComputePipelineAsyncCallbackTask::CreateComputePipelineAsyncCallbackTask( Ref pipeline, std::string errorMessage, @@ -39,6 +41,8 @@ CreateComputePipelineAsyncCallbackTask::CreateComputePipelineAsyncCallbackTask( mPipeline(std::move(pipeline)), mCreateComputePipelineAsyncCallback(callback) {} +CreateComputePipelineAsyncCallbackTask::~CreateComputePipelineAsyncCallbackTask() = default; + void CreateComputePipelineAsyncCallbackTask::Finish() { ASSERT(mCreateComputePipelineAsyncCallback != nullptr); @@ -74,6 +78,8 @@ CreateRenderPipelineAsyncCallbackTask::CreateRenderPipelineAsyncCallbackTask( mPipeline(std::move(pipeline)), mCreateRenderPipelineAsyncCallback(callback) {} +CreateRenderPipelineAsyncCallbackTask::~CreateRenderPipelineAsyncCallbackTask() = default; + void CreateRenderPipelineAsyncCallbackTask::Finish() { ASSERT(mCreateRenderPipelineAsyncCallback != nullptr); @@ -110,6 +116,8 @@ CreateComputePipelineAsyncTask::CreateComputePipelineAsyncTask( ASSERT(mComputePipeline != nullptr); } +CreateComputePipelineAsyncTask::~CreateComputePipelineAsyncTask() = default; + void CreateComputePipelineAsyncTask::Run() { const char* eventLabel = utils::GetLabelForTrace(mComputePipeline->GetLabel().c_str()); @@ -160,6 +168,8 @@ CreateRenderPipelineAsyncTask::CreateRenderPipelineAsyncTask( ASSERT(mRenderPipeline != nullptr); } +CreateRenderPipelineAsyncTask::~CreateRenderPipelineAsyncTask() = default; + void CreateRenderPipelineAsyncTask::Run() { const char* eventLabel = utils::GetLabelForTrace(mRenderPipeline->GetLabel().c_str()); diff --git a/src/dawn/native/CreatePipelineAsyncTask.h b/src/dawn/native/CreatePipelineAsyncTask.h index cd98154074..7b9e614a7e 100644 --- a/src/dawn/native/CreatePipelineAsyncTask.h +++ b/src/dawn/native/CreatePipelineAsyncTask.h @@ -34,6 +34,7 @@ struct FlatComputePipelineDescriptor; struct CreatePipelineAsyncCallbackTaskBase : CallbackTask { CreatePipelineAsyncCallbackTaskBase(std::string errorMessage, void* userData); + ~CreatePipelineAsyncCallbackTaskBase(); protected: std::string mErrorMessage; @@ -45,6 +46,7 @@ struct CreateComputePipelineAsyncCallbackTask : CreatePipelineAsyncCallbackTaskB std::string errorMessage, WGPUCreateComputePipelineAsyncCallback callback, void* userdata); + ~CreateComputePipelineAsyncCallbackTask() override; void Finish() override; void HandleShutDown() final; @@ -60,6 +62,7 @@ struct CreateRenderPipelineAsyncCallbackTask : CreatePipelineAsyncCallbackTaskBa std::string errorMessage, WGPUCreateRenderPipelineAsyncCallback callback, void* userdata); + ~CreateRenderPipelineAsyncCallbackTask() override; void Finish() override; void HandleShutDown() final; @@ -77,6 +80,7 @@ class CreateComputePipelineAsyncTask { CreateComputePipelineAsyncTask(Ref nonInitializedComputePipeline, WGPUCreateComputePipelineAsyncCallback callback, void* userdata); + ~CreateComputePipelineAsyncTask(); void Run(); @@ -95,6 +99,7 @@ class CreateRenderPipelineAsyncTask { CreateRenderPipelineAsyncTask(Ref nonInitializedRenderPipeline, WGPUCreateRenderPipelineAsyncCallback callback, void* userdata); + ~CreateRenderPipelineAsyncTask(); void Run(); diff --git a/src/dawn/native/ErrorScope.cpp b/src/dawn/native/ErrorScope.cpp index fe40d2d17b..b90fb13b6d 100644 --- a/src/dawn/native/ErrorScope.cpp +++ b/src/dawn/native/ErrorScope.cpp @@ -45,6 +45,10 @@ const char* ErrorScope::GetErrorMessage() const { return mErrorMessage.c_str(); } +ErrorScopeStack::ErrorScopeStack() = default; + +ErrorScopeStack::~ErrorScopeStack() = default; + void ErrorScopeStack::Push(wgpu::ErrorFilter filter) { mScopes.push_back(ErrorScope(filter)); } diff --git a/src/dawn/native/ErrorScope.h b/src/dawn/native/ErrorScope.h index 3ffb510a1a..7901d1883b 100644 --- a/src/dawn/native/ErrorScope.h +++ b/src/dawn/native/ErrorScope.h @@ -38,6 +38,9 @@ class ErrorScope { class ErrorScopeStack { public: + ErrorScopeStack(); + ~ErrorScopeStack(); + void Push(wgpu::ErrorFilter errorFilter); ErrorScope Pop(); diff --git a/src/dawn/native/Features.cpp b/src/dawn/native/Features.cpp index 5621b63071..c33b4af0c9 100644 --- a/src/dawn/native/Features.cpp +++ b/src/dawn/native/Features.cpp @@ -232,6 +232,8 @@ FeaturesInfo::FeaturesInfo() { } } +FeaturesInfo::~FeaturesInfo() = default; + const FeatureInfo* FeaturesInfo::GetFeatureInfo(wgpu::FeatureName feature) const { Feature f = FromAPIFeature(feature); if (f == Feature::InvalidEnum) { diff --git a/src/dawn/native/Features.h b/src/dawn/native/Features.h index bb1f015ddd..c2439b22ba 100644 --- a/src/dawn/native/Features.h +++ b/src/dawn/native/Features.h @@ -68,6 +68,7 @@ wgpu::FeatureName FeatureEnumToAPIFeature(Feature feature); class FeaturesInfo { public: FeaturesInfo(); + ~FeaturesInfo(); // Used to query the details of an feature. Return nullptr if featureName is not a valid // name of an feature supported in Dawn diff --git a/src/dawn/native/Instance.cpp b/src/dawn/native/Instance.cpp index 34436b2798..1e25a3be01 100644 --- a/src/dawn/native/Instance.cpp +++ b/src/dawn/native/Instance.cpp @@ -122,6 +122,10 @@ Ref InstanceBase::Create(const InstanceDescriptor* descriptor) { return instance; } +InstanceBase::InstanceBase() = default; + +InstanceBase::~InstanceBase() = default; + // TODO(crbug.com/dawn/832): make the platform an initialization parameter of the instance. MaybeError InstanceBase::Initialize(const InstanceDescriptor* descriptor) { DAWN_TRY(ValidateSingleSType(descriptor->nextInChain, wgpu::SType::DawnInstanceDescriptor)); diff --git a/src/dawn/native/Instance.h b/src/dawn/native/Instance.h index 6f8f5d5ef5..0f3cb18470 100644 --- a/src/dawn/native/Instance.h +++ b/src/dawn/native/Instance.h @@ -93,8 +93,8 @@ class InstanceBase final : public RefCounted { Surface* APICreateSurface(const SurfaceDescriptor* descriptor); private: - InstanceBase() = default; - ~InstanceBase() override = default; + InstanceBase(); + ~InstanceBase() override; InstanceBase(const InstanceBase& other) = delete; InstanceBase& operator=(const InstanceBase& other) = delete; diff --git a/src/dawn/native/PooledResourceMemoryAllocator.cpp b/src/dawn/native/PooledResourceMemoryAllocator.cpp index 95bca8cfdd..96b10c6981 100644 --- a/src/dawn/native/PooledResourceMemoryAllocator.cpp +++ b/src/dawn/native/PooledResourceMemoryAllocator.cpp @@ -23,6 +23,8 @@ namespace dawn::native { PooledResourceMemoryAllocator::PooledResourceMemoryAllocator(ResourceHeapAllocator* heapAllocator) : mHeapAllocator(heapAllocator) {} +PooledResourceMemoryAllocator::~PooledResourceMemoryAllocator() = default; + void PooledResourceMemoryAllocator::DestroyPool() { for (auto& resourceHeap : mPool) { ASSERT(resourceHeap != nullptr); diff --git a/src/dawn/native/PooledResourceMemoryAllocator.h b/src/dawn/native/PooledResourceMemoryAllocator.h index e75ad5511f..073ea26545 100644 --- a/src/dawn/native/PooledResourceMemoryAllocator.h +++ b/src/dawn/native/PooledResourceMemoryAllocator.h @@ -32,7 +32,7 @@ class DeviceBase; class PooledResourceMemoryAllocator : public ResourceHeapAllocator { public: explicit PooledResourceMemoryAllocator(ResourceHeapAllocator* heapAllocator); - ~PooledResourceMemoryAllocator() override = default; + ~PooledResourceMemoryAllocator() override; ResultOrError> AllocateResourceHeap(uint64_t size) override; void DeallocateResourceHeap(std::unique_ptr allocation) override; diff --git a/src/dawn/native/RingBufferAllocator.cpp b/src/dawn/native/RingBufferAllocator.cpp index d3843830f8..01e23e7c15 100644 --- a/src/dawn/native/RingBufferAllocator.cpp +++ b/src/dawn/native/RingBufferAllocator.cpp @@ -30,8 +30,16 @@ // used bytes. namespace dawn::native { +RingBufferAllocator::RingBufferAllocator() = default; + RingBufferAllocator::RingBufferAllocator(uint64_t maxSize) : mMaxBlockSize(maxSize) {} +RingBufferAllocator::RingBufferAllocator(const RingBufferAllocator&) = default; + +RingBufferAllocator::~RingBufferAllocator() = default; + +RingBufferAllocator& RingBufferAllocator::operator=(const RingBufferAllocator&) = default; + void RingBufferAllocator::Deallocate(ExecutionSerial lastCompletedSerial) { // Reclaim memory from previously recorded blocks. for (Request& request : mInflightRequests.IterateUpTo(lastCompletedSerial)) { diff --git a/src/dawn/native/RingBufferAllocator.h b/src/dawn/native/RingBufferAllocator.h index cbb01b7b35..6aeb1427be 100644 --- a/src/dawn/native/RingBufferAllocator.h +++ b/src/dawn/native/RingBufferAllocator.h @@ -26,11 +26,12 @@ namespace dawn::native { class RingBufferAllocator { public: - RingBufferAllocator() = default; + RingBufferAllocator(); explicit RingBufferAllocator(uint64_t maxSize); - ~RingBufferAllocator() = default; - RingBufferAllocator(const RingBufferAllocator&) = default; - RingBufferAllocator& operator=(const RingBufferAllocator&) = default; + RingBufferAllocator(const RingBufferAllocator&); + ~RingBufferAllocator(); + + RingBufferAllocator& operator=(const RingBufferAllocator&); uint64_t Allocate(uint64_t allocationSize, ExecutionSerial serial); void Deallocate(ExecutionSerial lastCompletedSerial); diff --git a/src/dawn/native/Toggles.cpp b/src/dawn/native/Toggles.cpp index bc2fcbd3fa..f98c94dbdf 100644 --- a/src/dawn/native/Toggles.cpp +++ b/src/dawn/native/Toggles.cpp @@ -313,6 +313,10 @@ const char* ToggleEnumToName(Toggle toggle) { return toggleNameAndInfo.info.name; } +TogglesInfo::TogglesInfo() = default; + +TogglesInfo::~TogglesInfo() = default; + const ToggleInfo* TogglesInfo::GetToggleInfo(const char* toggleName) { ASSERT(toggleName); diff --git a/src/dawn/native/Toggles.h b/src/dawn/native/Toggles.h index 2d8d286882..341db798fe 100644 --- a/src/dawn/native/Toggles.h +++ b/src/dawn/native/Toggles.h @@ -91,6 +91,9 @@ const char* ToggleEnumToName(Toggle toggle); class TogglesInfo { public: + TogglesInfo(); + ~TogglesInfo(); + // Used to query the details of a toggle. Return nullptr if toggleName is not a valid name // of a toggle supported in Dawn. const ToggleInfo* GetToggleInfo(const char* toggleName); diff --git a/src/dawn/native/metal/BackendMTL.h b/src/dawn/native/metal/BackendMTL.h index fe6908fdd8..75be73040e 100644 --- a/src/dawn/native/metal/BackendMTL.h +++ b/src/dawn/native/metal/BackendMTL.h @@ -24,6 +24,7 @@ namespace dawn::native::metal { class Backend : public BackendConnection { public: explicit Backend(InstanceBase* instance); + ~Backend() override; std::vector> DiscoverDefaultAdapters() override; ResultOrError>> DiscoverAdapters( diff --git a/src/dawn/native/metal/BackendMTL.mm b/src/dawn/native/metal/BackendMTL.mm index 2545e11977..11430de9ec 100644 --- a/src/dawn/native/metal/BackendMTL.mm +++ b/src/dawn/native/metal/BackendMTL.mm @@ -608,6 +608,8 @@ Backend::Backend(InstanceBase* instance) : BackendConnection(instance, wgpu::Bac } } +Backend::~Backend() = default; + std::vector> Backend::DiscoverDefaultAdapters() { AdapterDiscoveryOptions options; auto result = DiscoverAdapters(&options); diff --git a/src/dawn/native/metal/BindGroupLayoutMTL.h b/src/dawn/native/metal/BindGroupLayoutMTL.h index 97688eba8d..ab2abefc00 100644 --- a/src/dawn/native/metal/BindGroupLayoutMTL.h +++ b/src/dawn/native/metal/BindGroupLayoutMTL.h @@ -36,7 +36,7 @@ class BindGroupLayout final : public BindGroupLayoutBase { BindGroupLayout(DeviceBase* device, const BindGroupLayoutDescriptor* descriptor, PipelineCompatibilityToken pipelineCompatibilityToken); - ~BindGroupLayout() override = default; + ~BindGroupLayout() override; SlabAllocator mBindGroupAllocator; }; diff --git a/src/dawn/native/metal/BindGroupLayoutMTL.mm b/src/dawn/native/metal/BindGroupLayoutMTL.mm index 2f1012cd13..6c1a7acb3e 100644 --- a/src/dawn/native/metal/BindGroupLayoutMTL.mm +++ b/src/dawn/native/metal/BindGroupLayoutMTL.mm @@ -32,6 +32,8 @@ BindGroupLayout::BindGroupLayout(DeviceBase* device, : BindGroupLayoutBase(device, descriptor, pipelineCompatibilityToken), mBindGroupAllocator(MakeFrontendBindGroupAllocator(4096)) {} +BindGroupLayout::~BindGroupLayout() = default; + Ref BindGroupLayout::AllocateBindGroup(Device* device, const BindGroupDescriptor* descriptor) { return AcquireRef(mBindGroupAllocator.Allocate(device, descriptor)); diff --git a/src/dawn/native/metal/BufferMTL.h b/src/dawn/native/metal/BufferMTL.h index 096237b822..f36ebe8948 100644 --- a/src/dawn/native/metal/BufferMTL.h +++ b/src/dawn/native/metal/BufferMTL.h @@ -29,6 +29,9 @@ class Device; class Buffer final : public BufferBase { public: static ResultOrError> Create(Device* device, const BufferDescriptor* descriptor); + + Buffer(DeviceBase* device, const BufferDescriptor* descriptor); + id GetMTLBuffer() const; bool EnsureDataInitialized(CommandRecordingContext* commandContext); @@ -45,6 +48,7 @@ class Buffer final : public BufferBase { MaybeError Initialize(bool mappedAtCreation); ~Buffer() override; + MaybeError MapAsyncImpl(wgpu::MapMode mode, size_t offset, size_t size) override; void UnmapImpl() override; void DestroyImpl() override; diff --git a/src/dawn/native/metal/BufferMTL.mm b/src/dawn/native/metal/BufferMTL.mm index e8d74c1b2e..8f703ef407 100644 --- a/src/dawn/native/metal/BufferMTL.mm +++ b/src/dawn/native/metal/BufferMTL.mm @@ -59,6 +59,8 @@ uint64_t Buffer::QueryMaxBufferLength(id mtlDevice) { #endif } +Buffer::Buffer(DeviceBase* dev, const BufferDescriptor* desc) : BufferBase(dev, desc) {} + MaybeError Buffer::Initialize(bool mappedAtCreation) { MTLResourceOptions storageMode; if (GetUsage() & kMappableBufferUsages) { diff --git a/src/dawn/native/metal/CommandBufferMTL.h b/src/dawn/native/metal/CommandBufferMTL.h index 8f7a9835c5..8f0c02bea2 100644 --- a/src/dawn/native/metal/CommandBufferMTL.h +++ b/src/dawn/native/metal/CommandBufferMTL.h @@ -47,6 +47,9 @@ class CommandBuffer final : public CommandBufferBase { static Ref Create(CommandEncoder* encoder, const CommandBufferDescriptor* descriptor); + CommandBuffer(CommandEncoder* encoder, const CommandBufferDescriptor* descriptor); + ~CommandBuffer(); + MaybeError FillCommands(CommandRecordingContext* commandContext); private: diff --git a/src/dawn/native/metal/CommandBufferMTL.mm b/src/dawn/native/metal/CommandBufferMTL.mm index 121198f255..04dab40699 100644 --- a/src/dawn/native/metal/CommandBufferMTL.mm +++ b/src/dawn/native/metal/CommandBufferMTL.mm @@ -577,6 +577,11 @@ Ref CommandBuffer::Create(CommandEncoder* encoder, return AcquireRef(new CommandBuffer(encoder, descriptor)); } +CommandBuffer::CommandBuffer(CommandEncoder* enc, const CommandBufferDescriptor* desc) + : CommandBufferBase(enc, desc) {} + +CommandBuffer::~CommandBuffer() = default; + MaybeError CommandBuffer::FillCommands(CommandRecordingContext* commandContext) { size_t nextComputePassNumber = 0; size_t nextRenderPassNumber = 0; diff --git a/src/dawn/native/metal/ComputePipelineMTL.h b/src/dawn/native/metal/ComputePipelineMTL.h index 22ac6356f0..48a723dabf 100644 --- a/src/dawn/native/metal/ComputePipelineMTL.h +++ b/src/dawn/native/metal/ComputePipelineMTL.h @@ -35,6 +35,9 @@ class ComputePipeline final : public ComputePipelineBase { WGPUCreateComputePipelineAsyncCallback callback, void* userdata); + ComputePipeline(DeviceBase* device, const ComputePipelineDescriptor* descriptor); + ~ComputePipeline() override; + void Encode(id encoder); MTLSize GetLocalWorkGroupSize() const; bool RequiresStorageBufferLength() const; diff --git a/src/dawn/native/metal/ComputePipelineMTL.mm b/src/dawn/native/metal/ComputePipelineMTL.mm index f350071c8e..855cd7b4bf 100644 --- a/src/dawn/native/metal/ComputePipelineMTL.mm +++ b/src/dawn/native/metal/ComputePipelineMTL.mm @@ -29,6 +29,11 @@ Ref ComputePipeline::CreateUninitialized( return AcquireRef(new ComputePipeline(device, descriptor)); } +ComputePipeline::ComputePipeline(DeviceBase* dev, const ComputePipelineDescriptor* desc) + : ComputePipelineBase(dev, desc) {} + +ComputePipeline::~ComputePipeline() = default; + MaybeError ComputePipeline::Initialize() { auto mtlDevice = ToBackend(GetDevice())->GetMTLDevice(); diff --git a/src/dawn/native/metal/PipelineLayoutMTL.h b/src/dawn/native/metal/PipelineLayoutMTL.h index 16519543a1..48711e7693 100644 --- a/src/dawn/native/metal/PipelineLayoutMTL.h +++ b/src/dawn/native/metal/PipelineLayoutMTL.h @@ -51,7 +51,7 @@ class PipelineLayout final : public PipelineLayoutBase { private: PipelineLayout(Device* device, const PipelineLayoutDescriptor* descriptor); - ~PipelineLayout() override = default; + ~PipelineLayout() override; PerStage mIndexInfo; PerStage mBufferBindingCount; }; diff --git a/src/dawn/native/metal/PipelineLayoutMTL.mm b/src/dawn/native/metal/PipelineLayoutMTL.mm index 2dfad2e059..800db51a7c 100644 --- a/src/dawn/native/metal/PipelineLayoutMTL.mm +++ b/src/dawn/native/metal/PipelineLayoutMTL.mm @@ -70,6 +70,8 @@ PipelineLayout::PipelineLayout(Device* device, const PipelineLayoutDescriptor* d } } +PipelineLayout::~PipelineLayout() = default; + const PipelineLayout::BindingIndexInfo& PipelineLayout::GetBindingIndexInfo( SingleShaderStage stage) const { return mIndexInfo[stage]; diff --git a/src/dawn/native/metal/QuerySetMTL.h b/src/dawn/native/metal/QuerySetMTL.h index 9f0e6bb605..c8b4c73afa 100644 --- a/src/dawn/native/metal/QuerySetMTL.h +++ b/src/dawn/native/metal/QuerySetMTL.h @@ -30,15 +30,18 @@ class QuerySet final : public QuerySetBase { static ResultOrError> Create(Device* device, const QuerySetDescriptor* descriptor); + QuerySet(DeviceBase* device, const QuerySetDescriptor* descriptor); + id GetVisibilityBuffer() const; id GetCounterSampleBuffer() const API_AVAILABLE(macos(10.15), ios(14.0)); private: - ~QuerySet() override; using QuerySetBase::QuerySetBase; MaybeError Initialize(); + ~QuerySet() override; + // Dawn API void DestroyImpl() override; diff --git a/src/dawn/native/metal/QuerySetMTL.mm b/src/dawn/native/metal/QuerySetMTL.mm index 1e19963c16..262ddc8338 100644 --- a/src/dawn/native/metal/QuerySetMTL.mm +++ b/src/dawn/native/metal/QuerySetMTL.mm @@ -68,6 +68,8 @@ ResultOrError> QuerySet::Create(Device* device, return queryset; } +QuerySet::QuerySet(DeviceBase* dev, const QuerySetDescriptor* desc) : QuerySetBase(dev, desc) {} + MaybeError QuerySet::Initialize() { Device* device = ToBackend(GetDevice()); diff --git a/src/dawn/native/metal/QueueMTL.h b/src/dawn/native/metal/QueueMTL.h index e1a37b97f9..5f95921916 100644 --- a/src/dawn/native/metal/QueueMTL.h +++ b/src/dawn/native/metal/QueueMTL.h @@ -24,6 +24,7 @@ class Device; class Queue final : public QueueBase { public: Queue(Device* device, const QueueDescriptor* descriptor); + ~Queue() override; private: MaybeError SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) override; diff --git a/src/dawn/native/metal/QueueMTL.mm b/src/dawn/native/metal/QueueMTL.mm index c129c5d51d..f6cfa4cdf5 100644 --- a/src/dawn/native/metal/QueueMTL.mm +++ b/src/dawn/native/metal/QueueMTL.mm @@ -28,6 +28,8 @@ namespace dawn::native::metal { Queue::Queue(Device* device, const QueueDescriptor* descriptor) : QueueBase(device, descriptor) {} +Queue::~Queue() = default; + MaybeError Queue::SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) { Device* device = ToBackend(GetDevice()); diff --git a/src/dawn/native/metal/RenderPipelineMTL.h b/src/dawn/native/metal/RenderPipelineMTL.h index cd8111dff7..23268aea03 100644 --- a/src/dawn/native/metal/RenderPipelineMTL.h +++ b/src/dawn/native/metal/RenderPipelineMTL.h @@ -33,6 +33,9 @@ class RenderPipeline final : public RenderPipelineBase { WGPUCreateRenderPipelineAsyncCallback callback, void* userdata); + RenderPipeline(DeviceBase* device, const RenderPipelineDescriptor* descriptor); + ~RenderPipeline() override; + MTLPrimitiveType GetMTLPrimitiveTopology() const; MTLWinding GetMTLFrontFace() const; MTLCullMode GetMTLCullMode() const; diff --git a/src/dawn/native/metal/RenderPipelineMTL.mm b/src/dawn/native/metal/RenderPipelineMTL.mm index 2e10ed999c..89548aec86 100644 --- a/src/dawn/native/metal/RenderPipelineMTL.mm +++ b/src/dawn/native/metal/RenderPipelineMTL.mm @@ -310,6 +310,11 @@ Ref RenderPipeline::CreateUninitialized( return AcquireRef(new RenderPipeline(device, descriptor)); } +RenderPipeline::RenderPipeline(DeviceBase* dev, const RenderPipelineDescriptor* desc) + : RenderPipelineBase(dev, desc) {} + +RenderPipeline::~RenderPipeline() = default; + MaybeError RenderPipeline::Initialize() { mMtlPrimitiveTopology = MTLPrimitiveTopology(GetPrimitiveTopology()); mMtlFrontFace = MTLFrontFace(GetFrontFace()); diff --git a/src/dawn/native/metal/SamplerMTL.h b/src/dawn/native/metal/SamplerMTL.h index 2960817cd9..fb7b1fcb90 100644 --- a/src/dawn/native/metal/SamplerMTL.h +++ b/src/dawn/native/metal/SamplerMTL.h @@ -29,6 +29,9 @@ class Sampler final : public SamplerBase { public: static ResultOrError> Create(Device* device, const SamplerDescriptor* descriptor); + Sampler(DeviceBase* device, const SamplerDescriptor* descriptor); + ~Sampler() override; + id GetMTLSamplerState(); private: diff --git a/src/dawn/native/metal/SamplerMTL.mm b/src/dawn/native/metal/SamplerMTL.mm index 329cd28848..97b3046511 100644 --- a/src/dawn/native/metal/SamplerMTL.mm +++ b/src/dawn/native/metal/SamplerMTL.mm @@ -64,6 +64,10 @@ ResultOrError> Sampler::Create(Device* device, const SamplerDescrip return sampler; } +Sampler::Sampler(DeviceBase* dev, const SamplerDescriptor* desc) : SamplerBase(dev, desc) {} + +Sampler::~Sampler() = default; + MaybeError Sampler::Initialize(const SamplerDescriptor* descriptor) { NSRef mtlDescRef = AcquireNSRef([MTLSamplerDescriptor new]); MTLSamplerDescriptor* mtlDesc = mtlDescRef.Get(); diff --git a/src/dawn/native/metal/ShaderModuleMTL.h b/src/dawn/native/metal/ShaderModuleMTL.h index dc0ea0bbf4..035922384a 100644 --- a/src/dawn/native/metal/ShaderModuleMTL.h +++ b/src/dawn/native/metal/ShaderModuleMTL.h @@ -65,7 +65,7 @@ class ShaderModule final : public ShaderModuleBase { bool* hasInvariantAttribute, std::vector* workgroupAllocations); ShaderModule(Device* device, const ShaderModuleDescriptor* descriptor); - ~ShaderModule() override = default; + ~ShaderModule() override; MaybeError Initialize(ShaderModuleParseResult* parseResult, OwnedCompilationMessages* compilationMessages); }; diff --git a/src/dawn/native/metal/ShaderModuleMTL.mm b/src/dawn/native/metal/ShaderModuleMTL.mm index 7b17c56d3c..fa8befd2e5 100644 --- a/src/dawn/native/metal/ShaderModuleMTL.mm +++ b/src/dawn/native/metal/ShaderModuleMTL.mm @@ -42,6 +42,8 @@ ResultOrError> ShaderModule::Create( ShaderModule::ShaderModule(Device* device, const ShaderModuleDescriptor* descriptor) : ShaderModuleBase(device, descriptor) {} +ShaderModule::~ShaderModule() = default; + MaybeError ShaderModule::Initialize(ShaderModuleParseResult* parseResult, OwnedCompilationMessages* compilationMessages) { ScopedTintICEHandler scopedICEHandler(GetDevice()); diff --git a/src/dawn/native/metal/StagingBufferMTL.h b/src/dawn/native/metal/StagingBufferMTL.h index afd2eac6dd..bbad022d5a 100644 --- a/src/dawn/native/metal/StagingBufferMTL.h +++ b/src/dawn/native/metal/StagingBufferMTL.h @@ -28,6 +28,7 @@ class Device; class StagingBuffer : public StagingBufferBase { public: StagingBuffer(size_t size, Device* device); + ~StagingBuffer() override; id GetBufferHandle() const; diff --git a/src/dawn/native/metal/StagingBufferMTL.mm b/src/dawn/native/metal/StagingBufferMTL.mm index 6bdc9e3db7..f4255f1324 100644 --- a/src/dawn/native/metal/StagingBufferMTL.mm +++ b/src/dawn/native/metal/StagingBufferMTL.mm @@ -20,6 +20,8 @@ namespace dawn::native::metal { StagingBuffer::StagingBuffer(size_t size, Device* device) : StagingBufferBase(size), mDevice(device) {} +StagingBuffer::~StagingBuffer() = default; + MaybeError StagingBuffer::Initialize() { const size_t bufferSize = GetSize(); mBuffer = diff --git a/src/dawn/native/metal/SwapChainMTL.h b/src/dawn/native/metal/SwapChainMTL.h index 003629cd5f..de5cd5c5d4 100644 --- a/src/dawn/native/metal/SwapChainMTL.h +++ b/src/dawn/native/metal/SwapChainMTL.h @@ -44,6 +44,8 @@ class SwapChain final : public NewSwapChainBase { Surface* surface, NewSwapChainBase* previousSwapChain, const SwapChainDescriptor* descriptor); + + SwapChain(DeviceBase* device, Surface* surface, const SwapChainDescriptor* descriptor); ~SwapChain() override; private: diff --git a/src/dawn/native/metal/SwapChainMTL.mm b/src/dawn/native/metal/SwapChainMTL.mm index bf688841ec..d9435dd84f 100644 --- a/src/dawn/native/metal/SwapChainMTL.mm +++ b/src/dawn/native/metal/SwapChainMTL.mm @@ -72,6 +72,9 @@ ResultOrError> SwapChain::Create(Device* device, return swapchain; } +SwapChain::SwapChain(DeviceBase* dev, Surface* sur, const SwapChainDescriptor* desc) + : NewSwapChainBase(dev, sur, desc) {} + SwapChain::~SwapChain() = default; void SwapChain::DestroyImpl() { diff --git a/src/dawn/native/metal/TextureMTL.h b/src/dawn/native/metal/TextureMTL.h index d8b8ccd2ff..3a9c3d8f35 100644 --- a/src/dawn/native/metal/TextureMTL.h +++ b/src/dawn/native/metal/TextureMTL.h @@ -45,6 +45,8 @@ class Texture final : public TextureBase { const TextureDescriptor* descriptor, NSPRef> wrapped); + Texture(DeviceBase* device, const TextureDescriptor* descriptor, TextureState state); + id GetMTLTexture() const; IOSurfaceRef GetIOSurface(); NSPRef> CreateFormatView(wgpu::TextureFormat format); diff --git a/src/dawn/native/metal/TextureMTL.mm b/src/dawn/native/metal/TextureMTL.mm index 429d60ce15..38db7cfa32 100644 --- a/src/dawn/native/metal/TextureMTL.mm +++ b/src/dawn/native/metal/TextureMTL.mm @@ -772,6 +772,9 @@ MaybeError Texture::InitializeFromIOSurface(const ExternalImageDescriptor* descr return {}; } +Texture::Texture(DeviceBase* dev, const TextureDescriptor* desc, TextureState st) + : TextureBase(dev, desc, st) {} + Texture::~Texture() {} void Texture::DestroyImpl() { diff --git a/src/dawn/native/vulkan/AdapterVk.cpp b/src/dawn/native/vulkan/AdapterVk.cpp index 6b0d770a3e..c414c6240d 100644 --- a/src/dawn/native/vulkan/AdapterVk.cpp +++ b/src/dawn/native/vulkan/AdapterVk.cpp @@ -32,6 +32,8 @@ Adapter::Adapter(InstanceBase* instance, mPhysicalDevice(physicalDevice), mVulkanInstance(vulkanInstance) {} +Adapter::~Adapter() = default; + const VulkanDeviceInfo& Adapter::GetDeviceInfo() const { return mDeviceInfo; } diff --git a/src/dawn/native/vulkan/AdapterVk.h b/src/dawn/native/vulkan/AdapterVk.h index 2d9ce45a5a..9cb5234a65 100644 --- a/src/dawn/native/vulkan/AdapterVk.h +++ b/src/dawn/native/vulkan/AdapterVk.h @@ -30,7 +30,7 @@ class Adapter : public AdapterBase { Adapter(InstanceBase* instance, VulkanInstance* vulkanInstance, VkPhysicalDevice physicalDevice); - ~Adapter() override = default; + ~Adapter() override; // AdapterBase Implementation bool SupportsExternalImages() const override; diff --git a/src/dawn/wire/ChunkedCommandHandler.cpp b/src/dawn/wire/ChunkedCommandHandler.cpp index 9c3dc0eaa1..7dd1075ead 100644 --- a/src/dawn/wire/ChunkedCommandHandler.cpp +++ b/src/dawn/wire/ChunkedCommandHandler.cpp @@ -22,6 +22,8 @@ namespace dawn::wire { +ChunkedCommandHandler::ChunkedCommandHandler() = default; + ChunkedCommandHandler::~ChunkedCommandHandler() = default; const volatile char* ChunkedCommandHandler::HandleCommands(const volatile char* commands, diff --git a/src/dawn/wire/ChunkedCommandHandler.h b/src/dawn/wire/ChunkedCommandHandler.h index c84c4ef8a9..713ed38c14 100644 --- a/src/dawn/wire/ChunkedCommandHandler.h +++ b/src/dawn/wire/ChunkedCommandHandler.h @@ -27,9 +27,11 @@ namespace dawn::wire { class ChunkedCommandHandler : public CommandHandler { public: - const volatile char* HandleCommands(const volatile char* commands, size_t size) override; + ChunkedCommandHandler(); ~ChunkedCommandHandler() override; + const volatile char* HandleCommands(const volatile char* commands, size_t size) override; + protected: enum class ChunkedCommandsResult { Passthrough, diff --git a/src/dawn/wire/server/Server.cpp b/src/dawn/wire/server/Server.cpp index 565154e39e..6dc8358e54 100644 --- a/src/dawn/wire/server/Server.cpp +++ b/src/dawn/wire/server/Server.cpp @@ -17,6 +17,9 @@ namespace dawn::wire::server { +CallbackUserdata::CallbackUserdata(Server* server, const std::shared_ptr& serverIsAlive) + : server(server), serverIsAlive(serverIsAlive) {} + Server::Server(const DawnProcTable& procs, CommandSerializer* serializer, MemoryTransferService* memoryTransferService) diff --git a/src/dawn/wire/server/Server.h b/src/dawn/wire/server/Server.h index 52901b0966..9bf60c8468 100644 --- a/src/dawn/wire/server/Server.h +++ b/src/dawn/wire/server/Server.h @@ -55,8 +55,7 @@ struct CallbackUserdata { std::weak_ptr const serverIsAlive; CallbackUserdata() = delete; - CallbackUserdata(Server* server, const std::shared_ptr& serverIsAlive) - : server(server), serverIsAlive(serverIsAlive) {} + CallbackUserdata(Server* server, const std::shared_ptr& serverIsAlive); }; template