TransformFeedbackDescriptor.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using Ryujinx.Common.Memory;
  2. using System;
  3. using System.Runtime.InteropServices;
  4. namespace Ryujinx.Graphics.Gpu.Shader
  5. {
  6. /// <summary>
  7. /// Transform feedback descriptor.
  8. /// </summary>
  9. struct TransformFeedbackDescriptor
  10. {
  11. // New fields should be added to the end of the struct to keep disk shader cache compatibility.
  12. /// <summary>
  13. /// Index of the transform feedback.
  14. /// </summary>
  15. public readonly int BufferIndex;
  16. /// <summary>
  17. /// Amount of bytes consumed per vertex.
  18. /// </summary>
  19. public readonly int Stride;
  20. /// <summary>
  21. /// Number of varyings written into the buffer.
  22. /// </summary>
  23. public readonly int VaryingCount;
  24. /// <summary>
  25. /// Location of varyings to be written into the buffer. Each byte is one location.
  26. /// </summary>
  27. public Array32<uint> VaryingLocations; // Making this readonly breaks AsSpan
  28. /// <summary>
  29. /// Creates a new transform feedback descriptor.
  30. /// </summary>
  31. /// <param name="bufferIndex">Index of the transform feedback</param>
  32. /// <param name="stride">Amount of bytes consumed per vertex</param>
  33. /// <param name="varyingCount">Number of varyings written into the buffer. Indicates size in bytes of <paramref name="varyingLocations"/></param>
  34. /// <param name="varyingLocations">Location of varyings to be written into the buffer. Each byte is one location</param>
  35. public TransformFeedbackDescriptor(int bufferIndex, int stride, int varyingCount, ref Array32<uint> varyingLocations)
  36. {
  37. BufferIndex = bufferIndex;
  38. Stride = stride;
  39. VaryingCount = varyingCount;
  40. VaryingLocations = varyingLocations;
  41. }
  42. /// <summary>
  43. /// Gets a span of the <see cref="VaryingLocations"/>.
  44. /// </summary>
  45. /// <returns>Span of varying locations</returns>
  46. public ReadOnlySpan<byte> AsSpan()
  47. {
  48. return MemoryMarshal.Cast<uint, byte>(VaryingLocations.AsSpan()).Slice(0, Math.Min(128, VaryingCount));
  49. }
  50. }
  51. }