aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Gpu/Shader/TransformFeedbackDescriptor.cs
diff options
context:
space:
mode:
authorTSR Berry <20988865+TSRBerry@users.noreply.github.com>2023-04-08 01:22:00 +0200
committerMary <thog@protonmail.com>2023-04-27 23:51:14 +0200
commitcee712105850ac3385cd0091a923438167433f9f (patch)
tree4a5274b21d8b7f938c0d0ce18736d3f2993b11b1 /src/Ryujinx.Graphics.Gpu/Shader/TransformFeedbackDescriptor.cs
parentcd124bda587ef09668a971fa1cac1c3f0cfc9f21 (diff)
Move solution and projects to src
Diffstat (limited to 'src/Ryujinx.Graphics.Gpu/Shader/TransformFeedbackDescriptor.cs')
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/TransformFeedbackDescriptor.cs58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/TransformFeedbackDescriptor.cs b/src/Ryujinx.Graphics.Gpu/Shader/TransformFeedbackDescriptor.cs
new file mode 100644
index 00000000..5baf2a1a
--- /dev/null
+++ b/src/Ryujinx.Graphics.Gpu/Shader/TransformFeedbackDescriptor.cs
@@ -0,0 +1,58 @@
+using Ryujinx.Common.Memory;
+using System;
+using System.Runtime.InteropServices;
+
+namespace Ryujinx.Graphics.Gpu.Shader
+{
+ /// <summary>
+ /// Transform feedback descriptor.
+ /// </summary>
+ struct TransformFeedbackDescriptor
+ {
+ // New fields should be added to the end of the struct to keep disk shader cache compatibility.
+
+ /// <summary>
+ /// Index of the transform feedback.
+ /// </summary>
+ public readonly int BufferIndex;
+
+ /// <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()
+ {
+ return MemoryMarshal.Cast<uint, byte>(VaryingLocations.AsSpan()).Slice(0, Math.Min(128, VaryingCount));
+ }
+ }
+}