From be1d0cee1e131eb4cd1c8becf3e3714644bd9495 Mon Sep 17 00:00:00 2001 From: Phantom Date: Fri, 29 Dec 2017 17:07:01 +0100 Subject: [PATCH] Fix viewport to surface rect clamping --- .../renderer_opengl/gl_rasterizer.cpp | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index f4ead08488..3ceab54a27 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -271,14 +271,18 @@ void RasterizerOpenGL::DrawTriangles() { : (depth_surface == nullptr ? 1u : depth_surface->res_scale); MathUtil::Rectangle draw_rect{ - MathUtil::Clamp(surfaces_rect.left + viewport_rect_unscaled.left * res_scale, // left - surfaces_rect.left, surfaces_rect.right), - MathUtil::Clamp(surfaces_rect.bottom + viewport_rect_unscaled.top * res_scale, // top - surfaces_rect.bottom, surfaces_rect.top), - MathUtil::Clamp(surfaces_rect.left + viewport_rect_unscaled.right * res_scale, // right - surfaces_rect.left, surfaces_rect.right), - MathUtil::Clamp(surfaces_rect.bottom + viewport_rect_unscaled.bottom * res_scale, // bottom - surfaces_rect.bottom, surfaces_rect.top)}; + static_cast(MathUtil::Clamp(static_cast(surfaces_rect.left) + + viewport_rect_unscaled.left * res_scale, + surfaces_rect.left, surfaces_rect.right)), // Left + static_cast(MathUtil::Clamp(static_cast(surfaces_rect.bottom) + + viewport_rect_unscaled.top * res_scale, + surfaces_rect.bottom, surfaces_rect.top)), // Top + static_cast(MathUtil::Clamp(static_cast(surfaces_rect.left) + + viewport_rect_unscaled.right * res_scale, + surfaces_rect.left, surfaces_rect.right)), // Right + static_cast(MathUtil::Clamp(static_cast(surfaces_rect.bottom) + + viewport_rect_unscaled.bottom * res_scale, + surfaces_rect.bottom, surfaces_rect.top))}; // Bottom // Bind the framebuffer surfaces state.draw.draw_framebuffer = framebuffer.handle; @@ -306,9 +310,9 @@ void RasterizerOpenGL::DrawTriangles() { // Sync the viewport state.viewport.x = - static_cast(surfaces_rect.left + viewport_rect_unscaled.left * res_scale); + static_cast(surfaces_rect.left) + viewport_rect_unscaled.left * res_scale; state.viewport.y = - static_cast(surfaces_rect.bottom + viewport_rect_unscaled.bottom * res_scale); + static_cast(surfaces_rect.bottom) + viewport_rect_unscaled.bottom * res_scale; state.viewport.width = static_cast(viewport_rect_unscaled.GetWidth() * res_scale); state.viewport.height = static_cast(viewport_rect_unscaled.GetHeight() * res_scale);