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

@ -926,3 +926,32 @@ void Renderer::DumpFrameToImage(const FrameDumpConfig& config)
TextureToPng(config.data, config.stride, filename, config.width, config.height, false);
m_frame_dump_image_counter++;
}
bool Renderer::UseVertexDepthRange() const
{
// We can't compute the depth range in the vertex shader if we don't support depth clamp.
if (!g_ActiveConfig.backend_info.bSupportsDepthClamp)
return false;
const bool ztexture_enabled = bpmem.ztex2.type != ZTEXTURE_DISABLE && !bpmem.zcontrol.early_ztest;
if (g_ActiveConfig.backend_info.bSupportsOversizedDepthRanges)
{
// We support oversized depth ranges, but we need a full depth range if a ztexture is used.
return ztexture_enabled;
}
else
{
// We need a full depth range if a ztexture is used.
if (ztexture_enabled)
return true;
// If an inverted depth range is unsupported, we also need to check if the range is inverted.
if (!g_ActiveConfig.backend_info.bSupportsReversedDepthRange && xfmem.viewport.zRange < 0.0f)
return true;
// If an oversized depth range or a ztexture is used, we need to calculate the depth range
// in the vertex shader.
return fabs(xfmem.viewport.zRange) > 16777215.0f || fabs(xfmem.viewport.farZ) > 16777215.0f;
}
}