mirror of https://github.com/AxioDL/boo.git
Metal pool buffers
This commit is contained in:
parent
c057068e64
commit
1177d50eda
|
@ -31,6 +31,7 @@ class MetalDataFactory : public IGraphicsDataFactory
|
||||||
void destroyPool(IGraphicsBufferPool*);
|
void destroyPool(IGraphicsBufferPool*);
|
||||||
IGraphicsBufferD* newPoolBuffer(IGraphicsBufferPool* pool, BufferUse use,
|
IGraphicsBufferD* newPoolBuffer(IGraphicsBufferPool* pool, BufferUse use,
|
||||||
size_t stride, size_t count);
|
size_t stride, size_t count);
|
||||||
|
void deletePoolBuffer(IGraphicsBufferPool* p, IGraphicsBufferD* buf);
|
||||||
public:
|
public:
|
||||||
MetalDataFactory(IGraphicsContext* parent, MetalContext* ctx, uint32_t sampleCount);
|
MetalDataFactory(IGraphicsContext* parent, MetalContext* ctx, uint32_t sampleCount);
|
||||||
~MetalDataFactory() {}
|
~MetalDataFactory() {}
|
||||||
|
|
|
@ -739,7 +739,7 @@ IGraphicsBufferD* GLDataFactory::newPoolBuffer(IGraphicsBufferPool* p, BufferUse
|
||||||
{
|
{
|
||||||
GLPool* pool = static_cast<GLPool*>(p);
|
GLPool* pool = static_cast<GLPool*>(p);
|
||||||
GLGraphicsBufferD* retval = new GLGraphicsBufferD(use, stride * count);
|
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;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ struct MetalData : IGraphicsData
|
||||||
|
|
||||||
struct MetalPool : IGraphicsBufferPool
|
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
|
#define MTL_STATIC MTLResourceCPUCacheModeWriteCombined|MTLResourceStorageModeShared
|
||||||
|
@ -888,8 +888,8 @@ struct MetalCommandQueue : IGraphicsCommandQueue
|
||||||
}
|
}
|
||||||
for (MetalPool* p : gfxF->m_committedPools)
|
for (MetalPool* p : gfxF->m_committedPools)
|
||||||
{
|
{
|
||||||
for (std::unique_ptr<MetalGraphicsBufferD>& b : p->m_DBufs)
|
for (auto& b : p->m_DBufs)
|
||||||
b->update(m_fillBuf);
|
b.second->update(m_fillBuf);
|
||||||
}
|
}
|
||||||
datalk.unlock();
|
datalk.unlock();
|
||||||
|
|
||||||
|
@ -1184,10 +1184,16 @@ IGraphicsBufferD* MetalDataFactory::newPoolBuffer(IGraphicsBufferPool* p, Buffer
|
||||||
MetalPool* pool = static_cast<MetalPool*>(p);
|
MetalPool* pool = static_cast<MetalPool*>(p);
|
||||||
MetalCommandQueue* q = static_cast<MetalCommandQueue*>(m_parent->getCommandQueue());
|
MetalCommandQueue* q = static_cast<MetalCommandQueue*>(m_parent->getCommandQueue());
|
||||||
MetalGraphicsBufferD* retval = new MetalGraphicsBufferD(q, use, m_ctx, stride, count);
|
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;
|
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,
|
IGraphicsCommandQueue* _NewMetalCommandQueue(MetalContext* ctx, IWindow* parentWindow,
|
||||||
IGraphicsContext* parent)
|
IGraphicsContext* parent)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue