summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp47
1 files changed, 24 insertions, 23 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 615704711..d94f1e89f 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -214,8 +214,6 @@ void RasterizerOpenGL::Draw(bool is_indexed, bool is_instanced) {
214 214
215 query_cache.UpdateCounters(); 215 query_cache.UpdateCounters();
216 216
217 SyncState();
218
219 GraphicsPipeline* const pipeline{shader_cache.CurrentGraphicsPipeline()}; 217 GraphicsPipeline* const pipeline{shader_cache.CurrentGraphicsPipeline()};
220 if (!pipeline) { 218 if (!pipeline) {
221 return; 219 return;
@@ -223,6 +221,8 @@ void RasterizerOpenGL::Draw(bool is_indexed, bool is_instanced) {
223 std::scoped_lock lock{buffer_cache.mutex, texture_cache.mutex}; 221 std::scoped_lock lock{buffer_cache.mutex, texture_cache.mutex};
224 pipeline->Configure(is_indexed); 222 pipeline->Configure(is_indexed);
225 223
224 SyncState();
225
226 const GLenum primitive_mode = MaxwellToGL::PrimitiveTopology(maxwell3d.regs.draw.topology); 226 const GLenum primitive_mode = MaxwellToGL::PrimitiveTopology(maxwell3d.regs.draw.topology);
227 BeginTransformFeedback(pipeline, primitive_mode); 227 BeginTransformFeedback(pipeline, primitive_mode);
228 228
@@ -554,7 +554,6 @@ void RasterizerOpenGL::SyncViewport() {
554 } 554 }
555 glFrontFace(mode); 555 glFrontFace(mode);
556 } 556 }
557
558 if (dirty_viewport || flags[Dirty::ClipControl]) { 557 if (dirty_viewport || flags[Dirty::ClipControl]) {
559 flags[Dirty::ClipControl] = false; 558 flags[Dirty::ClipControl] = false;
560 559
@@ -571,6 +570,8 @@ void RasterizerOpenGL::SyncViewport() {
571 state_tracker.ClipControl(origin, depth); 570 state_tracker.ClipControl(origin, depth);
572 state_tracker.SetYNegate(regs.screen_y_control.y_negate != 0); 571 state_tracker.SetYNegate(regs.screen_y_control.y_negate != 0);
573 } 572 }
573 const bool is_rescaling{texture_cache.IsRescaling()};
574 const float scale = is_rescaling ? Settings::values.resolution_info.up_factor : 1.0f;
574 575
575 if (dirty_viewport) { 576 if (dirty_viewport) {
576 flags[Dirty::Viewports] = false; 577 flags[Dirty::Viewports] = false;
@@ -579,38 +580,38 @@ void RasterizerOpenGL::SyncViewport() {
579 flags[Dirty::ViewportTransform] = false; 580 flags[Dirty::ViewportTransform] = false;
580 flags[VideoCommon::Dirty::RescaleViewports] = false; 581 flags[VideoCommon::Dirty::RescaleViewports] = false;
581 582
582 const auto& resolution = Settings::values.resolution_info; 583 for (size_t index = 0; index < Maxwell::NumViewports; ++index) {
583 const auto scale_up = [&](u32 value) -> u32 { 584 if (!force && !flags[Dirty::Viewport0 + index]) {
584 if (value == 0) {
585 return 0U;
586 }
587 const u32 converted_value = (value * resolution.up_scale) >> resolution.down_shift;
588 return std::max<u32>(converted_value, 1U);
589 };
590 for (std::size_t i = 0; i < Maxwell::NumViewports; ++i) {
591 if (!force && !flags[Dirty::Viewport0 + i]) {
592 continue; 585 continue;
593 } 586 }
594 flags[Dirty::Viewport0 + i] = false; 587 flags[Dirty::Viewport0 + index] = false;
595 588
596 const auto& src = regs.viewport_transform[i]; 589 const auto& src = regs.viewport_transform[index];
597 const Common::Rectangle<f32> rect{src.GetRect()}; 590 GLfloat x = (src.translate_x - src.scale_x) * scale;
598 glViewportIndexedf(static_cast<GLuint>(i), rect.left, rect.bottom, 591 GLfloat y = (src.translate_y - src.scale_y) * scale;
599 scale_up(rect.GetWidth()), scale_up(rect.GetHeight())); 592 GLfloat width = src.scale_x * 2.0f * scale;
593 GLfloat height = src.scale_y * 2.0f * scale;
594 if (height < 0) {
595 y += height;
596 height = -height;
597 }
598 glViewportIndexedf(static_cast<GLuint>(index), x, y, width != 0.0f ? width : 1.0f,
599 height != 0.0f ? height : 1.0f);
600 600
601 const GLdouble reduce_z = regs.depth_mode == Maxwell::DepthMode::MinusOneToOne; 601 const GLdouble reduce_z = regs.depth_mode == Maxwell::DepthMode::MinusOneToOne;
602 const GLdouble near_depth = src.translate_z - src.scale_z * reduce_z; 602 const GLdouble near_depth = src.translate_z - src.scale_z * reduce_z;
603 const GLdouble far_depth = src.translate_z + src.scale_z; 603 const GLdouble far_depth = src.translate_z + src.scale_z;
604 if (device.HasDepthBufferFloat()) { 604 if (device.HasDepthBufferFloat()) {
605 glDepthRangeIndexeddNV(static_cast<GLuint>(i), near_depth, far_depth); 605 glDepthRangeIndexeddNV(static_cast<GLuint>(index), near_depth, far_depth);
606 } else { 606 } else {
607 glDepthRangeIndexed(static_cast<GLuint>(i), near_depth, far_depth); 607 glDepthRangeIndexed(static_cast<GLuint>(index), near_depth, far_depth);
608 } 608 }
609 609
610 if (!GLAD_GL_NV_viewport_swizzle) { 610 if (!GLAD_GL_NV_viewport_swizzle) {
611 continue; 611 continue;
612 } 612 }
613 glViewportSwizzleNV(static_cast<GLuint>(i), MaxwellToGL::ViewportSwizzle(src.swizzle.x), 613 glViewportSwizzleNV(static_cast<GLuint>(index),
614 MaxwellToGL::ViewportSwizzle(src.swizzle.x),
614 MaxwellToGL::ViewportSwizzle(src.swizzle.y), 615 MaxwellToGL::ViewportSwizzle(src.swizzle.y),
615 MaxwellToGL::ViewportSwizzle(src.swizzle.z), 616 MaxwellToGL::ViewportSwizzle(src.swizzle.z),
616 MaxwellToGL::ViewportSwizzle(src.swizzle.w)); 617 MaxwellToGL::ViewportSwizzle(src.swizzle.w));
@@ -940,7 +941,7 @@ void RasterizerOpenGL::SyncScissorTest() {
940 const auto& src = regs.scissor_test[index]; 941 const auto& src = regs.scissor_test[index];
941 if (src.enable) { 942 if (src.enable) {
942 glEnablei(GL_SCISSOR_TEST, static_cast<GLuint>(index)); 943 glEnablei(GL_SCISSOR_TEST, static_cast<GLuint>(index));
943 glScissorIndexed(static_cast<GLuint>(index), src.min_x, src.min_y, 944 glScissorIndexed(static_cast<GLuint>(index), scale_up(src.min_x), scale_up(src.min_y),
944 scale_up(src.max_x - src.min_x), scale_up(src.max_y - src.min_y)); 945 scale_up(src.max_x - src.min_x), scale_up(src.max_y - src.min_y));
945 } else { 946 } else {
946 glDisablei(GL_SCISSOR_TEST, static_cast<GLuint>(index)); 947 glDisablei(GL_SCISSOR_TEST, static_cast<GLuint>(index));