SetDepthTest

This commit is contained in:
Isaac Marovitz
2023-07-29 00:46:13 -04:00
committed by Isaac Marovitz
parent 0f52165e86
commit 3d42543f03
2 changed files with 68 additions and 25 deletions

View File

@@ -7,14 +7,24 @@ namespace Ryujinx.Graphics.Metal
[SupportedOSPlatform("macos")]
struct RenderEncoderState
{
private MTLDevice _device;
private MTLDepthStencilState _depthStencilState = null;
private MTLCompareFunction _depthCompareFunction = MTLCompareFunction.Always;
private bool _depthWriteEnabled = false;
private MTLStencilDescriptor _backFaceStencil = null;
private MTLStencilDescriptor _frontFaceStencil = null;
public MTLRenderPipelineState RenderPipelineState;
public PrimitiveTopology Topology = PrimitiveTopology.Triangles;
public MTLCullMode CullMode = MTLCullMode.None;
public MTLWinding Winding = MTLWinding.Clockwise;
public MTLDepthStencilState DepthStencilState = null;
public RenderEncoderState(MTLRenderPipelineState renderPipelineState)
public RenderEncoderState(MTLRenderPipelineState renderPipelineState, MTLDevice device)
{
_device = device;
RenderPipelineState = renderPipelineState;
}
@@ -23,7 +33,35 @@ namespace Ryujinx.Graphics.Metal
renderCommandEncoder.SetRenderPipelineState(RenderPipelineState);
renderCommandEncoder.SetCullMode(CullMode);
renderCommandEncoder.SetFrontFacingWinding(Winding);
renderCommandEncoder.SetDepthStencilState(DepthStencilState);
renderCommandEncoder.SetDepthStencilState(_depthStencilState);
}
public MTLDepthStencilState UpdateStencilState(MTLStencilDescriptor backFace, MTLStencilDescriptor frontFace)
{
_backFaceStencil = backFace;
_frontFaceStencil = frontFace;
return _depthStencilState = _device.NewDepthStencilState(new MTLDepthStencilDescriptor
{
DepthCompareFunction = _depthCompareFunction,
DepthWriteEnabled = _depthWriteEnabled,
BackFaceStencil = _backFaceStencil,
FrontFaceStencil = _frontFaceStencil
});
}
public MTLDepthStencilState UpdateDepthState(MTLCompareFunction depthCompareFunction, bool depthWriteEnabled)
{
_depthCompareFunction = depthCompareFunction;
_depthWriteEnabled = depthWriteEnabled;
return _depthStencilState = _device.NewDepthStencilState(new MTLDepthStencilDescriptor
{
DepthCompareFunction = _depthCompareFunction,
DepthWriteEnabled = _depthWriteEnabled,
BackFaceStencil = _backFaceStencil,
FrontFaceStencil = _frontFaceStencil
});
}
}
}