Simplify depth test state updates (#1695)

This commit is contained in:
gdkchan 2020-11-17 19:20:17 -03:00 committed by GitHub
parent 5189a807c4
commit 9435d62206
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)
{
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)