From a15555fe0304e1ba560f91f8bacc8b121d226d1c Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Fri, 24 Feb 2017 15:16:28 +0100 Subject: VideoBackends: Use vertex shader depth range if ztexture is used. --- Source/Core/VideoCommon/RenderBase.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'Source/Core/VideoCommon/RenderBase.cpp') diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index f47288ea4e..19ec2abed2 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -940,3 +940,30 @@ 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; + + if (g_ActiveConfig.backend_info.bSupportsOversizedDepthRanges) + { + // We support oversized depth ranges, but we need a full depth range if a ztexture is used. + return bpmem.ztex2.type != ZTEXTURE_DISABLE; + } + else + { + // We need a full depth range if a ztexture is used. + if (bpmem.ztex2.type != ZTEXTURE_DISABLE) + 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; + } +} -- cgit v1.2.3 From 3f41e6d4cf9f1a318c6d32fea4d2b422684961a3 Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Fri, 10 Mar 2017 15:43:32 +0100 Subject: RenderBase: Check if early ztest is enabled before falling back to vertex depth range. --- Source/Core/VideoCommon/RenderBase.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Source/Core/VideoCommon/RenderBase.cpp') diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 19ec2abed2..8ee4de1546 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -947,15 +947,17 @@ bool Renderer::UseVertexDepthRange() const 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 bpmem.ztex2.type != ZTEXTURE_DISABLE; + return ztexture_enabled; } else { // We need a full depth range if a ztexture is used. - if (bpmem.ztex2.type != ZTEXTURE_DISABLE) + if (ztexture_enabled) return true; // If an inverted depth range is unsupported, we also need to check if the range is inverted. -- cgit v1.2.3