mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-12-16 22:37:01 +00:00
rework buffer allocators
This commit is contained in:
parent
24ff85b11f
commit
97b806f16f
7 changed files with 391 additions and 442 deletions
|
|
@ -73,20 +73,14 @@ void MetalMemoryManager::UploadToBufferCache(const void* data, size_t offset, si
|
|||
|
||||
if (m_bufferCacheMode == BufferCacheMode::DevicePrivate)
|
||||
{
|
||||
auto allocation = m_tempBufferAllocator.GetAllocation(size);
|
||||
auto buffer = m_tempBufferAllocator.GetBufferOutsideOfCommandBuffer(allocation.bufferIndex);
|
||||
memcpy((uint8*)buffer->contents() + allocation.offset, data, size);
|
||||
auto blitCommandEncoder = m_mtlr->GetBlitCommandEncoder();
|
||||
|
||||
// Lock the buffer to make sure it's not deallocated before the copy is done
|
||||
m_tempBufferAllocator.LockBuffer(allocation.bufferIndex);
|
||||
auto allocation = m_stagingAllocator.AllocateBufferMemory(size, 1);
|
||||
memcpy(allocation.memPtr, data, size);
|
||||
|
||||
m_mtlr->CopyBufferToBuffer(buffer, allocation.offset, m_bufferCache, offset, size, ALL_MTL_RENDER_STAGES, ALL_MTL_RENDER_STAGES);
|
||||
blitCommandEncoder->copyFromBuffer(allocation.mtlBuffer, allocation.bufferOffset, m_bufferCache, offset, size);
|
||||
|
||||
// Mark buffer as used
|
||||
m_tempBufferAllocator.MarkBufferAsUsed(allocation.bufferIndex);
|
||||
|
||||
// We can now safely unlock the buffer
|
||||
m_tempBufferAllocator.UnlockBuffer(allocation.bufferIndex);
|
||||
//m_mtlr->CopyBufferToBuffer(allocation.mtlBuffer, allocation.bufferOffset, m_bufferCache, offset, size, ALL_MTL_RENDER_STAGES, ALL_MTL_RENDER_STAGES);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue