summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Subv2018-07-04 10:26:46 -0500
committerGravatar Subv2018-07-04 10:26:46 -0500
commitc1bebdef5e11558d27dd9aa60525b47c20598491 (patch)
tree1c5e8b100f41d3362de6e8b8f0d5db2f4aa7fd8d
parentMerge pull request #618 from Subv/clear_used_buffers (diff)
downloadyuzu-c1bebdef5e11558d27dd9aa60525b47c20598491.tar.gz
yuzu-c1bebdef5e11558d27dd9aa60525b47c20598491.tar.xz
yuzu-c1bebdef5e11558d27dd9aa60525b47c20598491.zip
GPU: Flip the triangle front face winding if the GPU is configured to not flip the triangles.
OpenGL's default behavior is already correct when the GPU is configured to flip the triangles. This fixes 1-2 Switch's splash screen.
-rw-r--r--src/video_core/engines/maxwell_3d.h22
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp10
2 files changed, 29 insertions, 3 deletions
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index 988a6433e..cc1f90de6 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -478,7 +478,9 @@ public:
478 478
479 u32 depth_write_enabled; 479 u32 depth_write_enabled;
480 480
481 INSERT_PADDING_WORDS(0x8); 481 INSERT_PADDING_WORDS(0x7);
482
483 u32 d3d_cull_mode;
482 484
483 BitField<0, 3, ComparisonOp> depth_test_func; 485 BitField<0, 3, ComparisonOp> depth_test_func;
484 486
@@ -498,7 +500,13 @@ public:
498 u32 enable[NumRenderTargets]; 500 u32 enable[NumRenderTargets];
499 } blend; 501 } blend;
500 502
501 INSERT_PADDING_WORDS(0x2D); 503 INSERT_PADDING_WORDS(0xB);
504
505 union {
506 BitField<4, 1, u32> triangle_rast_flip;
507 } screen_y_control;
508
509 INSERT_PADDING_WORDS(0x21);
502 510
503 u32 vb_element_base; 511 u32 vb_element_base;
504 512
@@ -528,7 +536,12 @@ public:
528 } 536 }
529 } tic; 537 } tic;
530 538
531 INSERT_PADDING_WORDS(0x22); 539 INSERT_PADDING_WORDS(0x21);
540
541 union {
542 BitField<2, 1, u32> coord_origin;
543 BitField<3, 10, u32> enable;
544 } point_coord_replace;
532 545
533 struct { 546 struct {
534 u32 code_address_high; 547 u32 code_address_high;
@@ -818,11 +831,14 @@ ASSERT_REG_POSITION(rt_control, 0x487);
818ASSERT_REG_POSITION(depth_test_enable, 0x4B3); 831ASSERT_REG_POSITION(depth_test_enable, 0x4B3);
819ASSERT_REG_POSITION(independent_blend_enable, 0x4B9); 832ASSERT_REG_POSITION(independent_blend_enable, 0x4B9);
820ASSERT_REG_POSITION(depth_write_enabled, 0x4BA); 833ASSERT_REG_POSITION(depth_write_enabled, 0x4BA);
834ASSERT_REG_POSITION(d3d_cull_mode, 0x4C2);
821ASSERT_REG_POSITION(depth_test_func, 0x4C3); 835ASSERT_REG_POSITION(depth_test_func, 0x4C3);
822ASSERT_REG_POSITION(blend, 0x4CF); 836ASSERT_REG_POSITION(blend, 0x4CF);
837ASSERT_REG_POSITION(screen_y_control, 0x4EB);
823ASSERT_REG_POSITION(vb_element_base, 0x50D); 838ASSERT_REG_POSITION(vb_element_base, 0x50D);
824ASSERT_REG_POSITION(tsc, 0x557); 839ASSERT_REG_POSITION(tsc, 0x557);
825ASSERT_REG_POSITION(tic, 0x55D); 840ASSERT_REG_POSITION(tic, 0x55D);
841ASSERT_REG_POSITION(point_coord_replace, 0x581);
826ASSERT_REG_POSITION(code_address, 0x582); 842ASSERT_REG_POSITION(code_address, 0x582);
827ASSERT_REG_POSITION(draw, 0x585); 843ASSERT_REG_POSITION(draw, 0x585);
828ASSERT_REG_POSITION(index_array, 0x5F2); 844ASSERT_REG_POSITION(index_array, 0x5F2);
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index e516eb1ad..3c3657d9d 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -771,6 +771,16 @@ void RasterizerOpenGL::SyncCullMode() {
771 if (state.cull.enabled) { 771 if (state.cull.enabled) {
772 state.cull.front_face = MaxwellToGL::FrontFace(regs.cull.front_face); 772 state.cull.front_face = MaxwellToGL::FrontFace(regs.cull.front_face);
773 state.cull.mode = MaxwellToGL::CullFace(regs.cull.cull_face); 773 state.cull.mode = MaxwellToGL::CullFace(regs.cull.cull_face);
774
775 // If the GPU is configured to flip the rasterized triangles, then we need to flip the
776 // notion of front and back. Note: We flip the triangles when the value of the register is 0
777 // because OpenGL already does it for us.
778 if (regs.screen_y_control.triangle_rast_flip == 0) {
779 if (state.cull.front_face == GL_CCW)
780 state.cull.front_face = GL_CW;
781 else if (state.cull.front_face == GL_CW)
782 state.cull.front_face = GL_CCW;
783 }
774 } 784 }
775} 785}
776 786