Skip to content

Commit

Permalink
Merge pull request #11859 from unknownbrackets/cullrange
Browse files Browse the repository at this point in the history
GPU: Handle cull range properly drawing at offset
  • Loading branch information
hrydgard committed Mar 2, 2019
2 parents 2d5acc8 + d7f2167 commit 748110c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions GPU/Common/ShaderUniforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,18 @@ 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 - gstate_c.vpXOffset) * gstate_c.vpWidthScale;
return (pspViewport * gstate_c.vpWidthScale) - gstate_c.vpXOffset;
};
auto reverseViewportY = [flipViewport](float y) {
float heightScale = gstate_c.vpHeightScale;
float yOffset = gstate_c.vpYOffset;
if (flipViewport) {
// For D3D11 and GLES non-buffered.
heightScale = -heightScale;
yOffset = -yOffset;
}
float pspViewport = (y - gstate.getViewportYCenter()) * (1.0f / gstate.getViewportYScale());
return (pspViewport - gstate_c.vpYOffset) * heightScale;
return (pspViewport * heightScale) - yOffset;
};
auto reverseViewportZ = [hasNegZ](float z) {
float vpZScale = gstate.getViewportZScale();
Expand Down

0 comments on commit 748110c

Please sign in to comment.