From a8588b0c5c86a10fec5d5160839042a4fb666557 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 20 Sep 2018 20:29:46 -0700 Subject: [PATCH] GPU: Correct handling of large viewport scaling. Need to multiply not divide, duh. Also lost the offset during refactor, and didn't test it well. --- GPU/Common/ShaderUniforms.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/GPU/Common/ShaderUniforms.cpp b/GPU/Common/ShaderUniforms.cpp index c6ffcf23c5..e0f6719502 100644 --- a/GPU/Common/ShaderUniforms.cpp +++ b/GPU/Common/ShaderUniforms.cpp @@ -30,7 +30,7 @@ void CalcCullRange(float minValues[4], float maxValues[4], bool flipViewport, bo // Account for the projection viewport adjustment when viewport is too large. auto reverseViewportX = [](float x) { float pspViewport = (x - gstate.getViewportXCenter()) * (1.0f / gstate.getViewportXScale()); - return pspViewport * (1.0f / gstate_c.vpWidthScale); + return (pspViewport - gstate_c.vpXOffset) * gstate_c.vpWidthScale; }; auto reverseViewportY = [flipViewport](float y) { float heightScale = gstate_c.vpHeightScale; @@ -39,12 +39,12 @@ void CalcCullRange(float minValues[4], float maxValues[4], bool flipViewport, bo heightScale = -heightScale; } float pspViewport = (y - gstate.getViewportYCenter()) * (1.0f / gstate.getViewportYScale()); - return pspViewport * (1.0f / gstate_c.vpHeightScale); + return (pspViewport - gstate_c.vpYOffset) * heightScale; }; auto reverseViewportZ = [hasNegZ](float z) { float pspViewport = (z - gstate.getViewportZCenter()) * (1.0f / gstate.getViewportZScale()); // Differs from GLES: depth is 0 to 1, not -1 to 1. - float realViewport = (pspViewport - gstate_c.vpZOffset) * (1.0f / gstate_c.vpDepthScale); + float realViewport = (pspViewport - gstate_c.vpZOffset) * gstate_c.vpDepthScale; return hasNegZ ? realViewport : (realViewport * 0.5f + 0.5f); }; auto sortPair = [](float a, float b) {