diff options
| author | Jules Blok <jules.blok@gmail.com> | 2017-02-21 16:15:22 +0100 |
|---|---|---|
| committer | Jules Blok <jules.blok@gmail.com> | 2017-02-24 14:54:20 +0100 |
| commit | bde81269130c31c93cbb0f0f3ac8f23560751cac (patch) | |
| tree | 2bab689d3eb5a205d47815e9c8dd07ec0c3b6aa4 /Source/Core/VideoBackends/OGL/Render.cpp | |
| parent | 94522d4cf3f18ba0783a877a8254537f0ff383ac (diff) | |
VideoBackends: Remove depth range clamping hacks.
Oversized depth ranges are handled correctly now, we don't need to hack around them with clamps anymore.
Diffstat (limited to 'Source/Core/VideoBackends/OGL/Render.cpp')
| -rw-r--r-- | Source/Core/VideoBackends/OGL/Render.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp index abee545ba4..f8405250d7 100644 --- a/Source/Core/VideoBackends/OGL/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Render.cpp @@ -1111,6 +1111,8 @@ void Renderer::SetViewport() (float)scissorYOff); float Width = EFBToScaledXf(2.0f * xfmem.viewport.wd); float Height = EFBToScaledYf(-2.0f * xfmem.viewport.ht); + float min_depth = (xfmem.viewport.farZ - xfmem.viewport.zRange) / 16777216.0f; + float max_depth = xfmem.viewport.farZ / 16777216.0f; if (Width < 0) { X += Width; @@ -1136,17 +1138,10 @@ void Renderer::SetViewport() // Set the reversed depth range. if (g_ActiveConfig.backend_info.bSupportsOversizedDepthRanges) { - float min_depth = (xfmem.viewport.farZ - xfmem.viewport.zRange) / 16777216.0f; - float max_depth = xfmem.viewport.farZ / 16777216.0f; glDepthRangedNV(max_depth, min_depth); } else { - float range = MathUtil::Clamp<float>(xfmem.viewport.zRange, -16777216.0f, 16777216.0f); - float min_depth = - MathUtil::Clamp<float>(xfmem.viewport.farZ - range, 0.0f, 16777215.0f) / 16777216.0f; - float max_depth = MathUtil::Clamp<float>(xfmem.viewport.farZ, 0.0f, 16777215.0f) / 16777216.0f; - // If an oversized depth range is used, we need to calculate the depth range in the // vertex shader. if (g_ActiveConfig.backend_info.bSupportsDepthClamp && @@ -1165,6 +1160,13 @@ void Renderer::SetViewport() max_depth = GX_MAX_DEPTH; } } + else + { + // There's no way to support oversized depth ranges in this situation. Let's just clamp the + // range to the maximum value supported by the console GPU and hope for the best. + min_depth = MathUtil::Clamp(min_depth, 0.0f, GX_MAX_DEPTH); + max_depth = MathUtil::Clamp(max_depth, 0.0f, GX_MAX_DEPTH); + } glDepthRangef(max_depth, min_depth); } |
