VideoBackends: Remove depth range clamping hacks.
Oversized depth ranges are handled correctly now, we don't need to hack around them with clamps anymore.
This commit is contained in:
parent
94522d4cf3
commit
bde8126913
|
@ -561,10 +561,8 @@ void Renderer::SetViewport()
|
|||
float Y = Renderer::EFBToScaledYf(xfmem.viewport.yOrig + xfmem.viewport.ht - scissorYOff);
|
||||
float Wd = Renderer::EFBToScaledXf(2.0f * xfmem.viewport.wd);
|
||||
float Ht = Renderer::EFBToScaledYf(-2.0f * xfmem.viewport.ht);
|
||||
float range = MathUtil::Clamp<float>(xfmem.viewport.zRange, 0.0f, 16777215.0f);
|
||||
float min_depth =
|
||||
MathUtil::Clamp<float>(xfmem.viewport.farZ - range, 0.0f, 16777215.0f) / 16777216.0f;
|
||||
float max_depth = MathUtil::Clamp<float>(xfmem.viewport.farZ, 0.0f, 16777215.0f) / 16777216.0f;
|
||||
float min_depth = (xfmem.viewport.farZ - xfmem.viewport.zRange) / 16777216.0f;
|
||||
float max_depth = xfmem.viewport.farZ / 16777216.0f;
|
||||
if (Wd < 0.0f)
|
||||
{
|
||||
X += Wd;
|
||||
|
|
|
@ -466,10 +466,8 @@ void Renderer::SetViewport()
|
|||
float y = Renderer::EFBToScaledYf(xfmem.viewport.yOrig + xfmem.viewport.ht - scissor_y_offset);
|
||||
float width = Renderer::EFBToScaledXf(2.0f * xfmem.viewport.wd);
|
||||
float height = Renderer::EFBToScaledYf(-2.0f * xfmem.viewport.ht);
|
||||
float range = MathUtil::Clamp<float>(xfmem.viewport.zRange, 0.0f, 16777215.0f);
|
||||
float min_depth =
|
||||
MathUtil::Clamp<float>(xfmem.viewport.farZ - range, 0.0f, 16777215.0f) / 16777216.0f;
|
||||
float max_depth = MathUtil::Clamp<float>(xfmem.viewport.farZ, 0.0f, 16777215.0f) / 16777216.0f;
|
||||
float min_depth = (xfmem.viewport.farZ - xfmem.viewport.zRange) / 16777216.0f;
|
||||
float max_depth = xfmem.viewport.farZ / 16777216.0f;
|
||||
if (width < 0.0f)
|
||||
{
|
||||
x += width;
|
||||
|
|
|
@ -1111,6 +1111,8 @@ void Renderer::SetViewport()
|
|||
(float)scissorYOff);
|
||||
float Width = EFBToScaledXf(2.0f * xfmem.viewport.wd);
|
||||
float Height = EFBToScaledYf(-2.0f * xfmem.viewport.ht);
|
||||
float min_depth = (xfmem.viewport.farZ - xfmem.viewport.zRange) / 16777216.0f;
|
||||
float max_depth = xfmem.viewport.farZ / 16777216.0f;
|
||||
if (Width < 0)
|
||||
{
|
||||
X += Width;
|
||||
|
@ -1136,17 +1138,10 @@ void Renderer::SetViewport()
|
|||
// Set the reversed depth range.
|
||||
if (g_ActiveConfig.backend_info.bSupportsOversizedDepthRanges)
|
||||
{
|
||||
float min_depth = (xfmem.viewport.farZ - xfmem.viewport.zRange) / 16777216.0f;
|
||||
float max_depth = xfmem.viewport.farZ / 16777216.0f;
|
||||
glDepthRangedNV(max_depth, min_depth);
|
||||
}
|
||||
else
|
||||
{
|
||||
float range = MathUtil::Clamp<float>(xfmem.viewport.zRange, -16777216.0f, 16777216.0f);
|
||||
float min_depth =
|
||||
MathUtil::Clamp<float>(xfmem.viewport.farZ - range, 0.0f, 16777215.0f) / 16777216.0f;
|
||||
float max_depth = MathUtil::Clamp<float>(xfmem.viewport.farZ, 0.0f, 16777215.0f) / 16777216.0f;
|
||||
|
||||
// If an oversized depth range is used, we need to calculate the depth range in the
|
||||
// vertex shader.
|
||||
if (g_ActiveConfig.backend_info.bSupportsDepthClamp &&
|
||||
|
@ -1165,6 +1160,13 @@ void Renderer::SetViewport()
|
|||
max_depth = GX_MAX_DEPTH;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// There's no way to support oversized depth ranges in this situation. Let's just clamp the
|
||||
// range to the maximum value supported by the console GPU and hope for the best.
|
||||
min_depth = MathUtil::Clamp(min_depth, 0.0f, GX_MAX_DEPTH);
|
||||
max_depth = MathUtil::Clamp(max_depth, 0.0f, GX_MAX_DEPTH);
|
||||
}
|
||||
|
||||
glDepthRangef(max_depth, min_depth);
|
||||
}
|
||||
|
|
|
@ -1641,10 +1641,8 @@ void Renderer::SetViewport()
|
|||
float y = Renderer::EFBToScaledYf(xfmem.viewport.yOrig + xfmem.viewport.ht - scissor_y_offset);
|
||||
float width = Renderer::EFBToScaledXf(2.0f * xfmem.viewport.wd);
|
||||
float height = Renderer::EFBToScaledYf(-2.0f * xfmem.viewport.ht);
|
||||
float range = MathUtil::Clamp<float>(xfmem.viewport.zRange, -16777215.0f, 16777215.0f);
|
||||
float min_depth =
|
||||
MathUtil::Clamp<float>(xfmem.viewport.farZ - range, 0.0f, 16777215.0f) / 16777216.0f;
|
||||
float max_depth = MathUtil::Clamp<float>(xfmem.viewport.farZ, 0.0f, 16777215.0f) / 16777216.0f;
|
||||
float min_depth = (xfmem.viewport.farZ - xfmem.viewport.zRange) / 16777216.0f;
|
||||
float max_depth = xfmem.viewport.farZ / 16777216.0f;
|
||||
if (width < 0.0f)
|
||||
{
|
||||
x += width;
|
||||
|
|
Loading…
Reference in New Issue