Skip to content

Commit

Permalink
Made commit 0920f6c a little more robust.
Browse files Browse the repository at this point in the history
Eliminated division-by-zero when depth range is zero.
  • Loading branch information
FTPiano committed Feb 1, 2016
1 parent 0151552 commit dc32805
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions GPU/Common/GPUStateUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.

#include <algorithm>
#include <limits>

#include "Common/StringUtils.h"
#include "Core/Config.h"
Expand Down Expand Up @@ -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<float>::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<float>::epsilon() ? 0.0f : (vpZCenter - (minz + halfActualZRange)) / halfActualZRange;

out.depthRangeMin = ToScaledDepthFromInteger(minz);
out.depthRangeMax = ToScaledDepthFromInteger(maxz);
Expand Down

0 comments on commit dc32805

Please sign in to comment.