From dc328052562ca86a62d87461149f6010826a2eb0 Mon Sep 17 00:00:00 2001 From: Victor Xie Date: Mon, 1 Feb 2016 13:17:15 +0800 Subject: [PATCH] Made commit 0920f6c a little more robust. Eliminated division-by-zero when depth range is zero. --- GPU/Common/GPUStateUtils.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/GPU/Common/GPUStateUtils.cpp b/GPU/Common/GPUStateUtils.cpp index 8a6065c6f3..52fe3be2cb 100644 --- a/GPU/Common/GPUStateUtils.cpp +++ b/GPU/Common/GPUStateUtils.cpp @@ -16,6 +16,7 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include +#include #include "Common/StringUtils.h" #include "Core/Config.h" @@ -679,9 +680,9 @@ void ConvertViewportAndScissor(bool useBufferedRendering, float renderWidth, flo // Okay. So, in our shader, -1 will map to minz, and +1 will map to maxz. float halfActualZRange = (maxz - minz) * (1.0f / 2.0f); - float zScale = vpZScale / halfActualZRange; + float zScale = halfActualZRange < std::numeric_limits::epsilon() ? 1.0f : vpZScale / halfActualZRange; // This adjusts the center from halfActualZRange to vpZCenter. - float zOffset = (vpZCenter - (minz + halfActualZRange)) / halfActualZRange; + float zOffset = halfActualZRange < std::numeric_limits::epsilon() ? 0.0f : (vpZCenter - (minz + halfActualZRange)) / halfActualZRange; out.depthRangeMin = ToScaledDepthFromInteger(minz); out.depthRangeMax = ToScaledDepthFromInteger(maxz);