summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-03-27 02:45:10 +0200
committerbunnei <bunneidev@gmail.com>2018-03-27 03:17:04 +0200
commitd30110348b10e1cf9765a5c7cec294a4e076a3af (patch)
treedb63e6bc201e5ad461803b2b13a033d7a6ed7837 /src/video_core/renderer_opengl
parentgl_rasterizer: Move PrimitiveTopology check to MaxwellToGL. (diff)
downloadyuzu-d30110348b10e1cf9765a5c7cec294a4e076a3af.tar
yuzu-d30110348b10e1cf9765a5c7cec294a4e076a3af.tar.gz
yuzu-d30110348b10e1cf9765a5c7cec294a4e076a3af.tar.bz2
yuzu-d30110348b10e1cf9765a5c7cec294a4e076a3af.tar.lz
yuzu-d30110348b10e1cf9765a5c7cec294a4e076a3af.tar.xz
yuzu-d30110348b10e1cf9765a5c7cec294a4e076a3af.tar.zst
yuzu-d30110348b10e1cf9765a5c7cec294a4e076a3af.zip
Diffstat (limited to 'src/video_core/renderer_opengl')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp35
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h3
2 files changed, 20 insertions, 18 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 487d37a26..d83c38cf8 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -228,13 +228,7 @@ void RasterizerOpenGL::DrawArrays() {
const bool has_stencil = false;
const bool using_color_fb = true;
const bool using_depth_fb = false;
-
- MathUtil::Rectangle<s32> viewport_rect_unscaled{
- static_cast<s32>(regs.viewport[0].x), // left
- static_cast<s32>(regs.viewport[0].y + regs.viewport[0].height), // top
- static_cast<s32>(regs.viewport[0].x + regs.viewport[0].width), // right
- static_cast<s32>(regs.viewport[0].y) // bottom
- };
+ const MathUtil::Rectangle<s32> viewport_rect{regs.viewport[0].GetRect()};
const bool write_color_fb =
state.color_mask.red_enabled == GL_TRUE || state.color_mask.green_enabled == GL_TRUE ||
@@ -248,7 +242,7 @@ void RasterizerOpenGL::DrawArrays() {
Surface depth_surface;
MathUtil::Rectangle<u32> surfaces_rect;
std::tie(color_surface, depth_surface, surfaces_rect) =
- res_cache.GetFramebufferSurfaces(using_color_fb, using_depth_fb, viewport_rect_unscaled);
+ res_cache.GetFramebufferSurfaces(using_color_fb, using_depth_fb, viewport_rect);
const u16 res_scale = color_surface != nullptr
? color_surface->res_scale
@@ -256,16 +250,16 @@ void RasterizerOpenGL::DrawArrays() {
MathUtil::Rectangle<u32> draw_rect{
static_cast<u32>(MathUtil::Clamp<s32>(static_cast<s32>(surfaces_rect.left) +
- viewport_rect_unscaled.left * res_scale,
+ viewport_rect.left * res_scale,
surfaces_rect.left, surfaces_rect.right)), // Left
static_cast<u32>(MathUtil::Clamp<s32>(static_cast<s32>(surfaces_rect.bottom) +
- viewport_rect_unscaled.top * res_scale,
+ viewport_rect.top * res_scale,
surfaces_rect.bottom, surfaces_rect.top)), // Top
static_cast<u32>(MathUtil::Clamp<s32>(static_cast<s32>(surfaces_rect.left) +
- viewport_rect_unscaled.right * res_scale,
+ viewport_rect.right * res_scale,
surfaces_rect.left, surfaces_rect.right)), // Right
static_cast<u32>(MathUtil::Clamp<s32>(static_cast<s32>(surfaces_rect.bottom) +
- viewport_rect_unscaled.bottom * res_scale,
+ viewport_rect.bottom * res_scale,
surfaces_rect.bottom, surfaces_rect.top))}; // Bottom
// Bind the framebuffer surfaces
@@ -293,12 +287,7 @@ void RasterizerOpenGL::DrawArrays() {
}
// Sync the viewport
- state.viewport.x =
- static_cast<GLint>(surfaces_rect.left) + viewport_rect_unscaled.left * res_scale;
- state.viewport.y =
- static_cast<GLint>(surfaces_rect.bottom) + viewport_rect_unscaled.bottom * res_scale;
- state.viewport.width = static_cast<GLsizei>(viewport_rect_unscaled.GetWidth() * res_scale);
- state.viewport.height = static_cast<GLsizei>(viewport_rect_unscaled.GetHeight() * res_scale);
+ SyncViewport(surfaces_rect, res_scale);
// TODO(bunnei): Sync framebuffer_scale uniform here
// TODO(bunnei): Sync scissorbox uniform(s) here
@@ -541,6 +530,16 @@ void main() {
}
}
+void RasterizerOpenGL::SyncViewport(const MathUtil::Rectangle<u32>& surfaces_rect, u16 res_scale) {
+ const auto& regs = Core::System().GetInstance().GPU().Maxwell3D().regs;
+ const MathUtil::Rectangle<s32> viewport_rect{regs.viewport[0].GetRect()};
+
+ state.viewport.x = static_cast<GLint>(surfaces_rect.left) + viewport_rect.left * res_scale;
+ state.viewport.y = static_cast<GLint>(surfaces_rect.bottom) + viewport_rect.bottom * res_scale;
+ state.viewport.width = static_cast<GLsizei>(viewport_rect.GetWidth() * res_scale);
+ state.viewport.height = static_cast<GLsizei>(viewport_rect.GetHeight() * res_scale);
+}
+
void RasterizerOpenGL::SyncClipEnabled() {
UNREACHABLE();
}
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index c889b1aff..1cd46c96a 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -87,6 +87,9 @@ public:
private:
struct SamplerInfo {};
+ /// Syncs the viewport to match the guest state
+ void SyncViewport(const MathUtil::Rectangle<u32>& surfaces_rect, u16 res_scale);
+
/// Syncs the clip enabled status to match the guest state
void SyncClipEnabled();