mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2025-08-04 02:02:25 -07:00
SetDepthTest
This commit is contained in:
committed by
Isaac Marovitz
parent
0f52165e86
commit
3d42543f03
@@ -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
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user