using System; using System.Runtime.CompilerServices; using ComputeSharp.__Internals; #pragma warning disable CS0618 namespace ComputeSharp.Tests.Internals.Helpers; /// /// A debug data loader for generic shaders. /// internal readonly unsafe struct DebugDispatchDataLoader : IDispatchDataLoader { /// /// The backing, mutable data for and . /// private readonly StrongBox<(uint[] Values, ulong[] Resources)> data; /// /// Gets the captured values. /// public uint[] Values => this.data.Value.Values; /// /// Gets the captured resources. /// public ulong[] Resources => this.data.Value.Resources; /// /// Creates a new instance. /// /// A new instance to use. public static DebugDispatchDataLoader Create() { DebugDispatchDataLoader @this = default; Unsafe.AsRef(in @this.data) = new StrongBox<(uint[], ulong[])>((Array.Empty(), Array.Empty())); return @this; } /// public void LoadCapturedValues(ReadOnlySpan data) { this.data.Value.Values = data.ToArray(); } /// public void LoadCapturedResources(ReadOnlySpan data) { this.data.Value.Resources = data.ToArray(); } }