summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/engines/maxwell_3d.h40
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp4
2 files changed, 30 insertions, 14 deletions
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index 5cf62fb01..245410c95 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -354,10 +354,35 @@ public:
354 f32 scale_x; 354 f32 scale_x;
355 f32 scale_y; 355 f32 scale_y;
356 f32 scale_z; 356 f32 scale_z;
357 u32 translate_x; 357 f32 translate_x;
358 u32 translate_y; 358 f32 translate_y;
359 u32 translate_z; 359 f32 translate_z;
360 INSERT_PADDING_WORDS(2); 360 INSERT_PADDING_WORDS(2);
361
362 MathUtil::Rectangle<s32> GetRect() const {
363 return {
364 GetX(), // left
365 GetY() + GetHeight(), // top
366 GetX() + GetWidth(), // right
367 GetY() // bottom
368 };
369 };
370
371 s32 GetX() const {
372 return static_cast<s32>(std::max(0.0f, translate_x - std::fabs(scale_x)));
373 }
374
375 s32 GetY() const {
376 return static_cast<s32>(std::max(0.0f, translate_y - std::fabs(scale_y)));
377 }
378
379 s32 GetWidth() const {
380 return static_cast<s32>(translate_x + std::fabs(scale_x)) - GetX();
381 }
382
383 s32 GetHeight() const {
384 return static_cast<s32>(translate_y + std::fabs(scale_y)) - GetY();
385 }
361 } viewport_transform[NumViewports]; 386 } viewport_transform[NumViewports];
362 387
363 struct { 388 struct {
@@ -371,15 +396,6 @@ public:
371 }; 396 };
372 float depth_range_near; 397 float depth_range_near;
373 float depth_range_far; 398 float depth_range_far;
374
375 MathUtil::Rectangle<s32> GetRect() const {
376 return {
377 static_cast<s32>(x), // left
378 static_cast<s32>(y + height), // top
379 static_cast<s32>(x + width), // right
380 static_cast<s32>(y) // bottom
381 };
382 };
383 } viewport[NumViewports]; 399 } viewport[NumViewports];
384 400
385 INSERT_PADDING_WORDS(0x1D); 401 INSERT_PADDING_WORDS(0x1D);
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 35c1b1890..0a33868b7 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -298,7 +298,7 @@ void RasterizerOpenGL::DrawArrays() {
298 const bool has_stencil = false; 298 const bool has_stencil = false;
299 const bool using_color_fb = true; 299 const bool using_color_fb = true;
300 const bool using_depth_fb = false; 300 const bool using_depth_fb = false;
301 const MathUtil::Rectangle<s32> viewport_rect{regs.viewport[0].GetRect()}; 301 const MathUtil::Rectangle<s32> viewport_rect{regs.viewport_transform[0].GetRect()};
302 302
303 const bool write_color_fb = 303 const bool write_color_fb =
304 state.color_mask.red_enabled == GL_TRUE || state.color_mask.green_enabled == GL_TRUE || 304 state.color_mask.red_enabled == GL_TRUE || state.color_mask.green_enabled == GL_TRUE ||
@@ -702,7 +702,7 @@ void RasterizerOpenGL::BindFramebufferSurfaces(const Surface& color_surface,
702 702
703void RasterizerOpenGL::SyncViewport(const MathUtil::Rectangle<u32>& surfaces_rect, u16 res_scale) { 703void RasterizerOpenGL::SyncViewport(const MathUtil::Rectangle<u32>& surfaces_rect, u16 res_scale) {
704 const auto& regs = Core::System().GetInstance().GPU().Maxwell3D().regs; 704 const auto& regs = Core::System().GetInstance().GPU().Maxwell3D().regs;
705 const MathUtil::Rectangle<s32> viewport_rect{regs.viewport[0].GetRect()}; 705 const MathUtil::Rectangle<s32> viewport_rect{regs.viewport_transform[0].GetRect()};
706 706
707 state.viewport.x = static_cast<GLint>(surfaces_rect.left) + viewport_rect.left * res_scale; 707 state.viewport.x = static_cast<GLint>(surfaces_rect.left) + viewport_rect.left * res_scale;
708 state.viewport.y = static_cast<GLint>(surfaces_rect.bottom) + viewport_rect.bottom * res_scale; 708 state.viewport.y = static_cast<GLint>(surfaces_rect.bottom) + viewport_rect.bottom * res_scale;