delete this copy c'tors to prevent lifetime issues

This commit is contained in:
TurtleP 2022-12-29 12:29:11 -05:00
parent b55cb17676
commit 1ba7ee701c
5 changed files with 20 additions and 1 deletions

View File

@ -15,6 +15,9 @@ class CCmdMemRing
dk::Fence m_fences[NumSlices];
public:
CCmdMemRing() : m_mem{}, m_curSlice{}, m_fences{} { }
CCmdMemRing(const CCmdMemRing&) = delete;
~CCmdMemRing()
{
m_mem.destroy();

View File

@ -18,7 +18,10 @@ class CDescriptorSet
CMemPool::Handle m_mem;
public:
CDescriptorSet() : m_mem{} { }
~CDescriptorSet()
CDescriptorSet(const CDescriptorSet&) = delete;
~CDescriptorSet()
{
m_mem.destroy();
}

View File

@ -13,6 +13,9 @@ class CExternalImage
CMemPool::Handle m_mem;
public:
CExternalImage() : m_image{}, m_descriptor{}, m_mem{} { }
CExternalImage(const CExternalImage&) = delete;
~CExternalImage()
{
m_mem.destroy();

View File

@ -42,6 +42,8 @@ class CMemPool
uint32_t m_start;
uint32_t m_end;
Slice(const Slice&) = delete;
constexpr uint32_t getSize() const { return m_end - m_start; }
constexpr bool canCoalesce(Slice const& rhs) const { return m_pool == rhs.m_pool && m_block == rhs.m_block && m_end == rhs.m_start; }
@ -72,6 +74,8 @@ public:
constexpr bool operator==(Handle const& rhs) const { return m_slice == rhs.m_slice; }
constexpr bool operator!=(Handle const& rhs) const { return m_slice != rhs.m_slice; }
Handle(const Handle&) = delete;
void destroy()
{
if (m_slice)
@ -109,9 +113,12 @@ public:
CMemPool(dk::Device dev, uint32_t flags = DkMemBlockFlags_CpuUncached | DkMemBlockFlags_GpuCached, uint32_t blockSize = DefaultBlockSize) :
m_dev{dev}, m_flags{flags}, m_blockSize{blockSize}, m_blocks{}, m_memMap{}, m_sliceHeap{}, m_freeList{} { }
~CMemPool();
Handle allocate(uint32_t size, uint32_t alignment = DK_CMDMEM_ALIGNMENT);
CMemPool(const CMemPool&) = delete;
};
constexpr bool operator<(uint32_t lhs, CMemPool::Slice const& rhs)

View File

@ -12,6 +12,9 @@ class CShader
CMemPool::Handle m_codemem;
public:
CShader() : m_shader{}, m_codemem{} { }
CShader(const CShader&) = delete;
~CShader()
{
m_codemem.destroy();