2024-05-18 22:54:55 +00:00
|
|
|
using Ryujinx.Graphics.GAL;
|
|
|
|
using SharpMetal.Metal;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Runtime.Versioning;
|
|
|
|
|
|
|
|
namespace Ryujinx.Graphics.Metal
|
|
|
|
{
|
2024-05-19 06:08:12 +00:00
|
|
|
public struct DirtyFlags
|
|
|
|
{
|
|
|
|
public bool Pipeline = false;
|
|
|
|
public bool DepthStencil = false;
|
|
|
|
|
|
|
|
public DirtyFlags() { }
|
2024-05-19 07:10:14 +00:00
|
|
|
|
2024-05-23 18:08:34 +00:00
|
|
|
public void MarkAll()
|
|
|
|
{
|
2024-05-19 07:10:14 +00:00
|
|
|
Pipeline = true;
|
|
|
|
DepthStencil = true;
|
2024-05-19 15:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Clear()
|
|
|
|
{
|
|
|
|
Pipeline = false;
|
|
|
|
DepthStencil = false;
|
2024-05-19 07:10:14 +00:00
|
|
|
}
|
2024-05-19 06:08:12 +00:00
|
|
|
}
|
|
|
|
|
2024-05-18 22:54:55 +00:00
|
|
|
[SupportedOSPlatform("macos")]
|
2024-05-22 21:21:44 +00:00
|
|
|
struct EncoderState
|
2024-05-18 22:54:55 +00:00
|
|
|
{
|
|
|
|
public MTLFunction? VertexFunction = null;
|
|
|
|
public MTLFunction? FragmentFunction = null;
|
|
|
|
|
2024-05-27 11:58:03 +00:00
|
|
|
public MTLTexture[] FragmentTextures = new MTLTexture[Constants.MaxTextures];
|
|
|
|
public MTLSamplerState[] FragmentSamplers = new MTLSamplerState[Constants.MaxSamplers];
|
2024-05-18 22:54:55 +00:00
|
|
|
|
2024-05-27 11:58:03 +00:00
|
|
|
public MTLTexture[] VertexTextures = new MTLTexture[Constants.MaxTextures];
|
|
|
|
public MTLSamplerState[] VertexSamplers = new MTLSamplerState[Constants.MaxSamplers];
|
2024-05-18 22:54:55 +00:00
|
|
|
|
|
|
|
public List<BufferInfo> UniformBuffers = [];
|
|
|
|
public List<BufferInfo> StorageBuffers = [];
|
|
|
|
|
|
|
|
public MTLBuffer IndexBuffer = default;
|
|
|
|
public MTLIndexType IndexType = MTLIndexType.UInt16;
|
|
|
|
public ulong IndexBufferOffset = 0;
|
|
|
|
|
|
|
|
public MTLDepthStencilState? DepthStencilState = null;
|
|
|
|
|
2024-05-19 01:29:46 +00:00
|
|
|
public MTLDepthClipMode DepthClipMode = MTLDepthClipMode.Clip;
|
2024-05-18 22:54:55 +00:00
|
|
|
public MTLCompareFunction DepthCompareFunction = MTLCompareFunction.Always;
|
|
|
|
public bool DepthWriteEnabled = false;
|
|
|
|
|
|
|
|
public MTLStencilDescriptor BackFaceStencil = new();
|
|
|
|
public MTLStencilDescriptor FrontFaceStencil = new();
|
2024-05-18 23:59:38 +00:00
|
|
|
public bool StencilTestEnabled = false;
|
2024-05-18 22:54:55 +00:00
|
|
|
|
|
|
|
public PrimitiveTopology Topology = PrimitiveTopology.Triangles;
|
|
|
|
public MTLCullMode CullMode = MTLCullMode.None;
|
2024-05-27 11:58:03 +00:00
|
|
|
public MTLWinding Winding = MTLWinding.CounterClockwise;
|
2024-05-18 22:54:55 +00:00
|
|
|
|
|
|
|
public MTLViewport[] Viewports = [];
|
|
|
|
public MTLScissorRect[] Scissors = [];
|
|
|
|
|
|
|
|
// Changes to attachments take recreation!
|
2024-05-23 00:26:54 +00:00
|
|
|
public Texture DepthStencil = default;
|
2024-05-22 21:21:44 +00:00
|
|
|
public Texture[] RenderTargets = new Texture[Constants.MaxColorAttachments];
|
2024-05-27 11:58:03 +00:00
|
|
|
public BlendDescriptor?[] BlendDescriptors = new BlendDescriptor?[Constants.MaxColorAttachments];
|
2024-05-19 01:20:15 +00:00
|
|
|
public ColorF BlendColor = new();
|
2024-05-18 22:54:55 +00:00
|
|
|
|
2024-05-19 02:06:53 +00:00
|
|
|
public VertexBufferDescriptor[] VertexBuffers = [];
|
|
|
|
public VertexAttribDescriptor[] VertexAttribs = [];
|
|
|
|
|
2024-05-19 06:08:12 +00:00
|
|
|
// Dirty flags
|
|
|
|
public DirtyFlags Dirty = new();
|
|
|
|
|
2024-05-18 22:54:55 +00:00
|
|
|
public EncoderState() { }
|
2024-05-27 11:58:03 +00:00
|
|
|
|
|
|
|
public EncoderState Clone()
|
|
|
|
{
|
|
|
|
// Certain state (like viewport and scissor) doesn't need to be cloned, as it is always reacreated when assigned to
|
|
|
|
EncoderState clone = this;
|
|
|
|
clone.FragmentTextures = (MTLTexture[])FragmentTextures.Clone();
|
|
|
|
clone.FragmentSamplers = (MTLSamplerState[])FragmentSamplers.Clone();
|
|
|
|
clone.VertexTextures = (MTLTexture[])VertexTextures.Clone();
|
|
|
|
clone.VertexSamplers = (MTLSamplerState[])VertexSamplers.Clone();
|
|
|
|
clone.BlendDescriptors = (BlendDescriptor?[])BlendDescriptors.Clone();
|
|
|
|
clone.VertexBuffers = (VertexBufferDescriptor[])VertexBuffers.Clone();
|
|
|
|
clone.VertexAttribs = (VertexAttribDescriptor[])VertexAttribs.Clone();
|
|
|
|
|
|
|
|
return clone;
|
|
|
|
}
|
2024-05-18 22:54:55 +00:00
|
|
|
}
|
|
|
|
}
|