From cb913e5c02ab1ae004062308ef7ecf97419ad19a Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 4 Apr 2022 10:04:10 -0400 Subject: [PATCH 1/2] OpenGL: flip front faces if Z scale is inverted --- src/video_core/renderer_opengl/gl_rasterizer.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index e6f9ece8b..216139173 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -561,8 +561,9 @@ void RasterizerOpenGL::SyncViewport() { flags[Dirty::FrontFace] = false; GLenum mode = MaxwellToGL::FrontFace(regs.front_face); - if (regs.screen_y_control.triangle_rast_flip != 0 && - regs.viewport_transform[0].scale_y < 0.0f) { + if ((regs.screen_y_control.triangle_rast_flip != 0 && + regs.viewport_transform[0].scale_y < 0.0f) || + regs.viewport_transform[0].scale_z < 0.0f) { switch (mode) { case GL_CW: mode = GL_CCW; From a57531854e8eeeab65287083e4cdfe37c4e77bf9 Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 4 Apr 2022 10:30:48 -0400 Subject: [PATCH 2/2] OpenGL: propagate face flip condition --- src/video_core/renderer_opengl/gl_rasterizer.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 216139173..5fa2febb4 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -557,13 +557,19 @@ void RasterizerOpenGL::SyncViewport() { const bool dirty_viewport = flags[Dirty::Viewports] || rescale_viewports; const bool dirty_clip_control = flags[Dirty::ClipControl]; - if (dirty_clip_control || flags[Dirty::FrontFace]) { + if (dirty_viewport || dirty_clip_control || flags[Dirty::FrontFace]) { flags[Dirty::FrontFace] = false; GLenum mode = MaxwellToGL::FrontFace(regs.front_face); - if ((regs.screen_y_control.triangle_rast_flip != 0 && - regs.viewport_transform[0].scale_y < 0.0f) || - regs.viewport_transform[0].scale_z < 0.0f) { + bool flip_faces = false; + if (regs.screen_y_control.triangle_rast_flip != 0 && + regs.viewport_transform[0].scale_y < 0.0f) { + flip_faces = !flip_faces; + } + if (regs.viewport_transform[0].scale_z < 0.0f) { + flip_faces = !flip_faces; + } + if (flip_faces) { switch (mode) { case GL_CW: mode = GL_CCW;