Simplify depth test state updates (#1695)
This commit is contained in:
parent
5189a807c4
commit
9435d62206
1 changed files with 10 additions and 35 deletions
|
@ -25,8 +25,6 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
|
|
||||||
private int _stencilFrontMask;
|
private int _stencilFrontMask;
|
||||||
private bool _depthMask;
|
private bool _depthMask;
|
||||||
private bool _depthTest;
|
|
||||||
private bool _hasDepthBuffer;
|
|
||||||
|
|
||||||
private int _boundDrawFramebuffer;
|
private int _boundDrawFramebuffer;
|
||||||
private int _boundReadFramebuffer;
|
private int _boundReadFramebuffer;
|
||||||
|
@ -671,12 +669,18 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
|
|
||||||
public void SetDepthTest(DepthTestDescriptor depthTest)
|
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;
|
_depthMask = depthTest.WriteEnable;
|
||||||
_depthTest = depthTest.TestEnable;
|
|
||||||
|
|
||||||
UpdateDepthTest();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetFaceCulling(bool enable, Face face)
|
public void SetFaceCulling(bool enable, Face face)
|
||||||
|
@ -860,10 +864,6 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
|
|
||||||
_framebuffer.AttachDepthStencil(depthStencilView);
|
_framebuffer.AttachDepthStencil(depthStencilView);
|
||||||
_framebuffer.SetDrawBuffers(colors.Length);
|
_framebuffer.SetDrawBuffers(colors.Length);
|
||||||
|
|
||||||
_hasDepthBuffer = depthStencil != null && depthStencilView.Format != Format.S8Uint;
|
|
||||||
|
|
||||||
UpdateDepthTest();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetSampler(int binding, ISampler sampler)
|
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)
|
public void UpdateRenderScale(ShaderStage stage, float[] scales, int textureCount, int imageCount)
|
||||||
{
|
{
|
||||||
if (_program != null)
|
if (_program != null)
|
||||||
|
|
Reference in a new issue