From d659b4f55e3d517931ccc2d79bbff740ce399808 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Sun, 29 Jan 2023 22:16:46 +0000 Subject: [PATCH] Swap min and max depth when negative scale is used Fixes Super Mario 3D All Stars rendering. --- .../cpp/skyline/gpu/interconnect/maxwell_3d/active_state.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/active_state.cpp b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/active_state.cpp index ee41cc97..e1cbc2ce 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/active_state.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/active_state.cpp @@ -249,9 +249,14 @@ namespace skyline::gpu::interconnect::maxwell3d { vkViewport.height = -vkViewport.height; } + // Clamp since we don't yet use VK_EXT_unrestricted_depth_range vkViewport.minDepth = std::clamp(viewportClip.minZ, 0.0f, 1.0f); vkViewport.maxDepth = std::clamp(viewportClip.maxZ, 0.0f, 1.0f); + + if (viewport.scaleZ < 0.0f) + std::swap(vkViewport.minDepth, vkViewport.maxDepth); + return vkViewport; }