summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/OGL/Render.cpp
diff options
context:
space:
mode:
authorJules Blok <jules.blok@gmail.com>2017-02-24 15:16:28 +0100
committerJules Blok <jules.blok@gmail.com>2017-02-26 11:34:48 +0100
commita15555fe0304e1ba560f91f8bacc8b121d226d1c (patch)
tree922822e65fa1303363f76896e9742ce7b5fd3582 /Source/Core/VideoBackends/OGL/Render.cpp
parentbde81269130c31c93cbb0f0f3ac8f23560751cac (diff)
VideoBackends: Use vertex shader depth range if ztexture is used.
Diffstat (limited to 'Source/Core/VideoBackends/OGL/Render.cpp')
-rw-r--r--Source/Core/VideoBackends/OGL/Render.cpp45
1 files changed, 20 insertions, 25 deletions
diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp
index f8405250d7..ee7d37bb67 100644
--- a/Source/Core/VideoBackends/OGL/Render.cpp
+++ b/Source/Core/VideoBackends/OGL/Render.cpp
@@ -1135,41 +1135,36 @@ void Renderer::SetViewport()
glViewport(iceilf(X), iceilf(Y), iceilf(Width), iceilf(Height));
}
- // Set the reversed depth range.
- if (g_ActiveConfig.backend_info.bSupportsOversizedDepthRanges)
+ if (!g_ActiveConfig.backend_info.bSupportsOversizedDepthRanges &&
+ !g_ActiveConfig.backend_info.bSupportsDepthClamp)
{
- glDepthRangedNV(max_depth, min_depth);
+ // 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);
}
- else
+
+ if (UseVertexDepthRange())
{
- // 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)
{
- // 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;
- }
+ min_depth = GX_MAX_DEPTH;
+ max_depth = 0.0f;
}
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);
+ min_depth = 0.0f;
+ max_depth = GX_MAX_DEPTH;
}
+ }
+ // Set the reversed depth range.
+ if (g_ActiveConfig.backend_info.bSupportsOversizedDepthRanges)
+ glDepthRangedNV(max_depth, min_depth);
+ else
glDepthRangef(max_depth, min_depth);
- }
}
void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable,