You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When pluggable storages are added to flecs, pinned C# arrays should be used as storage for managed types.
Performance - Special unboxing code is required per every iteration in the current design. Using plain C# arrays will remove this overhead and bring the performance of managed component iteration on par with native C# ECS frameworks/libraries.
Memory Allocations - This will greatly reduce memory consumption due to only needing a single GCHandle and Box<T> object to be allocated per column instead of per component.
Debugging - With the current setup, it is not possible to inspect the contents of a column for both managed and unmanaged types inside a debugger due to the GCHandle indirection and unboxing step required for managed objects. Switching to C# array storage will replace the Column<T> type with the Span<T> type and allow the contents of components to be displayed in the debugger.
Pointer APIs - Pointer-based APIs in Flecs.NET are currently restricted to unmanaged types only. This restriction can be removed entirely as using pinned C# arrays will allow us to retrieve pointers to managed component references. This is a prerequisite to being able to properly implement serialization and deserialization for managed types.
// Pointer-based iterationQuery.Iter((Iterit,Position*p,Velocity*v)=>{});// Span-based iterationQuery.Iter((Iterit,Span<Position>p,Span<Velocity>v)=>{});// Get raw pointers to managed objects.Position*p=e.GetPtr<Position>();
The text was updated successfully, but these errors were encountered:
Allocating pinned arrays for managed types is only possible in .NET 8 and above. The minimum target version has been changed from .NET Standard 2.1 to .NET 8 in this PR #42. The Unity package will no longer be updated.
When pluggable storages are added to flecs, pinned C# arrays should be used as storage for managed types.
Performance - Special unboxing code is required per every iteration in the current design. Using plain C# arrays will remove this overhead and bring the performance of managed component iteration on par with native C# ECS frameworks/libraries.
Memory Allocations - This will greatly reduce memory consumption due to only needing a single
GCHandle
andBox<T>
object to be allocated per column instead of per component.Debugging - With the current setup, it is not possible to inspect the contents of a column for both managed and unmanaged types inside a debugger due to the
GCHandle
indirection and unboxing step required for managed objects. Switching to C# array storage will replace theColumn<T>
type with theSpan<T>
type and allow the contents of components to be displayed in the debugger.Pointer APIs - Pointer-based APIs in Flecs.NET are currently restricted to unmanaged types only. This restriction can be removed entirely as using pinned C# arrays will allow us to retrieve pointers to managed component references. This is a prerequisite to being able to properly implement serialization and deserialization for managed types.
The text was updated successfully, but these errors were encountered: