mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 22:29:39 -06:00
OGL: Handle cases where reversed depth is already used.
This commit is contained in:
@ -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.
|
||||
|
Reference in New Issue
Block a user