[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 <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
dan sinclair 2022-05-09 22:22:18 +00:00 committed by Dawn LUCI CQ
parent b61e0452f8
commit 61f30bad1e
56 changed files with 164 additions and 16 deletions

View File

@ -77,4 +77,8 @@ void AsyncTaskManager::DoWaitableTask(void* task) {
waitableTask->taskManager->HandleTaskCompletion(waitableTask.Get()); waitableTask->taskManager->HandleTaskCompletion(waitableTask.Get());
} }
AsyncTaskManager::WaitableTask::WaitableTask() = default;
AsyncTaskManager::WaitableTask::~WaitableTask() = default;
} // namespace dawn::native } // namespace dawn::native

View File

@ -47,6 +47,9 @@ class AsyncTaskManager {
private: private:
class WaitableTask : public RefCounted { class WaitableTask : public RefCounted {
public: public:
WaitableTask();
~WaitableTask();
AsyncTask asyncTask; AsyncTask asyncTask;
AsyncTaskManager* taskManager; AsyncTaskManager* taskManager;
std::unique_ptr<dawn::platform::WaitableEvent> waitableEvent; std::unique_ptr<dawn::platform::WaitableEvent> waitableEvent;

View File

@ -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 { bool CachedBlob::Empty() const {
return mSize == 0; return mSize == 0;
} }

View File

@ -31,6 +31,10 @@ class InstanceBase;
class CachedBlob { class CachedBlob {
public: public:
explicit CachedBlob(size_t size = 0); explicit CachedBlob(size_t size = 0);
CachedBlob(CachedBlob&&);
~CachedBlob();
CachedBlob& operator=(CachedBlob&&);
bool Empty() const; bool Empty() const;
const uint8_t* Data() const; const uint8_t* Data() const;

View File

@ -34,6 +34,8 @@ BuddyMemoryAllocator::BuddyMemoryAllocator(uint64_t maxSystemSize,
mTrackedSubAllocations.resize(maxSystemSize / mMemoryBlockSize); mTrackedSubAllocations.resize(maxSystemSize / mMemoryBlockSize);
} }
BuddyMemoryAllocator::~BuddyMemoryAllocator() = default;
uint64_t BuddyMemoryAllocator::GetMemoryIndex(uint64_t offset) const { uint64_t BuddyMemoryAllocator::GetMemoryIndex(uint64_t offset) const {
ASSERT(offset != BuddyAllocator::kInvalidOffset); ASSERT(offset != BuddyAllocator::kInvalidOffset);
return offset / mMemoryBlockSize; return offset / mMemoryBlockSize;

View File

@ -42,7 +42,7 @@ class BuddyMemoryAllocator {
BuddyMemoryAllocator(uint64_t maxSystemSize, BuddyMemoryAllocator(uint64_t maxSystemSize,
uint64_t memoryBlockSize, uint64_t memoryBlockSize,
ResourceHeapAllocator* heapAllocator); ResourceHeapAllocator* heapAllocator);
~BuddyMemoryAllocator() = default; ~BuddyMemoryAllocator();
ResultOrError<ResourceMemoryAllocation> Allocate(uint64_t allocationSize, uint64_t alignment); ResultOrError<ResourceMemoryAllocation> Allocate(uint64_t allocationSize, uint64_t alignment);
void Deallocate(const ResourceMemoryAllocation& allocation); void Deallocate(const ResourceMemoryAllocation& allocation);

View File

@ -18,6 +18,10 @@
namespace dawn::native { namespace dawn::native {
CallbackTaskManager::CallbackTaskManager() = default;
CallbackTaskManager::~CallbackTaskManager() = default;
bool CallbackTaskManager::IsEmpty() { bool CallbackTaskManager::IsEmpty() {
std::lock_guard<std::mutex> lock(mCallbackTaskQueueMutex); std::lock_guard<std::mutex> lock(mCallbackTaskQueueMutex);
return mCallbackTaskQueue.empty(); return mCallbackTaskQueue.empty();

View File

@ -31,6 +31,9 @@ struct CallbackTask {
class CallbackTaskManager { class CallbackTaskManager {
public: public:
CallbackTaskManager();
~CallbackTaskManager();
void AddCallbackTask(std::unique_ptr<CallbackTask> callbackTask); void AddCallbackTask(std::unique_ptr<CallbackTask> callbackTask);
bool IsEmpty(); bool IsEmpty();
std::vector<std::unique_ptr<CallbackTask>> AcquireCallbackTasks(); std::vector<std::unique_ptr<CallbackTask>> AcquireCallbackTasks();

View File

@ -30,6 +30,8 @@ CreatePipelineAsyncCallbackTaskBase::CreatePipelineAsyncCallbackTaskBase(std::st
void* userdata) void* userdata)
: mErrorMessage(errorMessage), mUserData(userdata) {} : mErrorMessage(errorMessage), mUserData(userdata) {}
CreatePipelineAsyncCallbackTaskBase::~CreatePipelineAsyncCallbackTaskBase() = default;
CreateComputePipelineAsyncCallbackTask::CreateComputePipelineAsyncCallbackTask( CreateComputePipelineAsyncCallbackTask::CreateComputePipelineAsyncCallbackTask(
Ref<ComputePipelineBase> pipeline, Ref<ComputePipelineBase> pipeline,
std::string errorMessage, std::string errorMessage,
@ -39,6 +41,8 @@ CreateComputePipelineAsyncCallbackTask::CreateComputePipelineAsyncCallbackTask(
mPipeline(std::move(pipeline)), mPipeline(std::move(pipeline)),
mCreateComputePipelineAsyncCallback(callback) {} mCreateComputePipelineAsyncCallback(callback) {}
CreateComputePipelineAsyncCallbackTask::~CreateComputePipelineAsyncCallbackTask() = default;
void CreateComputePipelineAsyncCallbackTask::Finish() { void CreateComputePipelineAsyncCallbackTask::Finish() {
ASSERT(mCreateComputePipelineAsyncCallback != nullptr); ASSERT(mCreateComputePipelineAsyncCallback != nullptr);
@ -74,6 +78,8 @@ CreateRenderPipelineAsyncCallbackTask::CreateRenderPipelineAsyncCallbackTask(
mPipeline(std::move(pipeline)), mPipeline(std::move(pipeline)),
mCreateRenderPipelineAsyncCallback(callback) {} mCreateRenderPipelineAsyncCallback(callback) {}
CreateRenderPipelineAsyncCallbackTask::~CreateRenderPipelineAsyncCallbackTask() = default;
void CreateRenderPipelineAsyncCallbackTask::Finish() { void CreateRenderPipelineAsyncCallbackTask::Finish() {
ASSERT(mCreateRenderPipelineAsyncCallback != nullptr); ASSERT(mCreateRenderPipelineAsyncCallback != nullptr);
@ -110,6 +116,8 @@ CreateComputePipelineAsyncTask::CreateComputePipelineAsyncTask(
ASSERT(mComputePipeline != nullptr); ASSERT(mComputePipeline != nullptr);
} }
CreateComputePipelineAsyncTask::~CreateComputePipelineAsyncTask() = default;
void CreateComputePipelineAsyncTask::Run() { void CreateComputePipelineAsyncTask::Run() {
const char* eventLabel = utils::GetLabelForTrace(mComputePipeline->GetLabel().c_str()); const char* eventLabel = utils::GetLabelForTrace(mComputePipeline->GetLabel().c_str());
@ -160,6 +168,8 @@ CreateRenderPipelineAsyncTask::CreateRenderPipelineAsyncTask(
ASSERT(mRenderPipeline != nullptr); ASSERT(mRenderPipeline != nullptr);
} }
CreateRenderPipelineAsyncTask::~CreateRenderPipelineAsyncTask() = default;
void CreateRenderPipelineAsyncTask::Run() { void CreateRenderPipelineAsyncTask::Run() {
const char* eventLabel = utils::GetLabelForTrace(mRenderPipeline->GetLabel().c_str()); const char* eventLabel = utils::GetLabelForTrace(mRenderPipeline->GetLabel().c_str());

View File

@ -34,6 +34,7 @@ struct FlatComputePipelineDescriptor;
struct CreatePipelineAsyncCallbackTaskBase : CallbackTask { struct CreatePipelineAsyncCallbackTaskBase : CallbackTask {
CreatePipelineAsyncCallbackTaskBase(std::string errorMessage, void* userData); CreatePipelineAsyncCallbackTaskBase(std::string errorMessage, void* userData);
~CreatePipelineAsyncCallbackTaskBase();
protected: protected:
std::string mErrorMessage; std::string mErrorMessage;
@ -45,6 +46,7 @@ struct CreateComputePipelineAsyncCallbackTask : CreatePipelineAsyncCallbackTaskB
std::string errorMessage, std::string errorMessage,
WGPUCreateComputePipelineAsyncCallback callback, WGPUCreateComputePipelineAsyncCallback callback,
void* userdata); void* userdata);
~CreateComputePipelineAsyncCallbackTask() override;
void Finish() override; void Finish() override;
void HandleShutDown() final; void HandleShutDown() final;
@ -60,6 +62,7 @@ struct CreateRenderPipelineAsyncCallbackTask : CreatePipelineAsyncCallbackTaskBa
std::string errorMessage, std::string errorMessage,
WGPUCreateRenderPipelineAsyncCallback callback, WGPUCreateRenderPipelineAsyncCallback callback,
void* userdata); void* userdata);
~CreateRenderPipelineAsyncCallbackTask() override;
void Finish() override; void Finish() override;
void HandleShutDown() final; void HandleShutDown() final;
@ -77,6 +80,7 @@ class CreateComputePipelineAsyncTask {
CreateComputePipelineAsyncTask(Ref<ComputePipelineBase> nonInitializedComputePipeline, CreateComputePipelineAsyncTask(Ref<ComputePipelineBase> nonInitializedComputePipeline,
WGPUCreateComputePipelineAsyncCallback callback, WGPUCreateComputePipelineAsyncCallback callback,
void* userdata); void* userdata);
~CreateComputePipelineAsyncTask();
void Run(); void Run();
@ -95,6 +99,7 @@ class CreateRenderPipelineAsyncTask {
CreateRenderPipelineAsyncTask(Ref<RenderPipelineBase> nonInitializedRenderPipeline, CreateRenderPipelineAsyncTask(Ref<RenderPipelineBase> nonInitializedRenderPipeline,
WGPUCreateRenderPipelineAsyncCallback callback, WGPUCreateRenderPipelineAsyncCallback callback,
void* userdata); void* userdata);
~CreateRenderPipelineAsyncTask();
void Run(); void Run();

View File

@ -45,6 +45,10 @@ const char* ErrorScope::GetErrorMessage() const {
return mErrorMessage.c_str(); return mErrorMessage.c_str();
} }
ErrorScopeStack::ErrorScopeStack() = default;
ErrorScopeStack::~ErrorScopeStack() = default;
void ErrorScopeStack::Push(wgpu::ErrorFilter filter) { void ErrorScopeStack::Push(wgpu::ErrorFilter filter) {
mScopes.push_back(ErrorScope(filter)); mScopes.push_back(ErrorScope(filter));
} }

View File

@ -38,6 +38,9 @@ class ErrorScope {
class ErrorScopeStack { class ErrorScopeStack {
public: public:
ErrorScopeStack();
~ErrorScopeStack();
void Push(wgpu::ErrorFilter errorFilter); void Push(wgpu::ErrorFilter errorFilter);
ErrorScope Pop(); ErrorScope Pop();

View File

@ -232,6 +232,8 @@ FeaturesInfo::FeaturesInfo() {
} }
} }
FeaturesInfo::~FeaturesInfo() = default;
const FeatureInfo* FeaturesInfo::GetFeatureInfo(wgpu::FeatureName feature) const { const FeatureInfo* FeaturesInfo::GetFeatureInfo(wgpu::FeatureName feature) const {
Feature f = FromAPIFeature(feature); Feature f = FromAPIFeature(feature);
if (f == Feature::InvalidEnum) { if (f == Feature::InvalidEnum) {

View File

@ -68,6 +68,7 @@ wgpu::FeatureName FeatureEnumToAPIFeature(Feature feature);
class FeaturesInfo { class FeaturesInfo {
public: public:
FeaturesInfo(); FeaturesInfo();
~FeaturesInfo();
// Used to query the details of an feature. Return nullptr if featureName is not a valid // Used to query the details of an feature. Return nullptr if featureName is not a valid
// name of an feature supported in Dawn // name of an feature supported in Dawn

View File

@ -122,6 +122,10 @@ Ref<InstanceBase> InstanceBase::Create(const InstanceDescriptor* descriptor) {
return instance; return instance;
} }
InstanceBase::InstanceBase() = default;
InstanceBase::~InstanceBase() = default;
// TODO(crbug.com/dawn/832): make the platform an initialization parameter of the instance. // TODO(crbug.com/dawn/832): make the platform an initialization parameter of the instance.
MaybeError InstanceBase::Initialize(const InstanceDescriptor* descriptor) { MaybeError InstanceBase::Initialize(const InstanceDescriptor* descriptor) {
DAWN_TRY(ValidateSingleSType(descriptor->nextInChain, wgpu::SType::DawnInstanceDescriptor)); DAWN_TRY(ValidateSingleSType(descriptor->nextInChain, wgpu::SType::DawnInstanceDescriptor));

View File

@ -93,8 +93,8 @@ class InstanceBase final : public RefCounted {
Surface* APICreateSurface(const SurfaceDescriptor* descriptor); Surface* APICreateSurface(const SurfaceDescriptor* descriptor);
private: private:
InstanceBase() = default; InstanceBase();
~InstanceBase() override = default; ~InstanceBase() override;
InstanceBase(const InstanceBase& other) = delete; InstanceBase(const InstanceBase& other) = delete;
InstanceBase& operator=(const InstanceBase& other) = delete; InstanceBase& operator=(const InstanceBase& other) = delete;

View File

@ -23,6 +23,8 @@ namespace dawn::native {
PooledResourceMemoryAllocator::PooledResourceMemoryAllocator(ResourceHeapAllocator* heapAllocator) PooledResourceMemoryAllocator::PooledResourceMemoryAllocator(ResourceHeapAllocator* heapAllocator)
: mHeapAllocator(heapAllocator) {} : mHeapAllocator(heapAllocator) {}
PooledResourceMemoryAllocator::~PooledResourceMemoryAllocator() = default;
void PooledResourceMemoryAllocator::DestroyPool() { void PooledResourceMemoryAllocator::DestroyPool() {
for (auto& resourceHeap : mPool) { for (auto& resourceHeap : mPool) {
ASSERT(resourceHeap != nullptr); ASSERT(resourceHeap != nullptr);

View File

@ -32,7 +32,7 @@ class DeviceBase;
class PooledResourceMemoryAllocator : public ResourceHeapAllocator { class PooledResourceMemoryAllocator : public ResourceHeapAllocator {
public: public:
explicit PooledResourceMemoryAllocator(ResourceHeapAllocator* heapAllocator); explicit PooledResourceMemoryAllocator(ResourceHeapAllocator* heapAllocator);
~PooledResourceMemoryAllocator() override = default; ~PooledResourceMemoryAllocator() override;
ResultOrError<std::unique_ptr<ResourceHeapBase>> AllocateResourceHeap(uint64_t size) override; ResultOrError<std::unique_ptr<ResourceHeapBase>> AllocateResourceHeap(uint64_t size) override;
void DeallocateResourceHeap(std::unique_ptr<ResourceHeapBase> allocation) override; void DeallocateResourceHeap(std::unique_ptr<ResourceHeapBase> allocation) override;

View File

@ -30,8 +30,16 @@
// used bytes. // used bytes.
namespace dawn::native { namespace dawn::native {
RingBufferAllocator::RingBufferAllocator() = default;
RingBufferAllocator::RingBufferAllocator(uint64_t maxSize) : mMaxBlockSize(maxSize) {} 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) { void RingBufferAllocator::Deallocate(ExecutionSerial lastCompletedSerial) {
// Reclaim memory from previously recorded blocks. // Reclaim memory from previously recorded blocks.
for (Request& request : mInflightRequests.IterateUpTo(lastCompletedSerial)) { for (Request& request : mInflightRequests.IterateUpTo(lastCompletedSerial)) {

View File

@ -26,11 +26,12 @@ namespace dawn::native {
class RingBufferAllocator { class RingBufferAllocator {
public: public:
RingBufferAllocator() = default; RingBufferAllocator();
explicit RingBufferAllocator(uint64_t maxSize); explicit RingBufferAllocator(uint64_t maxSize);
~RingBufferAllocator() = default; RingBufferAllocator(const RingBufferAllocator&);
RingBufferAllocator(const RingBufferAllocator&) = default; ~RingBufferAllocator();
RingBufferAllocator& operator=(const RingBufferAllocator&) = default;
RingBufferAllocator& operator=(const RingBufferAllocator&);
uint64_t Allocate(uint64_t allocationSize, ExecutionSerial serial); uint64_t Allocate(uint64_t allocationSize, ExecutionSerial serial);
void Deallocate(ExecutionSerial lastCompletedSerial); void Deallocate(ExecutionSerial lastCompletedSerial);

View File

@ -313,6 +313,10 @@ const char* ToggleEnumToName(Toggle toggle) {
return toggleNameAndInfo.info.name; return toggleNameAndInfo.info.name;
} }
TogglesInfo::TogglesInfo() = default;
TogglesInfo::~TogglesInfo() = default;
const ToggleInfo* TogglesInfo::GetToggleInfo(const char* toggleName) { const ToggleInfo* TogglesInfo::GetToggleInfo(const char* toggleName) {
ASSERT(toggleName); ASSERT(toggleName);

View File

@ -91,6 +91,9 @@ const char* ToggleEnumToName(Toggle toggle);
class TogglesInfo { class TogglesInfo {
public: public:
TogglesInfo();
~TogglesInfo();
// Used to query the details of a toggle. Return nullptr if toggleName is not a valid name // Used to query the details of a toggle. Return nullptr if toggleName is not a valid name
// of a toggle supported in Dawn. // of a toggle supported in Dawn.
const ToggleInfo* GetToggleInfo(const char* toggleName); const ToggleInfo* GetToggleInfo(const char* toggleName);

View File

@ -24,6 +24,7 @@ namespace dawn::native::metal {
class Backend : public BackendConnection { class Backend : public BackendConnection {
public: public:
explicit Backend(InstanceBase* instance); explicit Backend(InstanceBase* instance);
~Backend() override;
std::vector<Ref<AdapterBase>> DiscoverDefaultAdapters() override; std::vector<Ref<AdapterBase>> DiscoverDefaultAdapters() override;
ResultOrError<std::vector<Ref<AdapterBase>>> DiscoverAdapters( ResultOrError<std::vector<Ref<AdapterBase>>> DiscoverAdapters(

View File

@ -608,6 +608,8 @@ Backend::Backend(InstanceBase* instance) : BackendConnection(instance, wgpu::Bac
} }
} }
Backend::~Backend() = default;
std::vector<Ref<AdapterBase>> Backend::DiscoverDefaultAdapters() { std::vector<Ref<AdapterBase>> Backend::DiscoverDefaultAdapters() {
AdapterDiscoveryOptions options; AdapterDiscoveryOptions options;
auto result = DiscoverAdapters(&options); auto result = DiscoverAdapters(&options);

View File

@ -36,7 +36,7 @@ class BindGroupLayout final : public BindGroupLayoutBase {
BindGroupLayout(DeviceBase* device, BindGroupLayout(DeviceBase* device,
const BindGroupLayoutDescriptor* descriptor, const BindGroupLayoutDescriptor* descriptor,
PipelineCompatibilityToken pipelineCompatibilityToken); PipelineCompatibilityToken pipelineCompatibilityToken);
~BindGroupLayout() override = default; ~BindGroupLayout() override;
SlabAllocator<BindGroup> mBindGroupAllocator; SlabAllocator<BindGroup> mBindGroupAllocator;
}; };

View File

@ -32,6 +32,8 @@ BindGroupLayout::BindGroupLayout(DeviceBase* device,
: BindGroupLayoutBase(device, descriptor, pipelineCompatibilityToken), : BindGroupLayoutBase(device, descriptor, pipelineCompatibilityToken),
mBindGroupAllocator(MakeFrontendBindGroupAllocator<BindGroup>(4096)) {} mBindGroupAllocator(MakeFrontendBindGroupAllocator<BindGroup>(4096)) {}
BindGroupLayout::~BindGroupLayout() = default;
Ref<BindGroup> BindGroupLayout::AllocateBindGroup(Device* device, Ref<BindGroup> BindGroupLayout::AllocateBindGroup(Device* device,
const BindGroupDescriptor* descriptor) { const BindGroupDescriptor* descriptor) {
return AcquireRef(mBindGroupAllocator.Allocate(device, descriptor)); return AcquireRef(mBindGroupAllocator.Allocate(device, descriptor));

View File

@ -29,6 +29,9 @@ class Device;
class Buffer final : public BufferBase { class Buffer final : public BufferBase {
public: public:
static ResultOrError<Ref<Buffer>> Create(Device* device, const BufferDescriptor* descriptor); static ResultOrError<Ref<Buffer>> Create(Device* device, const BufferDescriptor* descriptor);
Buffer(DeviceBase* device, const BufferDescriptor* descriptor);
id<MTLBuffer> GetMTLBuffer() const; id<MTLBuffer> GetMTLBuffer() const;
bool EnsureDataInitialized(CommandRecordingContext* commandContext); bool EnsureDataInitialized(CommandRecordingContext* commandContext);
@ -45,6 +48,7 @@ class Buffer final : public BufferBase {
MaybeError Initialize(bool mappedAtCreation); MaybeError Initialize(bool mappedAtCreation);
~Buffer() override; ~Buffer() override;
MaybeError MapAsyncImpl(wgpu::MapMode mode, size_t offset, size_t size) override; MaybeError MapAsyncImpl(wgpu::MapMode mode, size_t offset, size_t size) override;
void UnmapImpl() override; void UnmapImpl() override;
void DestroyImpl() override; void DestroyImpl() override;

View File

@ -59,6 +59,8 @@ uint64_t Buffer::QueryMaxBufferLength(id<MTLDevice> mtlDevice) {
#endif #endif
} }
Buffer::Buffer(DeviceBase* dev, const BufferDescriptor* desc) : BufferBase(dev, desc) {}
MaybeError Buffer::Initialize(bool mappedAtCreation) { MaybeError Buffer::Initialize(bool mappedAtCreation) {
MTLResourceOptions storageMode; MTLResourceOptions storageMode;
if (GetUsage() & kMappableBufferUsages) { if (GetUsage() & kMappableBufferUsages) {

View File

@ -47,6 +47,9 @@ class CommandBuffer final : public CommandBufferBase {
static Ref<CommandBuffer> Create(CommandEncoder* encoder, static Ref<CommandBuffer> Create(CommandEncoder* encoder,
const CommandBufferDescriptor* descriptor); const CommandBufferDescriptor* descriptor);
CommandBuffer(CommandEncoder* encoder, const CommandBufferDescriptor* descriptor);
~CommandBuffer();
MaybeError FillCommands(CommandRecordingContext* commandContext); MaybeError FillCommands(CommandRecordingContext* commandContext);
private: private:

View File

@ -577,6 +577,11 @@ Ref<CommandBuffer> CommandBuffer::Create(CommandEncoder* encoder,
return AcquireRef(new CommandBuffer(encoder, descriptor)); return AcquireRef(new CommandBuffer(encoder, descriptor));
} }
CommandBuffer::CommandBuffer(CommandEncoder* enc, const CommandBufferDescriptor* desc)
: CommandBufferBase(enc, desc) {}
CommandBuffer::~CommandBuffer() = default;
MaybeError CommandBuffer::FillCommands(CommandRecordingContext* commandContext) { MaybeError CommandBuffer::FillCommands(CommandRecordingContext* commandContext) {
size_t nextComputePassNumber = 0; size_t nextComputePassNumber = 0;
size_t nextRenderPassNumber = 0; size_t nextRenderPassNumber = 0;

View File

@ -35,6 +35,9 @@ class ComputePipeline final : public ComputePipelineBase {
WGPUCreateComputePipelineAsyncCallback callback, WGPUCreateComputePipelineAsyncCallback callback,
void* userdata); void* userdata);
ComputePipeline(DeviceBase* device, const ComputePipelineDescriptor* descriptor);
~ComputePipeline() override;
void Encode(id<MTLComputeCommandEncoder> encoder); void Encode(id<MTLComputeCommandEncoder> encoder);
MTLSize GetLocalWorkGroupSize() const; MTLSize GetLocalWorkGroupSize() const;
bool RequiresStorageBufferLength() const; bool RequiresStorageBufferLength() const;

View File

@ -29,6 +29,11 @@ Ref<ComputePipeline> ComputePipeline::CreateUninitialized(
return AcquireRef(new ComputePipeline(device, descriptor)); return AcquireRef(new ComputePipeline(device, descriptor));
} }
ComputePipeline::ComputePipeline(DeviceBase* dev, const ComputePipelineDescriptor* desc)
: ComputePipelineBase(dev, desc) {}
ComputePipeline::~ComputePipeline() = default;
MaybeError ComputePipeline::Initialize() { MaybeError ComputePipeline::Initialize() {
auto mtlDevice = ToBackend(GetDevice())->GetMTLDevice(); auto mtlDevice = ToBackend(GetDevice())->GetMTLDevice();

View File

@ -51,7 +51,7 @@ class PipelineLayout final : public PipelineLayoutBase {
private: private:
PipelineLayout(Device* device, const PipelineLayoutDescriptor* descriptor); PipelineLayout(Device* device, const PipelineLayoutDescriptor* descriptor);
~PipelineLayout() override = default; ~PipelineLayout() override;
PerStage<BindingIndexInfo> mIndexInfo; PerStage<BindingIndexInfo> mIndexInfo;
PerStage<uint32_t> mBufferBindingCount; PerStage<uint32_t> mBufferBindingCount;
}; };

View File

@ -70,6 +70,8 @@ PipelineLayout::PipelineLayout(Device* device, const PipelineLayoutDescriptor* d
} }
} }
PipelineLayout::~PipelineLayout() = default;
const PipelineLayout::BindingIndexInfo& PipelineLayout::GetBindingIndexInfo( const PipelineLayout::BindingIndexInfo& PipelineLayout::GetBindingIndexInfo(
SingleShaderStage stage) const { SingleShaderStage stage) const {
return mIndexInfo[stage]; return mIndexInfo[stage];

View File

@ -30,15 +30,18 @@ class QuerySet final : public QuerySetBase {
static ResultOrError<Ref<QuerySet>> Create(Device* device, static ResultOrError<Ref<QuerySet>> Create(Device* device,
const QuerySetDescriptor* descriptor); const QuerySetDescriptor* descriptor);
QuerySet(DeviceBase* device, const QuerySetDescriptor* descriptor);
id<MTLBuffer> GetVisibilityBuffer() const; id<MTLBuffer> GetVisibilityBuffer() const;
id<MTLCounterSampleBuffer> GetCounterSampleBuffer() const id<MTLCounterSampleBuffer> GetCounterSampleBuffer() const
API_AVAILABLE(macos(10.15), ios(14.0)); API_AVAILABLE(macos(10.15), ios(14.0));
private: private:
~QuerySet() override;
using QuerySetBase::QuerySetBase; using QuerySetBase::QuerySetBase;
MaybeError Initialize(); MaybeError Initialize();
~QuerySet() override;
// Dawn API // Dawn API
void DestroyImpl() override; void DestroyImpl() override;

View File

@ -68,6 +68,8 @@ ResultOrError<Ref<QuerySet>> QuerySet::Create(Device* device,
return queryset; return queryset;
} }
QuerySet::QuerySet(DeviceBase* dev, const QuerySetDescriptor* desc) : QuerySetBase(dev, desc) {}
MaybeError QuerySet::Initialize() { MaybeError QuerySet::Initialize() {
Device* device = ToBackend(GetDevice()); Device* device = ToBackend(GetDevice());

View File

@ -24,6 +24,7 @@ class Device;
class Queue final : public QueueBase { class Queue final : public QueueBase {
public: public:
Queue(Device* device, const QueueDescriptor* descriptor); Queue(Device* device, const QueueDescriptor* descriptor);
~Queue() override;
private: private:
MaybeError SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) override; MaybeError SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) override;

View File

@ -28,6 +28,8 @@ namespace dawn::native::metal {
Queue::Queue(Device* device, const QueueDescriptor* descriptor) : QueueBase(device, descriptor) {} Queue::Queue(Device* device, const QueueDescriptor* descriptor) : QueueBase(device, descriptor) {}
Queue::~Queue() = default;
MaybeError Queue::SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) { MaybeError Queue::SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) {
Device* device = ToBackend(GetDevice()); Device* device = ToBackend(GetDevice());

View File

@ -33,6 +33,9 @@ class RenderPipeline final : public RenderPipelineBase {
WGPUCreateRenderPipelineAsyncCallback callback, WGPUCreateRenderPipelineAsyncCallback callback,
void* userdata); void* userdata);
RenderPipeline(DeviceBase* device, const RenderPipelineDescriptor* descriptor);
~RenderPipeline() override;
MTLPrimitiveType GetMTLPrimitiveTopology() const; MTLPrimitiveType GetMTLPrimitiveTopology() const;
MTLWinding GetMTLFrontFace() const; MTLWinding GetMTLFrontFace() const;
MTLCullMode GetMTLCullMode() const; MTLCullMode GetMTLCullMode() const;

View File

@ -310,6 +310,11 @@ Ref<RenderPipelineBase> RenderPipeline::CreateUninitialized(
return AcquireRef(new RenderPipeline(device, descriptor)); return AcquireRef(new RenderPipeline(device, descriptor));
} }
RenderPipeline::RenderPipeline(DeviceBase* dev, const RenderPipelineDescriptor* desc)
: RenderPipelineBase(dev, desc) {}
RenderPipeline::~RenderPipeline() = default;
MaybeError RenderPipeline::Initialize() { MaybeError RenderPipeline::Initialize() {
mMtlPrimitiveTopology = MTLPrimitiveTopology(GetPrimitiveTopology()); mMtlPrimitiveTopology = MTLPrimitiveTopology(GetPrimitiveTopology());
mMtlFrontFace = MTLFrontFace(GetFrontFace()); mMtlFrontFace = MTLFrontFace(GetFrontFace());

View File

@ -29,6 +29,9 @@ class Sampler final : public SamplerBase {
public: public:
static ResultOrError<Ref<Sampler>> Create(Device* device, const SamplerDescriptor* descriptor); static ResultOrError<Ref<Sampler>> Create(Device* device, const SamplerDescriptor* descriptor);
Sampler(DeviceBase* device, const SamplerDescriptor* descriptor);
~Sampler() override;
id<MTLSamplerState> GetMTLSamplerState(); id<MTLSamplerState> GetMTLSamplerState();
private: private:

View File

@ -64,6 +64,10 @@ ResultOrError<Ref<Sampler>> Sampler::Create(Device* device, const SamplerDescrip
return sampler; return sampler;
} }
Sampler::Sampler(DeviceBase* dev, const SamplerDescriptor* desc) : SamplerBase(dev, desc) {}
Sampler::~Sampler() = default;
MaybeError Sampler::Initialize(const SamplerDescriptor* descriptor) { MaybeError Sampler::Initialize(const SamplerDescriptor* descriptor) {
NSRef<MTLSamplerDescriptor> mtlDescRef = AcquireNSRef([MTLSamplerDescriptor new]); NSRef<MTLSamplerDescriptor> mtlDescRef = AcquireNSRef([MTLSamplerDescriptor new]);
MTLSamplerDescriptor* mtlDesc = mtlDescRef.Get(); MTLSamplerDescriptor* mtlDesc = mtlDescRef.Get();

View File

@ -65,7 +65,7 @@ class ShaderModule final : public ShaderModuleBase {
bool* hasInvariantAttribute, bool* hasInvariantAttribute,
std::vector<uint32_t>* workgroupAllocations); std::vector<uint32_t>* workgroupAllocations);
ShaderModule(Device* device, const ShaderModuleDescriptor* descriptor); ShaderModule(Device* device, const ShaderModuleDescriptor* descriptor);
~ShaderModule() override = default; ~ShaderModule() override;
MaybeError Initialize(ShaderModuleParseResult* parseResult, MaybeError Initialize(ShaderModuleParseResult* parseResult,
OwnedCompilationMessages* compilationMessages); OwnedCompilationMessages* compilationMessages);
}; };

View File

@ -42,6 +42,8 @@ ResultOrError<Ref<ShaderModule>> ShaderModule::Create(
ShaderModule::ShaderModule(Device* device, const ShaderModuleDescriptor* descriptor) ShaderModule::ShaderModule(Device* device, const ShaderModuleDescriptor* descriptor)
: ShaderModuleBase(device, descriptor) {} : ShaderModuleBase(device, descriptor) {}
ShaderModule::~ShaderModule() = default;
MaybeError ShaderModule::Initialize(ShaderModuleParseResult* parseResult, MaybeError ShaderModule::Initialize(ShaderModuleParseResult* parseResult,
OwnedCompilationMessages* compilationMessages) { OwnedCompilationMessages* compilationMessages) {
ScopedTintICEHandler scopedICEHandler(GetDevice()); ScopedTintICEHandler scopedICEHandler(GetDevice());

View File

@ -28,6 +28,7 @@ class Device;
class StagingBuffer : public StagingBufferBase { class StagingBuffer : public StagingBufferBase {
public: public:
StagingBuffer(size_t size, Device* device); StagingBuffer(size_t size, Device* device);
~StagingBuffer() override;
id<MTLBuffer> GetBufferHandle() const; id<MTLBuffer> GetBufferHandle() const;

View File

@ -20,6 +20,8 @@ namespace dawn::native::metal {
StagingBuffer::StagingBuffer(size_t size, Device* device) StagingBuffer::StagingBuffer(size_t size, Device* device)
: StagingBufferBase(size), mDevice(device) {} : StagingBufferBase(size), mDevice(device) {}
StagingBuffer::~StagingBuffer() = default;
MaybeError StagingBuffer::Initialize() { MaybeError StagingBuffer::Initialize() {
const size_t bufferSize = GetSize(); const size_t bufferSize = GetSize();
mBuffer = mBuffer =

View File

@ -44,6 +44,8 @@ class SwapChain final : public NewSwapChainBase {
Surface* surface, Surface* surface,
NewSwapChainBase* previousSwapChain, NewSwapChainBase* previousSwapChain,
const SwapChainDescriptor* descriptor); const SwapChainDescriptor* descriptor);
SwapChain(DeviceBase* device, Surface* surface, const SwapChainDescriptor* descriptor);
~SwapChain() override; ~SwapChain() override;
private: private:

View File

@ -72,6 +72,9 @@ ResultOrError<Ref<SwapChain>> SwapChain::Create(Device* device,
return swapchain; return swapchain;
} }
SwapChain::SwapChain(DeviceBase* dev, Surface* sur, const SwapChainDescriptor* desc)
: NewSwapChainBase(dev, sur, desc) {}
SwapChain::~SwapChain() = default; SwapChain::~SwapChain() = default;
void SwapChain::DestroyImpl() { void SwapChain::DestroyImpl() {

View File

@ -45,6 +45,8 @@ class Texture final : public TextureBase {
const TextureDescriptor* descriptor, const TextureDescriptor* descriptor,
NSPRef<id<MTLTexture>> wrapped); NSPRef<id<MTLTexture>> wrapped);
Texture(DeviceBase* device, const TextureDescriptor* descriptor, TextureState state);
id<MTLTexture> GetMTLTexture() const; id<MTLTexture> GetMTLTexture() const;
IOSurfaceRef GetIOSurface(); IOSurfaceRef GetIOSurface();
NSPRef<id<MTLTexture>> CreateFormatView(wgpu::TextureFormat format); NSPRef<id<MTLTexture>> CreateFormatView(wgpu::TextureFormat format);

View File

@ -772,6 +772,9 @@ MaybeError Texture::InitializeFromIOSurface(const ExternalImageDescriptor* descr
return {}; return {};
} }
Texture::Texture(DeviceBase* dev, const TextureDescriptor* desc, TextureState st)
: TextureBase(dev, desc, st) {}
Texture::~Texture() {} Texture::~Texture() {}
void Texture::DestroyImpl() { void Texture::DestroyImpl() {

View File

@ -32,6 +32,8 @@ Adapter::Adapter(InstanceBase* instance,
mPhysicalDevice(physicalDevice), mPhysicalDevice(physicalDevice),
mVulkanInstance(vulkanInstance) {} mVulkanInstance(vulkanInstance) {}
Adapter::~Adapter() = default;
const VulkanDeviceInfo& Adapter::GetDeviceInfo() const { const VulkanDeviceInfo& Adapter::GetDeviceInfo() const {
return mDeviceInfo; return mDeviceInfo;
} }

View File

@ -30,7 +30,7 @@ class Adapter : public AdapterBase {
Adapter(InstanceBase* instance, Adapter(InstanceBase* instance,
VulkanInstance* vulkanInstance, VulkanInstance* vulkanInstance,
VkPhysicalDevice physicalDevice); VkPhysicalDevice physicalDevice);
~Adapter() override = default; ~Adapter() override;
// AdapterBase Implementation // AdapterBase Implementation
bool SupportsExternalImages() const override; bool SupportsExternalImages() const override;

View File

@ -22,6 +22,8 @@
namespace dawn::wire { namespace dawn::wire {
ChunkedCommandHandler::ChunkedCommandHandler() = default;
ChunkedCommandHandler::~ChunkedCommandHandler() = default; ChunkedCommandHandler::~ChunkedCommandHandler() = default;
const volatile char* ChunkedCommandHandler::HandleCommands(const volatile char* commands, const volatile char* ChunkedCommandHandler::HandleCommands(const volatile char* commands,

View File

@ -27,9 +27,11 @@ namespace dawn::wire {
class ChunkedCommandHandler : public CommandHandler { class ChunkedCommandHandler : public CommandHandler {
public: public:
const volatile char* HandleCommands(const volatile char* commands, size_t size) override; ChunkedCommandHandler();
~ChunkedCommandHandler() override; ~ChunkedCommandHandler() override;
const volatile char* HandleCommands(const volatile char* commands, size_t size) override;
protected: protected:
enum class ChunkedCommandsResult { enum class ChunkedCommandsResult {
Passthrough, Passthrough,

View File

@ -17,6 +17,9 @@
namespace dawn::wire::server { namespace dawn::wire::server {
CallbackUserdata::CallbackUserdata(Server* server, const std::shared_ptr<bool>& serverIsAlive)
: server(server), serverIsAlive(serverIsAlive) {}
Server::Server(const DawnProcTable& procs, Server::Server(const DawnProcTable& procs,
CommandSerializer* serializer, CommandSerializer* serializer,
MemoryTransferService* memoryTransferService) MemoryTransferService* memoryTransferService)

View File

@ -55,8 +55,7 @@ struct CallbackUserdata {
std::weak_ptr<bool> const serverIsAlive; std::weak_ptr<bool> const serverIsAlive;
CallbackUserdata() = delete; CallbackUserdata() = delete;
CallbackUserdata(Server* server, const std::shared_ptr<bool>& serverIsAlive) CallbackUserdata(Server* server, const std::shared_ptr<bool>& serverIsAlive);
: server(server), serverIsAlive(serverIsAlive) {}
}; };
template <auto F> template <auto F>