diff options
| author | Markus Wick <degasus@users.noreply.github.com> | 2017-03-10 18:05:52 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-03-10 18:05:52 +0100 |
| commit | e99cd57eb3827b246ea712e031bac3ffe92fe109 (patch) | |
| tree | f12d83d565f2e36d785046ff5917814be50fe62b /Source/Core/VideoBackends/Vulkan/Renderer.cpp | |
| parent | a3f5e3e27dacc40082346bbb00d41eddd61b16b9 (diff) | |
| parent | 3f41e6d4cf9f1a318c6d32fea4d2b422684961a3 (diff) | |
Merge pull request #4935 from Armada651/depth-range-fix
VideoBackends: Set the maximum range when the depth range is oversized.
Diffstat (limited to 'Source/Core/VideoBackends/Vulkan/Renderer.cpp')
| -rw-r--r-- | Source/Core/VideoBackends/Vulkan/Renderer.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/Source/Core/VideoBackends/Vulkan/Renderer.cpp b/Source/Core/VideoBackends/Vulkan/Renderer.cpp index d44317b3de..0a65290dd0 100644 --- a/Source/Core/VideoBackends/Vulkan/Renderer.cpp +++ b/Source/Core/VideoBackends/Vulkan/Renderer.cpp @@ -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; } |
