ProgramPipelineState.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 void SetVertexAttribs(ReadOnlySpan<VertexAttribDescriptor> vertexAttribs)
  56. {
  57. VertexAttribCount = vertexAttribs.Length;
  58. vertexAttribs.CopyTo(VertexAttribs.AsSpan());
  59. }
  60. public void SetLogicOpState(bool enable, LogicalOp op)
  61. {
  62. LogicOp = op;
  63. LogicOpEnable = enable;
  64. }
  65. }
  66. }