Skip to content

Commit

Permalink
Make sure we don't try to set a negative viewport size.
Browse files Browse the repository at this point in the history
Should help #13921.
  • Loading branch information
hrydgard committed Jan 16, 2021
1 parent 19313aa commit 0386caf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions GPU/Common/GPUStateUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,9 @@ void ConvertViewportAndScissor(bool useBufferedRendering, float renderWidth, flo
renderHeightFactor = renderHeight / 272.0f;
}

_assert_(renderWidthFactor > 0.0);
_assert_(renderHeightFactor > 0.0);

renderX = gstate_c.curRTOffsetX;

// Scissor
Expand Down Expand Up @@ -694,8 +697,11 @@ void ConvertViewportAndScissor(bool useBufferedRendering, float renderWidth, flo

out.viewportX = left * renderWidthFactor + displayOffsetX;
out.viewportY = top * renderHeightFactor + displayOffsetY;
out.viewportW = (right - left) * renderWidthFactor;
out.viewportH = (bottom - top) * renderHeightFactor;

// The calculations should end up with zero or positive values, but let's protect against any
// precision issues. See #13921.
out.viewportW = std::max(0.0f, (right - left) * renderWidthFactor);
out.viewportH = std::max(0.0f, (bottom - top) * renderHeightFactor);

// The depth viewport parameters are the same, but we handle it a bit differently.
// When clipping is enabled, depth is clamped to [0, 65535]. And minz/maxz discard.
Expand Down
2 changes: 1 addition & 1 deletion ffmpeg
Submodule ffmpeg updated 0 files

0 comments on commit 0386caf

Please sign in to comment.