diff options
| author | Jules Blok <jules.blok@gmail.com> | 2017-02-19 16:41:04 +0100 |
|---|---|---|
| committer | Jules Blok <jules.blok@gmail.com> | 2017-02-21 02:57:23 +0100 |
| commit | 28e6e259edc6828b467346d8e3f532c01791eabc (patch) | |
| tree | b9997b729d4a28656c22563cbe143f4aeda043bd /Source/Core/VideoBackends/OGL/Render.cpp | |
| parent | 51944afa56fca91c30c2b098ee75728d3784c0ae (diff) | |
VideoBackends: Set the maximum range when the depth range is oversized.
The depth values generated by the vertex shader need to be clamped correctly.
Diffstat (limited to 'Source/Core/VideoBackends/OGL/Render.cpp')
| -rw-r--r-- | Source/Core/VideoBackends/OGL/Render.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp index a92c4810f4..f55d06ecbc 100644 --- a/Source/Core/VideoBackends/OGL/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Render.cpp @@ -1123,6 +1123,24 @@ void Renderer::SetViewport() Height *= -1; } + // If an oversized depth range is used, we need to calculate the depth range in the vertex shader. + if (g_ActiveConfig.backend_info.bSupportsDepthClamp && + (fabs(xfmem.viewport.zRange) > 16777215.0f || fabs(xfmem.viewport.farZ) > 16777215.0f)) + { + // We need to ensure depth values are clamped the maximum value supported by the console GPU. + // Taking into account whether the depth range is inverted or not. + if (xfmem.viewport.zRange < 0.0f) + { + min_depth = GX_MAX_DEPTH; + max_depth = 0.0f; + } + else + { + min_depth = 0.0f; + max_depth = GX_MAX_DEPTH; + } + } + // Update the view port if (g_ogl_config.bSupportViewportFloat) { @@ -1134,10 +1152,7 @@ void Renderer::SetViewport() glViewport(iceilf(X), iceilf(Y), iceilf(Width), iceilf(Height)); } - // Set the reversed depth range. If we do depth clipping and depth range in the - // vertex shader we only need to ensure depth values don't exceed the maximum - // value supported by the console GPU. If not, we simply clamp the near/far values - // themselves to the maximum value as done above. + // Set the reversed depth range. glDepthRangef(max_depth, min_depth); } |
