diff options
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Shader/TransformFeedbackDescriptor.cs')
-rw-r--r-- | Ryujinx.Graphics.Gpu/Shader/TransformFeedbackDescriptor.cs | 53 |
1 files changed, 46 insertions, 7 deletions
diff --git a/Ryujinx.Graphics.Gpu/Shader/TransformFeedbackDescriptor.cs b/Ryujinx.Graphics.Gpu/Shader/TransformFeedbackDescriptor.cs index eaa889cc..09f1df76 100644 --- a/Ryujinx.Graphics.Gpu/Shader/TransformFeedbackDescriptor.cs +++ b/Ryujinx.Graphics.Gpu/Shader/TransformFeedbackDescriptor.cs @@ -1,19 +1,58 @@ +using Ryujinx.Common.Memory; using System; +using System.Runtime.InteropServices; namespace Ryujinx.Graphics.Gpu.Shader { + /// <summary> + /// Transform feedback descriptor. + /// </summary> struct TransformFeedbackDescriptor { - public int BufferIndex { get; } - public int Stride { get; } + // New fields should be added to the end of the struct to keep disk shader cache compatibility. - public byte[] VaryingLocations { get; } + /// <summary> + /// Index of the transform feedback. + /// </summary> + public readonly int BufferIndex; - public TransformFeedbackDescriptor(int bufferIndex, int stride, byte[] varyingLocations) + /// <summary> + /// Amount of bytes consumed per vertex. + /// </summary> + public readonly int Stride; + + /// <summary> + /// Number of varyings written into the buffer. + /// </summary> + public readonly int VaryingCount; + + /// <summary> + /// Location of varyings to be written into the buffer. Each byte is one location. + /// </summary> + public Array32<uint> VaryingLocations; // Making this readonly breaks AsSpan + + /// <summary> + /// Creates a new transform feedback descriptor. + /// </summary> + /// <param name="bufferIndex">Index of the transform feedback</param> + /// <param name="stride">Amount of bytes consumed per vertex</param> + /// <param name="varyingCount">Number of varyings written into the buffer. Indicates size in bytes of <paramref name="varyingLocations"/></param> + /// <param name="varyingLocations">Location of varyings to be written into the buffer. Each byte is one location</param> + public TransformFeedbackDescriptor(int bufferIndex, int stride, int varyingCount, ref Array32<uint> varyingLocations) + { + BufferIndex = bufferIndex; + Stride = stride; + VaryingCount = varyingCount; + VaryingLocations = varyingLocations; + } + + /// <summary> + /// Gets a span of the <see cref="VaryingLocations"/>. + /// </summary> + /// <returns>Span of varying locations</returns> + public ReadOnlySpan<byte> AsSpan() { - BufferIndex = bufferIndex; - Stride = stride; - VaryingLocations = varyingLocations ?? throw new ArgumentNullException(nameof(varyingLocations)); + return MemoryMarshal.Cast<uint, byte>(VaryingLocations.ToSpan()).Slice(0, Math.Min(128, VaryingCount)); } } } |