diff options
| author | 2018-03-26 20:45:10 -0400 | |
|---|---|---|
| committer | 2018-03-26 21:17:04 -0400 | |
| commit | d30110348b10e1cf9765a5c7cec294a4e076a3af (patch) | |
| tree | db63e6bc201e5ad461803b2b13a033d7a6ed7837 /src | |
| parent | gl_rasterizer: Move PrimitiveTopology check to MaxwellToGL. (diff) | |
| download | yuzu-d30110348b10e1cf9765a5c7cec294a4e076a3af.tar.gz yuzu-d30110348b10e1cf9765a5c7cec294a4e076a3af.tar.xz yuzu-d30110348b10e1cf9765a5c7cec294a4e076a3af.zip | |
gl_rasterizer: Add a SyncViewport method.
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/engines/maxwell_3d.h | 10 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 35 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 3 |
3 files changed, 30 insertions, 18 deletions
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index 0e1ae5912..3066bc606 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include "common/bit_field.h" | 11 | #include "common/bit_field.h" |
| 12 | #include "common/common_funcs.h" | 12 | #include "common/common_funcs.h" |
| 13 | #include "common/common_types.h" | 13 | #include "common/common_types.h" |
| 14 | #include "common/math_util.h" | ||
| 14 | #include "video_core/gpu.h" | 15 | #include "video_core/gpu.h" |
| 15 | #include "video_core/memory_manager.h" | 16 | #include "video_core/memory_manager.h" |
| 16 | #include "video_core/textures/texture.h" | 17 | #include "video_core/textures/texture.h" |
| @@ -281,6 +282,15 @@ public: | |||
| 281 | }; | 282 | }; |
| 282 | float depth_range_near; | 283 | float depth_range_near; |
| 283 | float depth_range_far; | 284 | float depth_range_far; |
| 285 | |||
| 286 | MathUtil::Rectangle<s32> GetRect() const { | ||
| 287 | return { | ||
| 288 | static_cast<s32>(x), // left | ||
| 289 | static_cast<s32>(y + height), // top | ||
| 290 | static_cast<s32>(x + width), // right | ||
| 291 | static_cast<s32>(y) // bottom | ||
| 292 | }; | ||
| 293 | }; | ||
| 284 | } viewport[NumViewports]; | 294 | } viewport[NumViewports]; |
| 285 | 295 | ||
| 286 | INSERT_PADDING_WORDS(0x1D); | 296 | 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 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() { | |||
| 228 | const bool has_stencil = false; | 228 | const bool has_stencil = false; |
| 229 | const bool using_color_fb = true; | 229 | const bool using_color_fb = true; |
| 230 | const bool using_depth_fb = false; | 230 | const bool using_depth_fb = false; |
| 231 | 231 | const MathUtil::Rectangle<s32> viewport_rect{regs.viewport[0].GetRect()}; | |
| 232 | MathUtil::Rectangle<s32> viewport_rect_unscaled{ | ||
| 233 | static_cast<s32>(regs.viewport[0].x), // left | ||
| 234 | static_cast<s32>(regs.viewport[0].y + regs.viewport[0].height), // top | ||
| 235 | static_cast<s32>(regs.viewport[0].x + regs.viewport[0].width), // right | ||
| 236 | static_cast<s32>(regs.viewport[0].y) // bottom | ||
| 237 | }; | ||
| 238 | 232 | ||
| 239 | const bool write_color_fb = | 233 | const bool write_color_fb = |
| 240 | state.color_mask.red_enabled == GL_TRUE || state.color_mask.green_enabled == GL_TRUE || | 234 | state.color_mask.red_enabled == GL_TRUE || state.color_mask.green_enabled == GL_TRUE || |
| @@ -248,7 +242,7 @@ void RasterizerOpenGL::DrawArrays() { | |||
| 248 | Surface depth_surface; | 242 | Surface depth_surface; |
| 249 | MathUtil::Rectangle<u32> surfaces_rect; | 243 | MathUtil::Rectangle<u32> surfaces_rect; |
| 250 | std::tie(color_surface, depth_surface, surfaces_rect) = | 244 | std::tie(color_surface, depth_surface, surfaces_rect) = |
| 251 | res_cache.GetFramebufferSurfaces(using_color_fb, using_depth_fb, viewport_rect_unscaled); | 245 | res_cache.GetFramebufferSurfaces(using_color_fb, using_depth_fb, viewport_rect); |
| 252 | 246 | ||
| 253 | const u16 res_scale = color_surface != nullptr | 247 | const u16 res_scale = color_surface != nullptr |
| 254 | ? color_surface->res_scale | 248 | ? color_surface->res_scale |
| @@ -256,16 +250,16 @@ void RasterizerOpenGL::DrawArrays() { | |||
| 256 | 250 | ||
| 257 | MathUtil::Rectangle<u32> draw_rect{ | 251 | MathUtil::Rectangle<u32> draw_rect{ |
| 258 | static_cast<u32>(MathUtil::Clamp<s32>(static_cast<s32>(surfaces_rect.left) + | 252 | static_cast<u32>(MathUtil::Clamp<s32>(static_cast<s32>(surfaces_rect.left) + |
| 259 | viewport_rect_unscaled.left * res_scale, | 253 | viewport_rect.left * res_scale, |
| 260 | surfaces_rect.left, surfaces_rect.right)), // Left | 254 | surfaces_rect.left, surfaces_rect.right)), // Left |
| 261 | static_cast<u32>(MathUtil::Clamp<s32>(static_cast<s32>(surfaces_rect.bottom) + | 255 | static_cast<u32>(MathUtil::Clamp<s32>(static_cast<s32>(surfaces_rect.bottom) + |
| 262 | viewport_rect_unscaled.top * res_scale, | 256 | viewport_rect.top * res_scale, |
| 263 | surfaces_rect.bottom, surfaces_rect.top)), // Top | 257 | surfaces_rect.bottom, surfaces_rect.top)), // Top |
| 264 | static_cast<u32>(MathUtil::Clamp<s32>(static_cast<s32>(surfaces_rect.left) + | 258 | static_cast<u32>(MathUtil::Clamp<s32>(static_cast<s32>(surfaces_rect.left) + |
| 265 | viewport_rect_unscaled.right * res_scale, | 259 | viewport_rect.right * res_scale, |
| 266 | surfaces_rect.left, surfaces_rect.right)), // Right | 260 | surfaces_rect.left, surfaces_rect.right)), // Right |
| 267 | static_cast<u32>(MathUtil::Clamp<s32>(static_cast<s32>(surfaces_rect.bottom) + | 261 | static_cast<u32>(MathUtil::Clamp<s32>(static_cast<s32>(surfaces_rect.bottom) + |
| 268 | viewport_rect_unscaled.bottom * res_scale, | 262 | viewport_rect.bottom * res_scale, |
| 269 | surfaces_rect.bottom, surfaces_rect.top))}; // Bottom | 263 | surfaces_rect.bottom, surfaces_rect.top))}; // Bottom |
| 270 | 264 | ||
| 271 | // Bind the framebuffer surfaces | 265 | // Bind the framebuffer surfaces |
| @@ -293,12 +287,7 @@ void RasterizerOpenGL::DrawArrays() { | |||
| 293 | } | 287 | } |
| 294 | 288 | ||
| 295 | // Sync the viewport | 289 | // Sync the viewport |
| 296 | state.viewport.x = | 290 | SyncViewport(surfaces_rect, res_scale); |
| 297 | static_cast<GLint>(surfaces_rect.left) + viewport_rect_unscaled.left * res_scale; | ||
| 298 | state.viewport.y = | ||
| 299 | static_cast<GLint>(surfaces_rect.bottom) + viewport_rect_unscaled.bottom * res_scale; | ||
| 300 | state.viewport.width = static_cast<GLsizei>(viewport_rect_unscaled.GetWidth() * res_scale); | ||
| 301 | state.viewport.height = static_cast<GLsizei>(viewport_rect_unscaled.GetHeight() * res_scale); | ||
| 302 | 291 | ||
| 303 | // TODO(bunnei): Sync framebuffer_scale uniform here | 292 | // TODO(bunnei): Sync framebuffer_scale uniform here |
| 304 | // TODO(bunnei): Sync scissorbox uniform(s) here | 293 | // TODO(bunnei): Sync scissorbox uniform(s) here |
| @@ -541,6 +530,16 @@ void main() { | |||
| 541 | } | 530 | } |
| 542 | } | 531 | } |
| 543 | 532 | ||
| 533 | void RasterizerOpenGL::SyncViewport(const MathUtil::Rectangle<u32>& surfaces_rect, u16 res_scale) { | ||
| 534 | const auto& regs = Core::System().GetInstance().GPU().Maxwell3D().regs; | ||
| 535 | const MathUtil::Rectangle<s32> viewport_rect{regs.viewport[0].GetRect()}; | ||
| 536 | |||
| 537 | state.viewport.x = static_cast<GLint>(surfaces_rect.left) + viewport_rect.left * res_scale; | ||
| 538 | state.viewport.y = static_cast<GLint>(surfaces_rect.bottom) + viewport_rect.bottom * res_scale; | ||
| 539 | state.viewport.width = static_cast<GLsizei>(viewport_rect.GetWidth() * res_scale); | ||
| 540 | state.viewport.height = static_cast<GLsizei>(viewport_rect.GetHeight() * res_scale); | ||
| 541 | } | ||
| 542 | |||
| 544 | void RasterizerOpenGL::SyncClipEnabled() { | 543 | void RasterizerOpenGL::SyncClipEnabled() { |
| 545 | UNREACHABLE(); | 544 | UNREACHABLE(); |
| 546 | } | 545 | } |
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: | |||
| 87 | private: | 87 | private: |
| 88 | struct SamplerInfo {}; | 88 | struct SamplerInfo {}; |
| 89 | 89 | ||
| 90 | /// Syncs the viewport to match the guest state | ||
| 91 | void SyncViewport(const MathUtil::Rectangle<u32>& surfaces_rect, u16 res_scale); | ||
| 92 | |||
| 90 | /// Syncs the clip enabled status to match the guest state | 93 | /// Syncs the clip enabled status to match the guest state |
| 91 | void SyncClipEnabled(); | 94 | void SyncClipEnabled(); |
| 92 | 95 | ||