ProgramPipelineState.cs 2.3 KB

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