using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace Veldrid.SPIRV { [StructLayout(LayoutKind.Sequential, Pack = 1)] internal unsafe struct InteropArray { public uint Count; public void* Data; public InteropArray(uint count, void* data) { Count = count; Data = data; } public ref T Ref(int index) { if (index >= Count) { throw new ArgumentOutOfRangeException(nameof(index)); } return ref Unsafe.AsRef((byte*)Data + (index * Unsafe.SizeOf())); } public ref T Ref(uint index) { if (index >= Count) { throw new ArgumentOutOfRangeException(nameof(index)); } return ref Unsafe.AsRef((byte*)Data + (index * Unsafe.SizeOf())); } } }