diff options
| author | Markus Wick <degasus@users.noreply.github.com> | 2017-01-15 23:02:13 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-01-15 23:02:13 +0100 |
| commit | 23104b6939079a5153eb52213f771d4157c3bbea (patch) | |
| tree | 4f5a38c6559e1a79d4bb5bfa484d25339e7f26a9 /Source/Core/VideoCommon/VertexShaderManager.cpp | |
| parent | 28f0d8e8a73af1323d3d88b91459911469f2ac1c (diff) | |
| parent | 271a9fe7a900634a1d9aeaf8f03218658fee246a (diff) | |
Merge pull request #4655 from Armada651/vertex-depth-no-uid
VertexShaderGen: Remove the need for an extra UID.
Diffstat (limited to 'Source/Core/VideoCommon/VertexShaderManager.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/VertexShaderManager.cpp | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp index c7331fe446..e516c2c63c 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/VertexShaderManager.cpp @@ -387,30 +387,44 @@ void VertexShaderManager::SetConstants() constants.pixelcentercorrection[0] = pixel_center_correction * pixel_size_x; constants.pixelcentercorrection[1] = pixel_center_correction * pixel_size_y; - // The depth range is handled in the vertex shader. We need to reverse - // the far value to get a reversed depth range mapping. This is necessary - // because the standard depth range equation pushes all depth values towards - // the back of the depth buffer where conventionally depth buffers have the - // least precision. - if (g_ActiveConfig.backend_info.bSupportsReversedDepthRange) + // By default we don't change the depth value at all in the vertex shader. + constants.pixelcentercorrection[2] = 1.0f; + constants.pixelcentercorrection[3] = 0.0f; + + if (g_ActiveConfig.backend_info.bSupportsDepthClamp) { - // For backends that support reversing the depth range we also support cases - // where the console also uses reversed depth with the same accuracy. We need - // to make sure the depth range is positive here and then reverse the depth in - // the backend viewport. - constants.pixelcentercorrection[2] = fabs(xfmem.viewport.zRange) / 16777215.0f; - if (xfmem.viewport.zRange < 0.0f) - constants.pixelcentercorrection[3] = xfmem.viewport.farZ / 16777215.0f; + // Oversized depth ranges are handled in the vertex shader. We need to reverse + // the far value to get a reversed depth range mapping. This is necessary + // because the standard depth range equation pushes all depth values towards + // the back of the depth buffer where conventionally depth buffers have the + // least precision. + if (g_ActiveConfig.backend_info.bSupportsReversedDepthRange) + { + if (fabs(xfmem.viewport.zRange) > 16777215.0f || fabs(xfmem.viewport.farZ) > 16777215.0f) + { + // For backends that support reversing the depth range we also support cases + // where the console also uses reversed depth with the same accuracy. We need + // to make sure the depth range is positive here and then reverse the depth in + // the backend viewport. + constants.pixelcentercorrection[2] = fabs(xfmem.viewport.zRange) / 16777215.0f; + if (xfmem.viewport.zRange < 0.0f) + constants.pixelcentercorrection[3] = xfmem.viewport.farZ / 16777215.0f; + else + constants.pixelcentercorrection[3] = 1.0f - xfmem.viewport.farZ / 16777215.0f; + } + } else - constants.pixelcentercorrection[3] = 1.0f - xfmem.viewport.farZ / 16777215.0f; - } - else - { - // For backends that don't support reversing the depth range we can still render - // cases where the console uses reversed depth correctly. But we simply can't - // provide the same accuracy as the console. - constants.pixelcentercorrection[2] = xfmem.viewport.zRange / 16777215.0f; - constants.pixelcentercorrection[3] = 1.0f - xfmem.viewport.farZ / 16777215.0f; + { + if (xfmem.viewport.zRange < 0.0f || xfmem.viewport.zRange > 16777215.0f || + fabs(xfmem.viewport.farZ) > 16777215.0f) + { + // For backends that don't support reversing the depth range we can still render + // cases where the console uses reversed depth correctly. But we simply can't + // provide the same accuracy as the console. + constants.pixelcentercorrection[2] = xfmem.viewport.zRange / 16777215.0f; + constants.pixelcentercorrection[3] = 1.0f - xfmem.viewport.farZ / 16777215.0f; + } + } } dirty = true; |
