Metal pool buffers

This commit is contained in:
Jack Andersen 2016-12-11 10:20:29 -10:00
parent c057068e64
commit 1177d50eda
3 changed files with 12 additions and 5 deletions

View File

@ -31,6 +31,7 @@ class MetalDataFactory : public IGraphicsDataFactory
void destroyPool(IGraphicsBufferPool*);
IGraphicsBufferD* newPoolBuffer(IGraphicsBufferPool* pool, BufferUse use,
size_t stride, size_t count);
void deletePoolBuffer(IGraphicsBufferPool* p, IGraphicsBufferD* buf);
public:
MetalDataFactory(IGraphicsContext* parent, MetalContext* ctx, uint32_t sampleCount);
~MetalDataFactory() {}

View File

@ -739,7 +739,7 @@ IGraphicsBufferD* GLDataFactory::newPoolBuffer(IGraphicsBufferPool* p, BufferUse
{
GLPool* pool = static_cast<GLPool*>(p);
GLGraphicsBufferD* retval = new GLGraphicsBufferD(use, stride * count);
pool->m_DBufs.emplace(std::make_pair(retval, retval));
pool->m_DBufs.emplace(std::make_pair(retval, std::unique_ptr<GLGraphicsBufferD>(retval)));
return retval;
}

View File

@ -33,7 +33,7 @@ struct MetalData : IGraphicsData
struct MetalPool : IGraphicsBufferPool
{
std::vector<std::unique_ptr<class MetalGraphicsBufferD>> m_DBufs;
std::unordered_map<class MetalGraphicsBufferD*, std::unique_ptr<class MetalGraphicsBufferD>> m_DBufs;
};
#define MTL_STATIC MTLResourceCPUCacheModeWriteCombined|MTLResourceStorageModeShared
@ -888,8 +888,8 @@ struct MetalCommandQueue : IGraphicsCommandQueue
}
for (MetalPool* p : gfxF->m_committedPools)
{
for (std::unique_ptr<MetalGraphicsBufferD>& b : p->m_DBufs)
b->update(m_fillBuf);
for (auto& b : p->m_DBufs)
b.second->update(m_fillBuf);
}
datalk.unlock();
@ -1184,10 +1184,16 @@ IGraphicsBufferD* MetalDataFactory::newPoolBuffer(IGraphicsBufferPool* p, Buffer
MetalPool* pool = static_cast<MetalPool*>(p);
MetalCommandQueue* q = static_cast<MetalCommandQueue*>(m_parent->getCommandQueue());
MetalGraphicsBufferD* retval = new MetalGraphicsBufferD(q, use, m_ctx, stride, count);
pool->m_DBufs.emplace_back(retval);
pool->m_DBufs.emplace(std::make_pair(retval, std::unique_ptr<MetalGraphicsBufferD>(retval)));
return retval;
}
void MetalDataFactory::deletePoolBuffer(IGraphicsBufferPool* p, IGraphicsBufferD* buf)
{
MetalPool* pool = static_cast<MetalPool*>(p);
pool->m_DBufs.erase(static_cast<MetalGraphicsBufferD*>(buf));
}
IGraphicsCommandQueue* _NewMetalCommandQueue(MetalContext* ctx, IWindow* parentWindow,
IGraphicsContext* parent)
{