summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl/gl_rasterizer.cpp
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2019-07-18 01:37:01 +0200
committerFernandoS27 <fsahmkow27@gmail.com>2019-07-20 16:18:35 +0200
commit7a35178ee2c8ce60c87654ed2d80cc76abb0380b (patch)
tree514fdc12910bb3b00d7c2df89b9e1882a8586320 /src/video_core/renderer_opengl/gl_rasterizer.cpp
parentGL_State: Feedback and fixes (diff)
downloadyuzu-7a35178ee2c8ce60c87654ed2d80cc76abb0380b.tar
yuzu-7a35178ee2c8ce60c87654ed2d80cc76abb0380b.tar.gz
yuzu-7a35178ee2c8ce60c87654ed2d80cc76abb0380b.tar.bz2
yuzu-7a35178ee2c8ce60c87654ed2d80cc76abb0380b.tar.lz
yuzu-7a35178ee2c8ce60c87654ed2d80cc76abb0380b.tar.xz
yuzu-7a35178ee2c8ce60c87654ed2d80cc76abb0380b.tar.zst
yuzu-7a35178ee2c8ce60c87654ed2d80cc76abb0380b.zip
Diffstat (limited to 'src/video_core/renderer_opengl/gl_rasterizer.cpp')
-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() {
const auto& regs = maxwell3d.regs;
state.cull.enabled = regs.cull.enabled != 0;
- state.cull.front_face = MaxwellToGL::FrontFace(regs.cull.front_face);
- state.cull.mode = MaxwellToGL::CullFace(regs.cull.cull_face);
-
- const bool flip_triangles{regs.screen_y_control.triangle_rast_flip == 0 ||
- regs.viewport_transform[0].scale_y < 0.0f};
-
- // If the GPU is configured to flip the rasterized triangles, then we need to flip the
- // notion of front and back. Note: We flip the triangles when the value of the register is 0
- // because OpenGL already does it for us.
- if (flip_triangles) {
- if (state.cull.front_face == GL_CCW)
- state.cull.front_face = GL_CW;
- else if (state.cull.front_face == GL_CW)
- state.cull.front_face = GL_CCW;
+ if (state.cull.enabled) {
+ state.cull.front_face = MaxwellToGL::FrontFace(regs.cull.front_face);
+ state.cull.mode = MaxwellToGL::CullFace(regs.cull.cull_face);
+
+ const bool flip_triangles{regs.screen_y_control.triangle_rast_flip == 0 ||
+ regs.viewport_transform[0].scale_y < 0.0f};
+
+ // If the GPU is configured to flip the rasterized triangles, then we need to flip the
+ // notion of front and back. Note: We flip the triangles when the value of the register is 0
+ // because OpenGL already does it for us.
+ if (flip_triangles) {
+ if (state.cull.front_face == GL_CCW)
+ state.cull.front_face = GL_CW;
+ else if (state.cull.front_face == GL_CW)
+ state.cull.front_face = GL_CCW;
+ }
}
}
void RasterizerOpenGL::SyncPrimitiveRestart() {
- auto& maxwell3d = system.GPU().Maxwell3D();
- const auto& regs = maxwell3d.regs;
+ const auto& regs = system.GPU().Maxwell3D().regs;
state.primitive_restart.enabled = regs.primitive_restart.enabled;
state.primitive_restart.index = regs.primitive_restart.index;
}
void RasterizerOpenGL::SyncDepthTestState() {
- auto& maxwell3d = system.GPU().Maxwell3D();
- const auto& regs = maxwell3d.regs;
+ const auto& regs = system.GPU().Maxwell3D().regs;
state.depth.test_enabled = regs.depth_test_enable != 0;
state.depth.write_mask = regs.depth_write_enabled ? GL_TRUE : GL_FALSE;
+
+ if (!state.depth.test_enabled) {
+ return;
+ }
+
state.depth.test_func = MaxwellToGL::ComparisonOp(regs.depth_test_func);
}
@@ -1035,6 +1040,10 @@ void RasterizerOpenGL::SyncStencilTestState() {
const auto& regs = maxwell3d.regs;
state.stencil.test_enabled = regs.stencil_enable != 0;
+ if (!regs.stencil_enable) {
+ return;
+ }
+
state.stencil.front.test_func = MaxwellToGL::ComparisonOp(regs.stencil_front_func_func);
state.stencil.front.test_ref = regs.stencil_front_func_ref;
state.stencil.front.test_mask = regs.stencil_front_func_mask;