Merge pull request #4935 from Armada651/depth-range-fix

VideoBackends: Set the maximum range when the depth range is oversized.
This commit is contained in:
Markus Wick
2017-03-10 18:05:52 +01:00
committed by GitHub
21 changed files with 181 additions and 77 deletions

View File

@ -1628,10 +1628,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;
@ -1643,11 +1641,12 @@ void Renderer::SetViewport()
height = -height;
}
// If an inverted depth range is used, which the Vulkan drivers don't
// support, we need to calculate the depth range in the vertex shader.
// TODO: Make this into a DriverDetails bug and write a test for CTS.
if (xfmem.viewport.zRange < 0.0f)
// If an oversized or inverted depth range is used, we need to calculate the depth range in the
// vertex shader.
// TODO: Inverted depth ranges are bugged in all drivers, which should be added to DriverDetails.
if (UseVertexDepthRange())
{
// We need to ensure depth values are clamped the maximum value supported by the console GPU.
min_depth = 0.0f;
max_depth = GX_MAX_DEPTH;
}