Merge pull request #4139 from Armada651/dbz-depth
OGL: Handle cases where reversed depth is already used.
This commit is contained in:
commit
8170092364
|
@ -72,6 +72,7 @@ void VideoBackend::InitBackendInfo()
|
||||||
g_Config.backend_info.bSupportsPaletteConversion = true;
|
g_Config.backend_info.bSupportsPaletteConversion = true;
|
||||||
g_Config.backend_info.bSupportsClipControl = true;
|
g_Config.backend_info.bSupportsClipControl = true;
|
||||||
g_Config.backend_info.bSupportsDepthClamp = true;
|
g_Config.backend_info.bSupportsDepthClamp = true;
|
||||||
|
g_Config.backend_info.bSupportsReversedDepthRange = false;
|
||||||
|
|
||||||
IDXGIFactory* factory;
|
IDXGIFactory* factory;
|
||||||
IDXGIAdapter* ad;
|
IDXGIAdapter* ad;
|
||||||
|
|
|
@ -75,6 +75,7 @@ void VideoBackend::InitBackendInfo()
|
||||||
g_Config.backend_info.bSupportsPaletteConversion = true;
|
g_Config.backend_info.bSupportsPaletteConversion = true;
|
||||||
g_Config.backend_info.bSupportsClipControl = true;
|
g_Config.backend_info.bSupportsClipControl = true;
|
||||||
g_Config.backend_info.bSupportsDepthClamp = true;
|
g_Config.backend_info.bSupportsDepthClamp = true;
|
||||||
|
g_Config.backend_info.bSupportsReversedDepthRange = false;
|
||||||
|
|
||||||
IDXGIFactory* factory;
|
IDXGIFactory* factory;
|
||||||
IDXGIAdapter* ad;
|
IDXGIAdapter* ad;
|
||||||
|
|
|
@ -1160,10 +1160,17 @@ void Renderer::SetViewport()
|
||||||
// value supported by the console GPU. If not, we simply clamp the near/far values
|
// value supported by the console GPU. If not, we simply clamp the near/far values
|
||||||
// themselves to the maximum value as done above.
|
// themselves to the maximum value as done above.
|
||||||
if (g_ActiveConfig.backend_info.bSupportsDepthClamp)
|
if (g_ActiveConfig.backend_info.bSupportsDepthClamp)
|
||||||
glDepthRangef(GX_MAX_DEPTH, 0.0f);
|
{
|
||||||
|
if (xfmem.viewport.zRange < 0.0f)
|
||||||
|
glDepthRangef(0.0f, GX_MAX_DEPTH);
|
||||||
else
|
else
|
||||||
|
glDepthRangef(GX_MAX_DEPTH, 0.0f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
glDepthRangef(GLFar, GLNear);
|
glDepthRangef(GLFar, GLNear);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable,
|
void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable,
|
||||||
u32 color, u32 z)
|
u32 color, u32 z)
|
||||||
|
|
|
@ -102,6 +102,7 @@ void VideoBackend::InitBackendInfo()
|
||||||
g_Config.backend_info.bSupports3DVision = false;
|
g_Config.backend_info.bSupports3DVision = false;
|
||||||
g_Config.backend_info.bSupportsPostProcessing = true;
|
g_Config.backend_info.bSupportsPostProcessing = true;
|
||||||
g_Config.backend_info.bSupportsSSAA = true;
|
g_Config.backend_info.bSupportsSSAA = true;
|
||||||
|
g_Config.backend_info.bSupportsReversedDepthRange = true;
|
||||||
|
|
||||||
// Overwritten in Render.cpp later
|
// Overwritten in Render.cpp later
|
||||||
g_Config.backend_info.bSupportsDualSourceBlend = true;
|
g_Config.backend_info.bSupportsDualSourceBlend = true;
|
||||||
|
|
|
@ -94,8 +94,8 @@ void PixelShaderManager::SetConstants()
|
||||||
|
|
||||||
if (s_bViewPortChanged)
|
if (s_bViewPortChanged)
|
||||||
{
|
{
|
||||||
constants.zbias[1][0] = (u32)xfmem.viewport.farZ;
|
constants.zbias[1][0] = (s32)xfmem.viewport.farZ;
|
||||||
constants.zbias[1][1] = (u32)xfmem.viewport.zRange;
|
constants.zbias[1][1] = (s32)xfmem.viewport.zRange;
|
||||||
dirty = true;
|
dirty = true;
|
||||||
s_bViewPortChanged = false;
|
s_bViewPortChanged = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -392,8 +392,26 @@ void VertexShaderManager::SetConstants()
|
||||||
// because the standard depth range equation pushes all depth values towards
|
// because the standard depth range equation pushes all depth values towards
|
||||||
// the back of the depth buffer where conventionally depth buffers have the
|
// the back of the depth buffer where conventionally depth buffers have the
|
||||||
// least precision.
|
// least precision.
|
||||||
|
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[2] = xfmem.viewport.zRange / 16777215.0f;
|
||||||
constants.pixelcentercorrection[3] = 1.0f - xfmem.viewport.farZ / 16777215.0f;
|
constants.pixelcentercorrection[3] = 1.0f - xfmem.viewport.farZ / 16777215.0f;
|
||||||
|
}
|
||||||
|
|
||||||
dirty = true;
|
dirty = true;
|
||||||
// This is so implementation-dependent that we can't have it here.
|
// This is so implementation-dependent that we can't have it here.
|
||||||
|
|
|
@ -172,6 +172,7 @@ struct VideoConfig final
|
||||||
bool bSupportsClipControl; // Needed by VertexShaderGen, so must stay in VideoCommon
|
bool bSupportsClipControl; // Needed by VertexShaderGen, so must stay in VideoCommon
|
||||||
bool bSupportsSSAA;
|
bool bSupportsSSAA;
|
||||||
bool bSupportsDepthClamp; // Needed by VertexShaderGen, so must stay in VideoCommon
|
bool bSupportsDepthClamp; // Needed by VertexShaderGen, so must stay in VideoCommon
|
||||||
|
bool bSupportsReversedDepthRange;
|
||||||
} backend_info;
|
} backend_info;
|
||||||
|
|
||||||
// Utility
|
// Utility
|
||||||
|
|
Loading…
Reference in New Issue