From 07c62d5f9526349c44e038fb43e76e78851f0d48 Mon Sep 17 00:00:00 2001 From: Samuliak Date: Tue, 5 Nov 2024 17:06:08 +0100 Subject: [PATCH] release texture upload buffer --- src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.cpp | 8 +++++++- src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.h | 4 +++- src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp | 7 ++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.cpp b/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.cpp index 8e0c141f..01cee8b9 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.cpp +++ b/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.cpp @@ -14,7 +14,7 @@ MetalMemoryManager::~MetalMemoryManager() } } -void* MetalMemoryManager::GetTextureUploadBuffer(size_t size) +void* MetalMemoryManager::AcquireTextureUploadBuffer(size_t size) { if (m_textureUploadBuffer.size() < size) { @@ -24,6 +24,12 @@ void* MetalMemoryManager::GetTextureUploadBuffer(size_t size) return m_textureUploadBuffer.data(); } +void MetalMemoryManager::ReleaseTextureUploadBuffer(uint8* mem) +{ + cemu_assert_debug(m_textureUploadBuffer.data() == mem); + m_textureUploadBuffer.clear(); +} + void MetalMemoryManager::InitBufferCache(size_t size) { cemu_assert_debug(!m_bufferCache); diff --git a/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.h b/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.h index f74d30d0..3d70e0db 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.h +++ b/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.h @@ -30,7 +30,9 @@ public: return m_bufferCache; } - void* GetTextureUploadBuffer(size_t size); + // Texture upload buffer + void* AcquireTextureUploadBuffer(size_t size); + void ReleaseTextureUploadBuffer(uint8* mem); // Buffer cache void InitBufferCache(size_t size); diff --git a/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp index 20f8f678..6ee3d9b6 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp @@ -456,9 +456,10 @@ void MetalRenderer::AppendOverlayDebugInfo() ImGui::Text("Triangle fans %u", m_performanceMonitor.m_triangleFans); } -// TODO: halfZ void MetalRenderer::renderTarget_setViewport(float x, float y, float width, float height, float nearZ, float farZ, bool halfZ) { + // halfZ is handled in the shader + m_state.m_viewport = MTL::Viewport{x, y, width, height, nearZ, farZ}; } @@ -485,12 +486,12 @@ void MetalRenderer::rendertarget_bindFramebufferObject(LatteCachedFBO* cfbo) void* MetalRenderer::texture_acquireTextureUploadBuffer(uint32 size) { - return m_memoryManager->GetTextureUploadBuffer(size); + return m_memoryManager->AcquireTextureUploadBuffer(size); } void MetalRenderer::texture_releaseTextureUploadBuffer(uint8* mem) { - // TODO: should the texture buffer get released? + m_memoryManager->ReleaseTextureUploadBuffer(mem); } TextureDecoder* MetalRenderer::texture_chooseDecodedFormat(Latte::E_GX2SURFFMT format, bool isDepth, Latte::E_DIM dim, uint32 width, uint32 height)