SetStencilTest

This commit is contained in:
Isaac Marovitz 2023-07-29 00:30:08 -04:00
parent c376395b24
commit d20878124d
No known key found for this signature in database
GPG Key ID: 97250B2B09A132E1
2 changed files with 30 additions and 1 deletions

View File

@ -387,7 +387,34 @@ namespace Ryujinx.Graphics.Metal
public void SetStencilTest(StencilTestDescriptor stencilTest)
{
// TODO
var depthStencilDescriptor = new MTLDepthStencilDescriptor
{
BackFaceStencil = new MTLStencilDescriptor
{
StencilFailureOperation = stencilTest.BackSFail.Convert(),
DepthFailureOperation = stencilTest.BackDpFail.Convert(),
DepthStencilPassOperation = stencilTest.BackDpPass.Convert(),
StencilCompareFunction = stencilTest.BackFunc.Convert(),
ReadMask = (uint)stencilTest.BackFuncMask,
WriteMask = (uint)stencilTest.BackMask
},
FrontFaceStencil = new MTLStencilDescriptor
{
StencilFailureOperation = stencilTest.FrontSFail.Convert(),
DepthFailureOperation = stencilTest.FrontDpFail.Convert(),
DepthStencilPassOperation = stencilTest.FrontDpPass.Convert(),
StencilCompareFunction = stencilTest.FrontFunc.Convert(),
ReadMask = (uint)stencilTest.FrontFuncMask,
WriteMask = (uint)stencilTest.FrontMask
}
};
var depthStencilState = _device.NewDepthStencilState(depthStencilDescriptor);
if (_currentEncoder is MTLRenderCommandEncoder renderCommandEncoder)
{
renderCommandEncoder.SetDepthStencilState(depthStencilState);
}
}
public void SetStorageBuffers(ReadOnlySpan<BufferAssignment> buffers)

View File

@ -11,6 +11,7 @@ namespace Ryujinx.Graphics.Metal
public PrimitiveTopology Topology = PrimitiveTopology.Triangles;
public MTLCullMode CullMode = MTLCullMode.None;
public MTLWinding Winding = MTLWinding.Clockwise;
public MTLDepthStencilState DepthStencilState = null;
public RenderEncoderState(MTLRenderPipelineState renderPipelineState)
{
@ -22,6 +23,7 @@ namespace Ryujinx.Graphics.Metal
renderCommandEncoder.SetRenderPipelineState(RenderPipelineState);
renderCommandEncoder.SetCullMode(CullMode);
renderCommandEncoder.SetFrontFacingWinding(Winding);
renderCommandEncoder.SetDepthStencilState(DepthStencilState);
}
}
}