1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2025-02-19 06:45:45 +00:00
Ryujinx/src/Ryujinx.Graphics.Metal/RenderEncoderState.cs

68 lines
2.5 KiB
C#
Raw Normal View History

2023-07-28 16:23:13 -04:00
using Ryujinx.Graphics.GAL;
using SharpMetal.Metal;
using System.Runtime.Versioning;
namespace Ryujinx.Graphics.Metal
{
[SupportedOSPlatform("macos")]
struct RenderEncoderState
{
2023-07-29 00:46:13 -04:00
private MTLDevice _device;
private MTLDepthStencilState _depthStencilState = null;
private MTLCompareFunction _depthCompareFunction = MTLCompareFunction.Always;
private bool _depthWriteEnabled = false;
private MTLStencilDescriptor _backFaceStencil = null;
private MTLStencilDescriptor _frontFaceStencil = null;
2023-08-02 19:56:59 -04:00
public MTLRenderPipelineState CopyPipeline;
2023-07-28 16:23:13 -04:00
public PrimitiveTopology Topology = PrimitiveTopology.Triangles;
public MTLCullMode CullMode = MTLCullMode.None;
public MTLWinding Winding = MTLWinding.Clockwise;
2023-08-02 19:56:59 -04:00
public RenderEncoderState(MTLRenderPipelineState copyPipeline, MTLDevice device)
2023-07-28 16:23:13 -04:00
{
2023-07-29 00:46:13 -04:00
_device = device;
2023-08-02 19:56:59 -04:00
CopyPipeline = copyPipeline;
2023-07-28 16:23:13 -04:00
}
public void SetEncoderState(MTLRenderCommandEncoder renderCommandEncoder)
{
2023-08-02 19:56:59 -04:00
renderCommandEncoder.SetRenderPipelineState(CopyPipeline);
2023-07-28 16:23:13 -04:00
renderCommandEncoder.SetCullMode(CullMode);
renderCommandEncoder.SetFrontFacingWinding(Winding);
2023-08-02 19:56:59 -04:00
// renderCommandEncoder.SetDepthStencilState(_depthStencilState);
2023-07-29 00:46:13 -04:00
}
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
});
2023-07-28 16:23:13 -04:00
}
}
}