Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dtatarnikov committed Jul 6, 2023
1 parent 36a1b08 commit f5c5a34
Showing 1 changed file with 39 additions and 12 deletions.
51 changes: 39 additions & 12 deletions src/Veldrid/OpenGL/OpenGLCommandExecutor.cs
Expand Up @@ -94,28 +94,55 @@ public void ClearColorTarget(uint index, RgbaFloat clearColor)

public void ClearDepthStencil(float depth, byte stencil)
{
glClearDepth_Compat(depth);
CheckLastError();
if (_graphicsPipeline != null)
{
if (!_graphicsPipeline.DepthStencilState.DepthWriteEnabled)
{
glDepthMask(true);
CheckLastError();
}

if (_graphicsPipeline.DepthStencilState.StencilWriteMask != 0xFF)
{
glStencilMask(0xFF);
CheckLastError();
}

glStencilMask(~0u);
if (_graphicsPipeline.RasterizerState.ScissorTestEnabled)
{
glDisable(EnableCap.ScissorTest);
CheckLastError();
}
}

glClearDepth_Compat(depth);
CheckLastError();

glClearStencil(stencil);
CheckLastError();

if (_graphicsPipeline != null && _graphicsPipeline.RasterizerState.ScissorTestEnabled)
{
glDisable(EnableCap.ScissorTest);
CheckLastError();
}

glDepthMask(true);
glClear(ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit);
CheckLastError();

if (_graphicsPipeline != null && _graphicsPipeline.RasterizerState.ScissorTestEnabled)
if (_graphicsPipeline != null)
{
glEnable(EnableCap.ScissorTest);
if (!_graphicsPipeline.DepthStencilState.DepthWriteEnabled)
{
glDepthMask(false);
CheckLastError();
}

if (_graphicsPipeline.DepthStencilState.StencilWriteMask != 0xFF)
{
glStencilMask(_graphicsPipeline.DepthStencilState.StencilWriteMask);
CheckLastError();
}

if (_graphicsPipeline.RasterizerState.ScissorTestEnabled)
{
glEnable(EnableCap.ScissorTest);
CheckLastError();
}
}
}

Expand Down

0 comments on commit f5c5a34

Please sign in to comment.