StructureOfArraysGenerator
StructureOfArraysGenerator copied to clipboard
Use different arrays for each field
as an option
[MultiArray(typeof(Vector3), IndividualArrays = true)]
public readonly partial struct Vector3MultiArray
{
}
[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Auto)]
partial struct Vector3MultiArray : global::StructureOfArraysGenerator.IMultiArray<Vector3MultiArray>
{
- readonly byte[] __value;
+ readonly float[] __valueX;
+ readonly float[] __valueY;
+ readonly float[] __valueZ;
readonly int __length;
- readonly int __byteSize;
- readonly int __byteOffsetX;
- readonly int __byteOffsetY;
- readonly int __byteOffsetZ;
public int Length => __length;
- public Span<float> X => MemoryMarshal.CreateSpan(ref Unsafe.As<byte, float>(ref Unsafe.Add(ref GetArrayDataReference(__value), __byteOffsetX)), __length);
- public Span<float> Y => MemoryMarshal.CreateSpan(ref Unsafe.As<byte, float>(ref Unsafe.Add(ref GetArrayDataReference(__value), __byteOffsetY)), __length);
- public Span<float> Z => MemoryMarshal.CreateSpan(ref Unsafe.As<byte, float>(ref Unsafe.Add(ref GetArrayDataReference(__value), __byteOffsetZ)), __length);
+ public Span<float> X => __valueX;
+ public Span<float> Y => __valueY;
+ public Span<float> Z => __valueZ;
...
}
this will allow to have more than 2^(32-1)/sizeof(T) elements in a single array.
It's hard to see a use case where we have so many elements in use simultaneously. Maybe segments (chunks) could be a better solution, as the Parquet format does.
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 30 days.