diff --git a/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.cpp b/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.cpp index 4de12549..4f27ccf5 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.cpp +++ b/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.cpp @@ -33,9 +33,8 @@ void MetalMemoryManager::InitBufferCache(size_t size) if (m_bufferCacheType == BufferCacheType::Host && m_mtlr->IsAppleGPU()) { m_importedMemBaseAddress = 0x10000000; - size_t hostAllocationSize = 0x40000000ull; - // TODO: get size of allocation - m_bufferCache = m_mtlr->GetDevice()->newBuffer(memory_getPointerFromVirtualOffset(m_importedMemBaseAddress), hostAllocationSize, MTL::ResourceStorageModeShared, nullptr); + m_hostAllocationSize = 0x40000000ull; // TODO: get size of allocation + m_bufferCache = m_mtlr->GetDevice()->newBuffer(memory_getPointerFromVirtualOffset(m_importedMemBaseAddress), m_hostAllocationSize, MTL::ResourceStorageModeShared, nullptr); if (!m_bufferCache) { cemuLog_logDebug(LogType::Force, "Failed to import host memory as a buffer"); diff --git a/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.h b/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.h index ecae3d3e..8f3c4d4c 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.h +++ b/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.h @@ -48,6 +48,11 @@ public: return m_importedMemBaseAddress; } + size_t GetHostAllocationSize() const + { + return m_hostAllocationSize; + } + private: class MetalRenderer* m_mtlr; @@ -60,4 +65,5 @@ private: MTL::Buffer* m_bufferCache = nullptr; BufferCacheType m_bufferCacheType; MPTR m_importedMemBaseAddress; + size_t m_hostAllocationSize = 0; }; diff --git a/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp index 93d3c08d..b19ef07a 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp @@ -204,7 +204,8 @@ bool MetalRenderer::IsPadWindowActive() 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; return true;