From db709c34956a406ed9e31e8fe7dc246419a6e4f4 Mon Sep 17 00:00:00 2001 From: Samuliak Date: Sat, 3 Aug 2024 08:24:39 +0200 Subject: [PATCH] fix: present issue --- src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp | 9 +++++++++ src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.h | 1 + 2 files changed, 10 insertions(+) diff --git a/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp index de8282fe..ecb75c71 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp @@ -137,6 +137,7 @@ void MetalRenderer::SwapBuffers(bool swapTV, bool swapDRC) debug_printf("skipped present!\n"); } m_drawable = nullptr; + m_drawableAcquired = false; CommitCommandBuffer(); } @@ -145,6 +146,14 @@ void MetalRenderer::DrawBackbufferQuad(LatteTextureView* texView, RendererOutput sint32 imageX, sint32 imageY, sint32 imageWidth, sint32 imageHeight, bool padView, bool clearBackground) { + if (m_drawableAcquired) + { + debug_printf("drawable already acquired this frame\n"); + return; + } + + m_drawableAcquired = true; + // Acquire drawable m_drawable = m_metalLayer->nextDrawable(); if (!m_drawable) diff --git a/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.h b/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.h index 8ac87118..a79a515f 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.h @@ -216,6 +216,7 @@ private: MetalEncoderType m_encoderType = MetalEncoderType::None; MTL::CommandEncoder* m_commandEncoder = nullptr; CA::MetalDrawable* m_drawable = nullptr; + bool m_drawableAcquired = false; // State MetalState m_state;