Permalink
Browse files

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.
  • Loading branch information...
unknownbrackets committed Sep 21, 2018
1 parent 92b857c commit a8588b0c5c86a10fec5d5160839042a4fb666557
Showing with 3 additions and 3 deletions.
  1. +3 −3 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) {

0 comments on commit a8588b0

Please sign in to comment.