diff options
| author | Stenzek <stenzek@gmail.com> | 2018-01-21 22:04:15 +1000 |
|---|---|---|
| committer | Stenzek <stenzek@gmail.com> | 2018-02-20 00:49:32 +1000 |
| commit | 5359396099dd09583a155dbf4c6bd04df0a97582 (patch) | |
| tree | 205baf7bea96fbb14ad1c8425fbe9e65fdd11f49 /Source/Core/VideoBackends/Vulkan/Renderer.cpp | |
| parent | a2d2a0a356cd9ef66077033b553fd09ba7423f9a (diff) | |
BPFunctions: Move GX viewport conversion to VideoCommon
Diffstat (limited to 'Source/Core/VideoBackends/Vulkan/Renderer.cpp')
| -rw-r--r-- | Source/Core/VideoBackends/Vulkan/Renderer.cpp | 41 |
1 files changed, 5 insertions, 36 deletions
diff --git a/Source/Core/VideoBackends/Vulkan/Renderer.cpp b/Source/Core/VideoBackends/Vulkan/Renderer.cpp index e4fb76c37c..7a882217cb 100644 --- a/Source/Core/VideoBackends/Vulkan/Renderer.cpp +++ b/Source/Core/VideoBackends/Vulkan/Renderer.cpp @@ -810,7 +810,7 @@ void Renderer::RecreateEFBFramebuffer() BindEFBToStateTracker(); // Viewport and scissor rect have to be reset since they will be scaled differently. - SetViewport(); + BPFunctions::SetViewport(); BPFunctions::SetScissor(); } @@ -910,42 +910,11 @@ void Renderer::SetScissorRect(const EFBRectangle& rc) StateTracker::GetInstance()->SetScissor(scissor); } -void Renderer::SetViewport() +void Renderer::SetViewport(float x, float y, float width, float height, float near_depth, + float far_depth) { - int scissor_x_offset = bpmem.scissorOffset.x * 2; - int scissor_y_offset = bpmem.scissorOffset.y * 2; - - float x = Renderer::EFBToScaledXf(xfmem.viewport.xOrig - xfmem.viewport.wd - scissor_x_offset); - 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 min_depth = (xfmem.viewport.farZ - xfmem.viewport.zRange) / 16777216.0f; - float max_depth = xfmem.viewport.farZ / 16777216.0f; - if (width < 0.0f) - { - x += width; - width = -width; - } - if (height < 0.0f) - { - y += height; - height = -height; - } - - // 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; - } - - // We use an inverted depth range here to apply the Reverse Z trick. - // This trick makes sure we match the precision provided by the 1:0 - // clipping depth range on the hardware. - VkViewport viewport = {x, y, width, height, 1.0f - max_depth, 1.0f - min_depth}; + VkViewport viewport = {x, y, std::max(width, 1.0f), std::max(height, 1.0f), + near_depth, far_depth}; StateTracker::GetInstance()->SetViewport(viewport); } |
