using System; using System.Collections.Immutable; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using ComputeSharp.D2D1.__Internals; using ComputeSharp.D2D1.Interop; #pragma warning disable CS0618 namespace ComputeSharp.D2D1.Shaders.Loaders; /// /// A resource texture index array loader for D2D1 pixel shaders. /// internal struct D2D1ImmutableArrayResourceTextureDescriptionsLoader : ID2D1ResourceTextureDescriptionsLoader { /// /// The array of indices for resource textures for the current effect. /// private ImmutableArray indices; /// /// Gets the resulting array of indices for resource textures for the current effect. /// /// An array of indices for resource textures for the current effect. [MethodImpl(MethodImplOptions.AggressiveInlining)] public ImmutableArray GetResultingIndices() { return this.indices; } /// void ID2D1ResourceTextureDescriptionsLoader.LoadResourceTextureDescriptions(ReadOnlySpan data) { if (data.IsEmpty) { this.indices = ImmutableArray.Empty; } else { ReadOnlySpan descriptions = MemoryMarshal.Cast(data); int[] indices = new int[descriptions.Length]; for (int i = 0; i < descriptions.Length; i++) { indices[i] = descriptions[i].Index; } this.indices = Unsafe.As>(ref indices); } } }