correctly report memory usage for host buffer cache

This commit is contained in:
Samuliak 2024-11-03 16:58:32 +01:00
parent e00d244e0d
commit fbea328b9b
No known key found for this signature in database
3 changed files with 10 additions and 4 deletions

View File

@ -33,9 +33,8 @@ void MetalMemoryManager::InitBufferCache(size_t size)
if (m_bufferCacheType == BufferCacheType::Host && m_mtlr->IsAppleGPU()) if (m_bufferCacheType == BufferCacheType::Host && m_mtlr->IsAppleGPU())
{ {
m_importedMemBaseAddress = 0x10000000; m_importedMemBaseAddress = 0x10000000;
size_t hostAllocationSize = 0x40000000ull; m_hostAllocationSize = 0x40000000ull; // TODO: get size of allocation
// TODO: get size of allocation m_bufferCache = m_mtlr->GetDevice()->newBuffer(memory_getPointerFromVirtualOffset(m_importedMemBaseAddress), m_hostAllocationSize, MTL::ResourceStorageModeShared, nullptr);
m_bufferCache = m_mtlr->GetDevice()->newBuffer(memory_getPointerFromVirtualOffset(m_importedMemBaseAddress), hostAllocationSize, MTL::ResourceStorageModeShared, nullptr);
if (!m_bufferCache) if (!m_bufferCache)
{ {
cemuLog_logDebug(LogType::Force, "Failed to import host memory as a buffer"); cemuLog_logDebug(LogType::Force, "Failed to import host memory as a buffer");

View File

@ -48,6 +48,11 @@ public:
return m_importedMemBaseAddress; return m_importedMemBaseAddress;
} }
size_t GetHostAllocationSize() const
{
return m_hostAllocationSize;
}
private: private:
class MetalRenderer* m_mtlr; class MetalRenderer* m_mtlr;
@ -60,4 +65,5 @@ private:
MTL::Buffer* m_bufferCache = nullptr; MTL::Buffer* m_bufferCache = nullptr;
BufferCacheType m_bufferCacheType; BufferCacheType m_bufferCacheType;
MPTR m_importedMemBaseAddress; MPTR m_importedMemBaseAddress;
size_t m_hostAllocationSize = 0;
}; };

View File

@ -204,7 +204,8 @@ bool MetalRenderer::IsPadWindowActive()
bool MetalRenderer::GetVRAMInfo(int& usageInMB, int& totalInMB) const bool MetalRenderer::GetVRAMInfo(int& usageInMB, int& totalInMB) const
{ {
usageInMB = m_device->currentAllocatedSize() / 1024 / 1024; // Subtract host memory from total VRAM, since it's shared with the CPU
usageInMB = (m_device->currentAllocatedSize() - m_memoryManager->GetHostAllocationSize()) / 1024 / 1024;
totalInMB = m_recommendedMaxVRAMUsage / 1024 / 1024; totalInMB = m_recommendedMaxVRAMUsage / 1024 / 1024;
return true; return true;