From ee7a2edf35807689dfeec3d39e6a02c6444d4249 Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Tue, 27 Dec 2016 20:25:46 +0100 Subject: [PATCH] Update comments --- Source/Core/VideoBackends/Vulkan/Renderer.cpp | 5 +++-- Source/Core/VideoCommon/VertexShaderGen.cpp | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Source/Core/VideoBackends/Vulkan/Renderer.cpp b/Source/Core/VideoBackends/Vulkan/Renderer.cpp index 1407a4fbec..b4e39f3ed0 100644 --- a/Source/Core/VideoBackends/Vulkan/Renderer.cpp +++ b/Source/Core/VideoBackends/Vulkan/Renderer.cpp @@ -1650,8 +1650,9 @@ void Renderer::SetViewport() height = -height; } - // If an inverted depth range is used, which D3D doesn't support, - // we need to calculate the depth range in the vertex shader. + // 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) { min_depth = 0.0f; diff --git a/Source/Core/VideoCommon/VertexShaderGen.cpp b/Source/Core/VideoCommon/VertexShaderGen.cpp index 8f44f1735e..8ebcc76257 100644 --- a/Source/Core/VideoCommon/VertexShaderGen.cpp +++ b/Source/Core/VideoCommon/VertexShaderGen.cpp @@ -421,7 +421,8 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const vertex_shader_uid_da } // If we can disable the incorrect depth clipping planes using depth clamping, then we can do - // our own depth clipping and calculate the depth range before the perspective divide. + // our own depth clipping and calculate the depth range before the perspective divide if + // necessary. if (g_ActiveConfig.backend_info.bSupportsDepthClamp) { // Since we're adjusting z for the depth range before the perspective divide, we have to do our @@ -435,6 +436,8 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const vertex_shader_uid_da // Write the true depth value. If the game uses depth textures, then the pixel shader will // override it with the correct values if not then early z culling will improve speed. + // There are two different ways to do this, when the depth range is oversized, we process + // the depth range in the vertex shader, if not we let the host driver handle it. if (uid_data->vertex_depth) { // Adjust z for the depth range. We're using an equation which incorperates a depth inversion, @@ -448,11 +451,8 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const vertex_shader_uid_da } else { - // If we can't disable the incorrect depth clipping planes, then we need to rely on the - // graphics API to handle the depth range after the perspective divide. This can result in - // inaccurate depth values due to the missing depth bias, but that can be least corrected by - // overriding depth values in the pixel shader. We still need to take care of the reversed depth - // though, so we do that here. + // Here we rely on the host driver to process the depth range, however we still need to invert + // the console -1..0 range to the 0..1 range used in the depth buffer. out.Write("o.pos.z = -o.pos.z;\n"); }