From c6f66167a58f6e04093f758b644d427967403acc Mon Sep 17 00:00:00 2001 From: Samuliak Date: Sat, 3 Aug 2024 08:36:34 +0200 Subject: [PATCH] fix: viewport --- .../HW/Latte/Renderer/Metal/MetalRenderer.cpp | 19 +++++++++---------- .../Renderer/Metal/ShaderSourcePresent.h | 1 + 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp index ecb75c71..f91a36a4 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp @@ -146,19 +146,18 @@ void MetalRenderer::DrawBackbufferQuad(LatteTextureView* texView, RendererOutput sint32 imageX, sint32 imageY, sint32 imageWidth, sint32 imageHeight, bool padView, bool clearBackground) { - if (m_drawableAcquired) + if (!m_drawableAcquired) { debug_printf("drawable already acquired this frame\n"); - return; - } - m_drawableAcquired = true; + m_drawableAcquired = true; - // Acquire drawable - m_drawable = m_metalLayer->nextDrawable(); - if (!m_drawable) - { - return; + // Acquire drawable + m_drawable = m_metalLayer->nextDrawable(); + if (!m_drawable) + { + return; + } } MTL::Texture* presentTexture = static_cast(texView)->GetTexture(); @@ -204,7 +203,7 @@ void MetalRenderer::AppendOverlayDebugInfo() void MetalRenderer::renderTarget_setViewport(float x, float y, float width, float height, float nearZ, float farZ, bool halfZ) { - m_state.viewport = MTL::Viewport{x, y + height, width, -height, nearZ, farZ}; + m_state.viewport = MTL::Viewport{x, y, width, height, nearZ, farZ}; if (m_encoderType == MetalEncoderType::Render) { static_cast(m_commandEncoder)->setViewport(m_state.viewport); diff --git a/src/Cafe/HW/Latte/Renderer/Metal/ShaderSourcePresent.h b/src/Cafe/HW/Latte/Renderer/Metal/ShaderSourcePresent.h index ad3f6971..a77ce2cd 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/ShaderSourcePresent.h +++ b/src/Cafe/HW/Latte/Renderer/Metal/ShaderSourcePresent.h @@ -13,6 +13,7 @@ inline const char* presentLibrarySource = \ " VertexOut out;\n" \ " out.position = float4(positions[vid], 0.0, 1.0);\n" \ " out.texCoord = positions[vid] * 0.5 + 0.5;\n" \ +" out.texCoord.y = 1.0 - out.texCoord.y;\n" \ "\n" \ " return out;\n" \ "}\n" \