aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2020-11-17 19:20:17 -0300
committerGitHub <noreply@github.com>2020-11-17 23:20:17 +0100
commit9435d62206423c1a5056af557135310fc068f84b (patch)
tree26156cb1754297a9b23735eaa9efa12b518d1764
parent5189a807c45722e3ed9173dd90ed87a4606d1a89 (diff)
Simplify depth test state updates (#1695)
-rw-r--r--Ryujinx.Graphics.OpenGL/Pipeline.cs45
1 files changed, 10 insertions, 35 deletions
diff --git a/Ryujinx.Graphics.OpenGL/Pipeline.cs b/Ryujinx.Graphics.OpenGL/Pipeline.cs
index 56873291..00ac3a73 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)