From 9435d62206423c1a5056af557135310fc068f84b Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 17 Nov 2020 19:20:17 -0300 Subject: [PATCH] Simplify depth test state updates (#1695) --- Ryujinx.Graphics.OpenGL/Pipeline.cs | 45 +++++++---------------------- 1 file changed, 10 insertions(+), 35 deletions(-) diff --git a/Ryujinx.Graphics.OpenGL/Pipeline.cs b/Ryujinx.Graphics.OpenGL/Pipeline.cs index 5687329102..00ac3a73fa 100644 --- a/Ryujinx.Graphics.OpenGL/Pipeline.cs +++ b/Ryujinx.Graphics.OpenGL/Pipeline.cs @@ -25,8 +25,6 @@ namespace Ryujinx.Graphics.OpenGL private int _stencilFrontMask; private bool _depthMask; - private bool _depthTest; - private bool _hasDepthBuffer; private int _boundDrawFramebuffer; private int _boundReadFramebuffer; @@ -671,12 +669,18 @@ namespace Ryujinx.Graphics.OpenGL public void SetDepthTest(DepthTestDescriptor depthTest) { - GL.DepthFunc((DepthFunction)depthTest.Func.Convert()); + if (depthTest.TestEnable) + { + GL.Enable(EnableCap.DepthTest); + GL.DepthFunc((DepthFunction)depthTest.Func.Convert()); + } + else + { + GL.Disable(EnableCap.DepthTest); + } + GL.DepthMask(depthTest.WriteEnable); _depthMask = depthTest.WriteEnable; - _depthTest = depthTest.TestEnable; - - UpdateDepthTest(); } public void SetFaceCulling(bool enable, Face face) @@ -860,10 +864,6 @@ namespace Ryujinx.Graphics.OpenGL _framebuffer.AttachDepthStencil(depthStencilView); _framebuffer.SetDrawBuffers(colors.Length); - - _hasDepthBuffer = depthStencil != null && depthStencilView.Format != Format.S8Uint; - - UpdateDepthTest(); } public void SetSampler(int binding, ISampler sampler) @@ -1161,31 +1161,6 @@ namespace Ryujinx.Graphics.OpenGL } } - private void UpdateDepthTest() - { - // Enabling depth operations is only valid when we have - // a depth buffer, otherwise it's not allowed. - if (_hasDepthBuffer) - { - if (_depthTest) - { - GL.Enable(EnableCap.DepthTest); - } - else - { - GL.Disable(EnableCap.DepthTest); - } - - GL.DepthMask(_depthMask); - } - else - { - GL.Disable(EnableCap.DepthTest); - - GL.DepthMask(false); - } - } - public void UpdateRenderScale(ShaderStage stage, float[] scales, int textureCount, int imageCount) { if (_program != null)