/ src / Ryujinx.Graphics.Shader / GpuGraphicsState.cs
GpuGraphicsState.cs
  1  using Ryujinx.Common.Memory;
  2  
  3  namespace Ryujinx.Graphics.Shader
  4  {
  5      /// <summary>
  6      /// GPU graphics state that the shader depends on.
  7      /// </summary>
  8      public readonly struct GpuGraphicsState
  9      {
 10          /// <summary>
 11          /// Early Z force enable.
 12          /// </summary>
 13          public readonly bool EarlyZForce;
 14  
 15          /// <summary>
 16          /// Primitive topology of current draw.
 17          /// </summary>
 18          public readonly InputTopology Topology;
 19  
 20          /// <summary>
 21          /// Tessellation winding order.
 22          /// </summary>
 23          public readonly bool TessCw;
 24  
 25          /// <summary>
 26          /// Tessellation patch type.
 27          /// </summary>
 28          public readonly TessPatchType TessPatchType;
 29  
 30          /// <summary>
 31          /// Tessellation spacing.
 32          /// </summary>
 33          public readonly TessSpacing TessSpacing;
 34  
 35          /// <summary>
 36          /// Indicates whether alpha-to-coverage is enabled.
 37          /// </summary>
 38          public readonly bool AlphaToCoverageEnable;
 39  
 40          /// <summary>
 41          /// Indicates whether alpha-to-coverage dithering is enabled.
 42          /// </summary>
 43          public readonly bool AlphaToCoverageDitherEnable;
 44  
 45          /// <summary>
 46          /// Indicates whether the viewport transform is disabled.
 47          /// </summary>
 48          public readonly bool ViewportTransformDisable;
 49  
 50          /// <summary>
 51          /// Depth mode zero to one or minus one to one.
 52          /// </summary>
 53          public readonly bool DepthMode;
 54  
 55          /// <summary>
 56          /// Indicates if the point size is set on the shader or is fixed.
 57          /// </summary>
 58          public readonly bool ProgramPointSizeEnable;
 59  
 60          /// <summary>
 61          /// Point size used if <see cref="ProgramPointSizeEnable" /> is false.
 62          /// </summary>
 63          public readonly float PointSize;
 64  
 65          /// <summary>
 66          /// When alpha test is enabled, indicates the comparison that decides if the fragment should be discarded.
 67          /// </summary>
 68          public readonly AlphaTestOp AlphaTestCompare;
 69  
 70          /// <summary>
 71          /// When alpha test is enabled, indicates the value to compare with the fragment output alpha.
 72          /// </summary>
 73          public readonly float AlphaTestReference;
 74  
 75          /// <summary>
 76          /// Type of the vertex attributes consumed by the shader.
 77          /// </summary>
 78          public readonly Array32<AttributeType> AttributeTypes;
 79  
 80          /// <summary>
 81          /// Indicates that the draw is writing the base vertex, base instance and draw index to Constant Buffer 0.
 82          /// </summary>
 83          public readonly bool HasConstantBufferDrawParameters;
 84  
 85          /// <summary>
 86          /// Type of the fragment shader outputs.
 87          /// </summary>
 88          public readonly Array8<AttributeType> FragmentOutputTypes;
 89  
 90          /// <summary>
 91          /// Indicates whether dual source blend is enabled.
 92          /// </summary>
 93          public readonly bool DualSourceBlendEnable;
 94  
 95          /// <summary>
 96          /// Indicates if negation of the viewport Y axis is enabled.
 97          /// </summary>
 98          public readonly bool YNegateEnabled;
 99  
100          /// <summary>
101          /// If true, indicates that the fragment origin is the upper left corner of the viewport, otherwise it is the lower left corner.
102          /// </summary>
103          public readonly bool OriginUpperLeft;
104  
105          /// <summary>
106          /// Indicates that the primitive ID values on the shader should be halved due to quad to triangles conversion.
107          /// </summary>
108          public readonly bool HalvePrimitiveId;
109  
110          /// <summary>
111          /// Creates a new GPU graphics state.
112          /// </summary>
113          /// <param name="earlyZForce">Early Z force enable</param>
114          /// <param name="topology">Primitive topology</param>
115          /// <param name="tessCw">Tessellation winding order (clockwise or counter-clockwise)</param>
116          /// <param name="tessPatchType">Tessellation patch type</param>
117          /// <param name="tessSpacing">Tessellation spacing</param>
118          /// <param name="alphaToCoverageEnable">Indicates whether alpha-to-coverage is enabled</param>
119          /// <param name="alphaToCoverageDitherEnable">Indicates whether alpha-to-coverage dithering is enabled</param>
120          /// <param name="viewportTransformDisable">Indicates whether the viewport transform is disabled</param>
121          /// <param name="depthMode">Depth mode zero to one or minus one to one</param>
122          /// <param name="programPointSizeEnable">Indicates if the point size is set on the shader or is fixed</param>
123          /// <param name="pointSize">Point size if not set from shader</param>
124          /// <param name="alphaTestCompare">When alpha test is enabled, indicates the comparison that decides if the fragment should be discarded</param>
125          /// <param name="alphaTestReference">When alpha test is enabled, indicates the value to compare with the fragment output alpha</param>
126          /// <param name="attributeTypes">Type of the vertex attributes consumed by the shader</param>
127          /// <param name="hasConstantBufferDrawParameters">Indicates that the draw is writing the base vertex, base instance and draw index to Constant Buffer 0</param>
128          /// <param name="fragmentOutputTypes">Type of the fragment shader outputs</param>
129          /// <param name="dualSourceBlendEnable">Indicates whether dual source blend is enabled</param>
130          /// <param name="yNegateEnabled">Indicates if negation of the viewport Y axis is enabled</param>
131          /// <param name="originUpperLeft">If true, indicates that the fragment origin is the upper left corner of the viewport, otherwise it is the lower left corner</param>
132          /// <param name="halvePrimitiveId">Indicates that the primitive ID values on the shader should be halved due to quad to triangles conversion</param>
133          public GpuGraphicsState(
134              bool earlyZForce,
135              InputTopology topology,
136              bool tessCw,
137              TessPatchType tessPatchType,
138              TessSpacing tessSpacing,
139              bool alphaToCoverageEnable,
140              bool alphaToCoverageDitherEnable,
141              bool viewportTransformDisable,
142              bool depthMode,
143              bool programPointSizeEnable,
144              float pointSize,
145              AlphaTestOp alphaTestCompare,
146              float alphaTestReference,
147              in Array32<AttributeType> attributeTypes,
148              bool hasConstantBufferDrawParameters,
149              in Array8<AttributeType> fragmentOutputTypes,
150              bool dualSourceBlendEnable,
151              bool yNegateEnabled,
152              bool originUpperLeft,
153              bool halvePrimitiveId)
154          {
155              EarlyZForce = earlyZForce;
156              Topology = topology;
157              TessCw = tessCw;
158              TessPatchType = tessPatchType;
159              TessSpacing = tessSpacing;
160              AlphaToCoverageEnable = alphaToCoverageEnable;
161              AlphaToCoverageDitherEnable = alphaToCoverageDitherEnable;
162              ViewportTransformDisable = viewportTransformDisable;
163              DepthMode = depthMode;
164              ProgramPointSizeEnable = programPointSizeEnable;
165              PointSize = pointSize;
166              AlphaTestCompare = alphaTestCompare;
167              AlphaTestReference = alphaTestReference;
168              AttributeTypes = attributeTypes;
169              HasConstantBufferDrawParameters = hasConstantBufferDrawParameters;
170              FragmentOutputTypes = fragmentOutputTypes;
171              DualSourceBlendEnable = dualSourceBlendEnable;
172              YNegateEnabled = yNegateEnabled;
173              OriginUpperLeft = originUpperLeft;
174              HalvePrimitiveId = halvePrimitiveId;
175          }
176      }
177  }