/ src / Ryujinx.Graphics.GAL / ProgramPipelineState.cs
ProgramPipelineState.cs
 1  using Ryujinx.Common.Memory;
 2  using System;
 3  
 4  namespace Ryujinx.Graphics.GAL
 5  {
 6      /// <summary>
 7      /// Descriptor for a pipeline buffer binding.
 8      /// </summary>
 9      public readonly struct BufferPipelineDescriptor
10      {
11          public bool Enable { get; }
12          public int Stride { get; }
13          public int Divisor { get; }
14  
15          public BufferPipelineDescriptor(bool enable, int stride, int divisor)
16          {
17              Enable = enable;
18              Stride = stride;
19              Divisor = divisor;
20          }
21      }
22  
23      /// <summary>
24      /// State required for a program to compile shaders.
25      /// </summary>
26      public struct ProgramPipelineState
27      {
28          // Some state is considered always dynamic and should not be included:
29          // - Viewports/Scissors
30          // - Bias values (not enable)
31  
32          public int SamplesCount;
33          public Array8<bool> AttachmentEnable;
34          public Array8<Format> AttachmentFormats;
35          public bool DepthStencilEnable;
36          public Format DepthStencilFormat;
37  
38          public bool LogicOpEnable;
39          public LogicalOp LogicOp;
40          public Array8<BlendDescriptor> BlendDescriptors;
41          public Array8<uint> ColorWriteMask;
42  
43          public int VertexAttribCount;
44          public Array32<VertexAttribDescriptor> VertexAttribs;
45  
46          public int VertexBufferCount;
47          public Array32<BufferPipelineDescriptor> VertexBuffers;
48  
49          // TODO: Min/max depth bounds.
50          public DepthTestDescriptor DepthTest;
51          public StencilTestDescriptor StencilTest;
52          public FrontFace FrontFace;
53          public Face CullMode;
54          public bool CullEnable;
55  
56          public PolygonModeMask BiasEnable;
57  
58          public float LineWidth;
59          // TODO: Polygon mode.
60          public bool DepthClampEnable;
61          public bool RasterizerDiscard;
62          public PrimitiveTopology Topology;
63          public bool PrimitiveRestartEnable;
64          public uint PatchControlPoints;
65  
66          public DepthMode DepthMode;
67  
68          public void SetVertexAttribs(ReadOnlySpan<VertexAttribDescriptor> vertexAttribs)
69          {
70              VertexAttribCount = vertexAttribs.Length;
71              vertexAttribs.CopyTo(VertexAttribs.AsSpan());
72          }
73  
74          public void SetLogicOpState(bool enable, LogicalOp op)
75          {
76              LogicOp = op;
77              LogicOpEnable = enable;
78          }
79      }
80  }