Ensure boo IObj instances are heap-allocated

This commit is contained in:
Jack Andersen 2017-11-19 13:44:46 -10:00
parent 403249582a
commit 49d76b84be
2 changed files with 28 additions and 27 deletions

View File

@ -10,8 +10,9 @@ namespace boo
class IObj class IObj
{ {
std::atomic_int m_refCount = {0}; std::atomic_int m_refCount = {0};
public: protected:
virtual ~IObj() = default; virtual ~IObj() = default;
public:
virtual std::unique_lock<std::recursive_mutex> destructorLock() { return {}; } virtual std::unique_lock<std::recursive_mutex> destructorLock() { return {}; }
void increment() { m_refCount++; } void increment() { m_refCount++; }
void decrement() void decrement()

View File

@ -1231,34 +1231,34 @@ struct MetalCommandQueue : IGraphicsCommandQueue
if (!m_running) if (!m_running)
return; return;
/* Update dynamic data here */
MetalDataFactoryImpl* gfxF = static_cast<MetalDataFactoryImpl*>(m_parent->getDataFactory());
std::unique_lock<std::recursive_mutex> datalk(gfxF->m_dataMutex);
if (gfxF->m_dataHead)
{
for (BaseGraphicsData& d : *gfxF->m_dataHead)
{
if (d.m_DBufs)
for (IGraphicsBufferD& b : *d.m_DBufs)
static_cast<MetalGraphicsBufferD<BaseGraphicsData>&>(b).update(m_fillBuf);
if (d.m_DTexs)
for (ITextureD& t : *d.m_DTexs)
static_cast<MetalTextureD&>(t).update(m_fillBuf);
}
}
if (gfxF->m_poolHead)
{
for (BaseGraphicsPool& p : *gfxF->m_poolHead)
{
if (p.m_DBufs)
for (IGraphicsBufferD& b : *p.m_DBufs)
static_cast<MetalGraphicsBufferD<BaseGraphicsData>&>(b).update(m_fillBuf);
}
}
datalk.unlock();
@autoreleasepool @autoreleasepool
{ {
/* Update dynamic data here */
MetalDataFactoryImpl* gfxF = static_cast<MetalDataFactoryImpl*>(m_parent->getDataFactory());
std::unique_lock<std::recursive_mutex> datalk(gfxF->m_dataMutex);
if (gfxF->m_dataHead)
{
for (BaseGraphicsData& d : *gfxF->m_dataHead)
{
if (d.m_DBufs)
for (IGraphicsBufferD& b : *d.m_DBufs)
static_cast<MetalGraphicsBufferD<BaseGraphicsData>&>(b).update(m_fillBuf);
if (d.m_DTexs)
for (ITextureD& t : *d.m_DTexs)
static_cast<MetalTextureD&>(t).update(m_fillBuf);
}
}
if (gfxF->m_poolHead)
{
for (BaseGraphicsPool& p : *gfxF->m_poolHead)
{
if (p.m_DBufs)
for (IGraphicsBufferD& b : *p.m_DBufs)
static_cast<MetalGraphicsBufferD<BaseGraphicsData>&>(b).update(m_fillBuf);
}
}
datalk.unlock();
[m_enc endEncoding]; [m_enc endEncoding];
m_enc = nullptr; m_enc = nullptr;