diff options
| author | Jules Blok <jules.blok@gmail.com> | 2016-08-23 16:23:58 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-08-23 16:23:58 +0200 |
| commit | 817009236474cce63e783cf5168d173d790ca79a (patch) | |
| tree | ac1bf60b1adcf88036bb1b9a68fa03f2ea499d6c /Source/Core/VideoCommon | |
| parent | 92f165d75693e54285294bb666f33d003d1ab174 (diff) | |
| parent | f7987017a02d249f92a2ba69ddc6c98ad86abfc3 (diff) | |
Merge pull request #4139 from Armada651/dbz-depth
OGL: Handle cases where reversed depth is already used.
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/PixelShaderManager.cpp | 4 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/VertexShaderManager.cpp | 22 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/VideoConfig.h | 1 |
3 files changed, 23 insertions, 4 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderManager.cpp b/Source/Core/VideoCommon/PixelShaderManager.cpp index b77f5e31a2..cb626bc31d 100644 --- a/Source/Core/VideoCommon/PixelShaderManager.cpp +++ b/Source/Core/VideoCommon/PixelShaderManager.cpp @@ -94,8 +94,8 @@ void PixelShaderManager::SetConstants() if (s_bViewPortChanged) { - constants.zbias[1][0] = (u32)xfmem.viewport.farZ; - constants.zbias[1][1] = (u32)xfmem.viewport.zRange; + constants.zbias[1][0] = (s32)xfmem.viewport.farZ; + constants.zbias[1][1] = (s32)xfmem.viewport.zRange; dirty = true; s_bViewPortChanged = false; } diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp index 5f9f4affdc..e8f82d0bf5 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/VertexShaderManager.cpp @@ -392,8 +392,26 @@ void VertexShaderManager::SetConstants() // 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. - constants.pixelcentercorrection[2] = xfmem.viewport.zRange / 16777215.0f; - constants.pixelcentercorrection[3] = 1.0f - xfmem.viewport.farZ / 16777215.0f; + if (g_ActiveConfig.backend_info.bSupportsReversedDepthRange) + { + // 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] = abs(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 + { + // 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; // This is so implementation-dependent that we can't have it here. diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h index 3a1f984e87..c948077acc 100644 --- a/Source/Core/VideoCommon/VideoConfig.h +++ b/Source/Core/VideoCommon/VideoConfig.h @@ -172,6 +172,7 @@ struct VideoConfig final bool bSupportsClipControl; // Needed by VertexShaderGen, so must stay in VideoCommon bool bSupportsSSAA; bool bSupportsDepthClamp; // Needed by VertexShaderGen, so must stay in VideoCommon + bool bSupportsReversedDepthRange; } backend_info; // Utility |
