From 92f950b29060c1aafa397db2e214e96577628598 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Fri, 6 Jul 2018 11:26:40 -0300 Subject: [PATCH] Do not set front face if face culling is not enabled --- Ryujinx.Graphics/Gal/GalFrontFace.cs | 4 +- .../Gal/OpenGL/OGLEnumConverter.cs | 4 +- Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs | 47 ++++++++----------- 3 files changed, 23 insertions(+), 32 deletions(-) diff --git a/Ryujinx.Graphics/Gal/GalFrontFace.cs b/Ryujinx.Graphics/Gal/GalFrontFace.cs index 17ad11267..6cc4a8024 100644 --- a/Ryujinx.Graphics/Gal/GalFrontFace.cs +++ b/Ryujinx.Graphics/Gal/GalFrontFace.cs @@ -2,7 +2,7 @@ { public enum GalFrontFace { - CW = 0x900, - CCW = 0x901 + Cw = 0x900, + Ccw = 0x901 } } \ No newline at end of file diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs index 3a81150d6..29cd9f14c 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs @@ -9,8 +9,8 @@ namespace Ryujinx.Graphics.Gal.OpenGL { switch (FrontFace) { - case GalFrontFace.CW: return FrontFaceDirection.Cw; - case GalFrontFace.CCW: return FrontFaceDirection.Ccw; + case GalFrontFace.Cw: return FrontFaceDirection.Cw; + case GalFrontFace.Ccw: return FrontFaceDirection.Ccw; } throw new ArgumentException(nameof(FrontFace)); diff --git a/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs index e0e769d48..eddedca05 100644 --- a/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs +++ b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs @@ -79,8 +79,7 @@ namespace Ryujinx.HLE.Gpu.Engines Gpu.Renderer.Shader.BindProgram(); - SetFrontFace(); - SetCullFace(); + SetFaceCulling(); SetDepth(); SetStencil(); SetAlphaBlending(); @@ -198,32 +197,7 @@ namespace Ryujinx.HLE.Gpu.Engines throw new ArgumentOutOfRangeException(nameof(Program)); } - private void SetFrontFace() - { - float SignX = GetFlipSign(NvGpuEngine3dReg.ViewportScaleX); - float SignY = GetFlipSign(NvGpuEngine3dReg.ViewportScaleY); - - GalFrontFace FrontFace = (GalFrontFace)ReadRegister(NvGpuEngine3dReg.FrontFace); - - //Flipping breaks facing. Flipping front facing too fixes it - if (SignX != SignY) - { - switch (FrontFace) - { - case GalFrontFace.CW: - FrontFace = GalFrontFace.CCW; - break; - - case GalFrontFace.CCW: - FrontFace = GalFrontFace.CW; - break; - } - } - - Gpu.Renderer.Rasterizer.SetFrontFace(FrontFace); - } - - private void SetCullFace() + private void SetFaceCulling() { bool Enable = (ReadRegister(NvGpuEngine3dReg.CullFaceEnable) & 1) != 0; @@ -241,6 +215,23 @@ namespace Ryujinx.HLE.Gpu.Engines return; } + float SignX = GetFlipSign(NvGpuEngine3dReg.ViewportScaleX); + float SignY = GetFlipSign(NvGpuEngine3dReg.ViewportScaleY); + + GalFrontFace FrontFace = (GalFrontFace)ReadRegister(NvGpuEngine3dReg.FrontFace); + + //Flipping breaks facing. Flipping front facing too fixes it + if (SignX != SignY) + { + switch (FrontFace) + { + case GalFrontFace.Cw: FrontFace = GalFrontFace.Ccw; break; + case GalFrontFace.Ccw: FrontFace = GalFrontFace.Cw; break; + } + } + + Gpu.Renderer.Rasterizer.SetFrontFace(FrontFace); + GalCullFace CullFace = (GalCullFace)ReadRegister(NvGpuEngine3dReg.CullFace); Gpu.Renderer.Rasterizer.SetCullFace(CullFace);