mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 02:39:11 +00:00
Make RefCounted derived objects have private destructors
RefCounted (and derived) destructors should be protected on the class to ensure the objects can ONLY be destructed by calling Release. This avoids errors cause by destroying objects out from under code which has an active reference count. Unfortunately, many of the 'base' classes must continue having public destructors because they are used as "blueprint" objects created on the stack. Added final on most-derived classes. Ideas for future improvement: - Change "base" objects to have protected destructors but create new blueprint objects that privately derive from base objects. This limits the blueprint object's usefulness to only be a blueprint. - Modify createX methods to return Ref<Object> instead of Object* Change-Id: I6f3b3b178118d135c4342cb912e982a3873d71af Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/18780 Commit-Queue: Rafael Cintron <rafael.cintron@microsoft.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
022d074c06
commit
c64242d4c2
@@ -169,16 +169,17 @@ namespace dawn_native { namespace null {
|
||||
|
||||
// We don't have the complexity of placement-allocation of bind group data in
|
||||
// the Null backend. This class, keeps the binding data in a separate allocation for simplicity.
|
||||
class BindGroup : private BindGroupDataHolder, public BindGroupBase {
|
||||
class BindGroup final : private BindGroupDataHolder, public BindGroupBase {
|
||||
public:
|
||||
BindGroup(DeviceBase* device, const BindGroupDescriptor* descriptor);
|
||||
|
||||
private:
|
||||
~BindGroup() override = default;
|
||||
};
|
||||
|
||||
class Buffer : public BufferBase {
|
||||
class Buffer final : public BufferBase {
|
||||
public:
|
||||
Buffer(Device* device, const BufferDescriptor* descriptor);
|
||||
~Buffer();
|
||||
|
||||
void MapOperationCompleted(uint32_t serial, void* ptr, bool isWrite);
|
||||
void CopyFromStaging(StagingBufferBase* staging,
|
||||
@@ -187,6 +188,8 @@ namespace dawn_native { namespace null {
|
||||
uint64_t size);
|
||||
|
||||
private:
|
||||
~Buffer() override;
|
||||
|
||||
// Dawn API
|
||||
MaybeError SetSubDataImpl(uint32_t start, uint32_t count, const void* data) override;
|
||||
MaybeError MapReadAsyncImpl(uint32_t serial) override;
|
||||
@@ -201,33 +204,35 @@ namespace dawn_native { namespace null {
|
||||
std::unique_ptr<uint8_t[]> mBackingData;
|
||||
};
|
||||
|
||||
class CommandBuffer : public CommandBufferBase {
|
||||
class CommandBuffer final : public CommandBufferBase {
|
||||
public:
|
||||
CommandBuffer(CommandEncoder* encoder, const CommandBufferDescriptor* descriptor);
|
||||
~CommandBuffer();
|
||||
|
||||
private:
|
||||
~CommandBuffer() override;
|
||||
|
||||
CommandIterator mCommands;
|
||||
};
|
||||
|
||||
class Queue : public QueueBase {
|
||||
class Queue final : public QueueBase {
|
||||
public:
|
||||
Queue(Device* device);
|
||||
~Queue();
|
||||
|
||||
private:
|
||||
~Queue() override;
|
||||
MaybeError SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) override;
|
||||
};
|
||||
|
||||
class SwapChain : public NewSwapChainBase {
|
||||
class SwapChain final : public NewSwapChainBase {
|
||||
public:
|
||||
SwapChain(Device* device,
|
||||
Surface* surface,
|
||||
NewSwapChainBase* previousSwapChain,
|
||||
const SwapChainDescriptor* descriptor);
|
||||
~SwapChain() override;
|
||||
|
||||
private:
|
||||
~SwapChain() override;
|
||||
|
||||
Ref<Texture> mTexture;
|
||||
|
||||
MaybeError PresentImpl() override;
|
||||
@@ -235,12 +240,12 @@ namespace dawn_native { namespace null {
|
||||
void DetachFromSurfaceImpl() override;
|
||||
};
|
||||
|
||||
class OldSwapChain : public OldSwapChainBase {
|
||||
class OldSwapChain final : public OldSwapChainBase {
|
||||
public:
|
||||
OldSwapChain(Device* device, const SwapChainDescriptor* descriptor);
|
||||
~OldSwapChain();
|
||||
|
||||
protected:
|
||||
~OldSwapChain() override;
|
||||
TextureBase* GetNextTextureImpl(const TextureDescriptor* descriptor) override;
|
||||
MaybeError OnBeforePresent(TextureBase*) override;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user