summaryrefslogtreecommitdiff
path: root/src/video_core/renderer_opengl
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2019-07-17 19:37:01 -0400
committerGravatar FernandoS272019-07-20 10:18:35 -0400
commit7a35178ee2c8ce60c87654ed2d80cc76abb0380b (patch)
tree514fdc12910bb3b00d7c2df89b9e1882a8586320 /src/video_core/renderer_opengl
parentGL_State: Feedback and fixes (diff)
downloadyuzu-7a35178ee2c8ce60c87654ed2d80cc76abb0380b.tar.gz
yuzu-7a35178ee2c8ce60c87654ed2d80cc76abb0380b.tar.xz
yuzu-7a35178ee2c8ce60c87654ed2d80cc76abb0380b.zip
Maxwell3D: Reorganize and address feedback
Diffstat (limited to 'src/video_core/renderer_opengl')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp45
1 files changed, 27 insertions, 18 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index d1ae8a7c5..0432a9e10 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -993,37 +993,42 @@ void RasterizerOpenGL::SyncCullMode() {
993 const auto& regs = maxwell3d.regs; 993 const auto& regs = maxwell3d.regs;
994 994
995 state.cull.enabled = regs.cull.enabled != 0; 995 state.cull.enabled = regs.cull.enabled != 0;
996 state.cull.front_face = MaxwellToGL::FrontFace(regs.cull.front_face); 996 if (state.cull.enabled) {
997 state.cull.mode = MaxwellToGL::CullFace(regs.cull.cull_face); 997 state.cull.front_face = MaxwellToGL::FrontFace(regs.cull.front_face);
998 998 state.cull.mode = MaxwellToGL::CullFace(regs.cull.cull_face);
999 const bool flip_triangles{regs.screen_y_control.triangle_rast_flip == 0 || 999
1000 regs.viewport_transform[0].scale_y < 0.0f}; 1000 const bool flip_triangles{regs.screen_y_control.triangle_rast_flip == 0 ||
1001 1001 regs.viewport_transform[0].scale_y < 0.0f};
1002 // If the GPU is configured to flip the rasterized triangles, then we need to flip the 1002
1003 // notion of front and back. Note: We flip the triangles when the value of the register is 0 1003 // If the GPU is configured to flip the rasterized triangles, then we need to flip the
1004 // because OpenGL already does it for us. 1004 // notion of front and back. Note: We flip the triangles when the value of the register is 0
1005 if (flip_triangles) { 1005 // because OpenGL already does it for us.
1006 if (state.cull.front_face == GL_CCW) 1006 if (flip_triangles) {
1007 state.cull.front_face = GL_CW; 1007 if (state.cull.front_face == GL_CCW)
1008 else if (state.cull.front_face == GL_CW) 1008 state.cull.front_face = GL_CW;
1009 state.cull.front_face = GL_CCW; 1009 else if (state.cull.front_face == GL_CW)
1010 state.cull.front_face = GL_CCW;
1011 }
1010 } 1012 }
1011} 1013}
1012 1014
1013void RasterizerOpenGL::SyncPrimitiveRestart() { 1015void RasterizerOpenGL::SyncPrimitiveRestart() {
1014 auto& maxwell3d = system.GPU().Maxwell3D(); 1016 const auto& regs = system.GPU().Maxwell3D().regs;
1015 const auto& regs = maxwell3d.regs;
1016 1017
1017 state.primitive_restart.enabled = regs.primitive_restart.enabled; 1018 state.primitive_restart.enabled = regs.primitive_restart.enabled;
1018 state.primitive_restart.index = regs.primitive_restart.index; 1019 state.primitive_restart.index = regs.primitive_restart.index;
1019} 1020}
1020 1021
1021void RasterizerOpenGL::SyncDepthTestState() { 1022void RasterizerOpenGL::SyncDepthTestState() {
1022 auto& maxwell3d = system.GPU().Maxwell3D(); 1023 const auto& regs = system.GPU().Maxwell3D().regs;
1023 const auto& regs = maxwell3d.regs;
1024 1024
1025 state.depth.test_enabled = regs.depth_test_enable != 0; 1025 state.depth.test_enabled = regs.depth_test_enable != 0;
1026 state.depth.write_mask = regs.depth_write_enabled ? GL_TRUE : GL_FALSE; 1026 state.depth.write_mask = regs.depth_write_enabled ? GL_TRUE : GL_FALSE;
1027
1028 if (!state.depth.test_enabled) {
1029 return;
1030 }
1031
1027 state.depth.test_func = MaxwellToGL::ComparisonOp(regs.depth_test_func); 1032 state.depth.test_func = MaxwellToGL::ComparisonOp(regs.depth_test_func);
1028} 1033}
1029 1034
@@ -1035,6 +1040,10 @@ void RasterizerOpenGL::SyncStencilTestState() {
1035 const auto& regs = maxwell3d.regs; 1040 const auto& regs = maxwell3d.regs;
1036 1041
1037 state.stencil.test_enabled = regs.stencil_enable != 0; 1042 state.stencil.test_enabled = regs.stencil_enable != 0;
1043 if (!regs.stencil_enable) {
1044 return;
1045 }
1046
1038 state.stencil.front.test_func = MaxwellToGL::ComparisonOp(regs.stencil_front_func_func); 1047 state.stencil.front.test_func = MaxwellToGL::ComparisonOp(regs.stencil_front_func_func);
1039 state.stencil.front.test_ref = regs.stencil_front_func_ref; 1048 state.stencil.front.test_ref = regs.stencil_front_func_ref;
1040 state.stencil.front.test_mask = regs.stencil_front_func_mask; 1049 state.stencil.front.test_mask = regs.stencil_front_func_mask;