summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/VertexShaderGen.cpp
diff options
context:
space:
mode:
authorJules Blok <jules.blok@gmail.com>2016-11-23 23:25:44 +0100
committerJules Blok <jules.blok@gmail.com>2016-12-27 14:31:17 +0100
commitef82aebb971f5fd792e93facbfcb7b5bf757776c (patch)
tree3c923c01d898aefa981040f18a5503e785c7dc57 /Source/Core/VideoCommon/VertexShaderGen.cpp
parent8e506cb974521017e2563821221784eb54cf8e98 (diff)
VideoCommon: Don't process the depth range in the vertex shader if it's not oversized.
Diffstat (limited to 'Source/Core/VideoCommon/VertexShaderGen.cpp')
-rw-r--r--Source/Core/VideoCommon/VertexShaderGen.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/Source/Core/VideoCommon/VertexShaderGen.cpp b/Source/Core/VideoCommon/VertexShaderGen.cpp
index d3ea2a774a..8f44f1735e 100644
--- a/Source/Core/VideoCommon/VertexShaderGen.cpp
+++ b/Source/Core/VideoCommon/VertexShaderGen.cpp
@@ -30,6 +30,10 @@ VertexShaderUid GetVertexShaderUid()
uid_data->msaa = g_ActiveConfig.iMultisamples > 1;
uid_data->ssaa = g_ActiveConfig.iMultisamples > 1 && g_ActiveConfig.bSSAA;
uid_data->numColorChans = xfmem.numChan.numColorChans;
+ uid_data->vertex_depth =
+ g_ActiveConfig.backend_info.bSupportsDepthClamp &&
+ ((fabs(xfmem.viewport.zRange) > 16777215.0f || fabs(xfmem.viewport.farZ) > 16777215.0f) ||
+ (xfmem.viewport.zRange < 0.0f && !g_ActiveConfig.backend_info.bSupportsReversedDepthRange));
GetLightingShaderUid(uid_data->lighting);
@@ -416,13 +420,10 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const vertex_shader_uid_da
out.Write("o.colors_1 = color1;\n");
}
- // Write the true depth value. If the game uses depth textures, then the pixel shader will
- // override it with the correct values if not then early z culling will improve speed.
+ // If we can disable the incorrect depth clipping planes using depth clamping, then we can do
+ // our own depth clipping and calculate the depth range before the perspective divide.
if (g_ActiveConfig.backend_info.bSupportsDepthClamp)
{
- // If we can disable the incorrect depth clipping planes using depth clamping, then we can do
- // our own depth clipping and calculate the depth range before the perspective divide.
-
// Since we're adjusting z for the depth range before the perspective divide, we have to do our
// own clipping. We want to clip so that -w <= z <= 0, which matches the console -1..0 range.
// We adjust our depth value for clipping purposes to match the perspective projection in the
@@ -430,7 +431,12 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const vertex_shader_uid_da
out.Write("float clipDepth = o.pos.z * (1.0 - 1e-7);\n");
out.Write("o.clipDist0 = clipDepth + o.pos.w;\n"); // Near: z < -w
out.Write("o.clipDist1 = -clipDepth;\n"); // Far: z > 0
+ }
+ // Write the true depth value. If the game uses depth textures, then the pixel shader will
+ // override it with the correct values if not then early z culling will improve speed.
+ if (uid_data->vertex_depth)
+ {
// Adjust z for the depth range. We're using an equation which incorperates a depth inversion,
// so we can map the console -1..0 range to the 0..1 range used in the depth buffer.
// We have to handle the depth range in the vertex shader instead of after the perspective