feat(rendering): add GPU scene updates and optimizations
Added a new `code-executor` agent with strict TDD and performance focus. Refactored `TextureProcessor` and `TextureAssetHandler` to use `Magick.NET` for image processing. Enhanced `GPUScene` with `InstanceCounterBuffer` and improved instance management. Introduced a compute shader for GPU scene updates. Updated `GhostRenderPipeline` to handle add/remove instance buffers. BREAKING CHANGE: Removed `x86` platform support and replaced `CachesFolderPath` with `LibraryFolderPath`. Updated project dependencies and removed unused utility classes.
This commit is contained in:
@@ -48,6 +48,11 @@ internal static class ComponentRegistry
|
||||
internal static readonly Dictionary<int, Type> s_runtimeIDToType = new();
|
||||
#endif
|
||||
|
||||
static ComponentRegistry()
|
||||
{
|
||||
GetOrRegisterComponentID<ManagedEntityRef>();
|
||||
}
|
||||
|
||||
public static unsafe Identifier<IComponent> GetOrRegisterComponentID<T>()
|
||||
where T : unmanaged, IComponent
|
||||
{
|
||||
|
||||
@@ -424,7 +424,7 @@ public unsafe partial class EntityManager : IDisposable
|
||||
// Remove Managed Entities first
|
||||
// RemoveManagedEntity(rowIndicesCache.AsSpan(), in prevArchetype, prevChunkIndex);
|
||||
|
||||
// TODO: Handle ICleanupComponent here before we remove the entities from the archetype.
|
||||
// FIX: Handle ICleanupComponent here before we remove the entities from the archetype.
|
||||
|
||||
// Execute the hole-filling/swap logic
|
||||
prevArchetype.RemoveEntities(prevChunkIndex, rowIndicesCache.AsSpan());
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<IsAotCompatible>False</IsAotCompatible>
|
||||
<IsTrimmable>False</IsTrimmable>
|
||||
<IsAotCompatible>True</IsAotCompatible>
|
||||
<IsTrimmable>True</IsTrimmable>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Ghost.Core;
|
||||
using Misaki.HighPerformance.LowLevel.Collections;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ghost.Entities;
|
||||
|
||||
@@ -201,6 +202,7 @@ public abstract class SystemGroup : ISystem
|
||||
// _systems = SystemGroupRegistry.GetSystemsForGroup(GetType());
|
||||
// }
|
||||
|
||||
// TODO: Use Source Generators to generate group registrations at compile time, and remove the need for this public constructor.
|
||||
private static List<ISystem> Sort(List<ISystem> systems)
|
||||
{
|
||||
// 1. Build the Graph
|
||||
@@ -211,10 +213,10 @@ public abstract class SystemGroup : ISystem
|
||||
foreach (var sys in systems)
|
||||
{
|
||||
var type = sys.GetType();
|
||||
if (!dependencies.TryGetValue(type, out var value))
|
||||
ref var value = ref CollectionsMarshal.GetValueRefOrAddDefault(dependencies, type, out var exists);
|
||||
if (!exists || value == null)
|
||||
{
|
||||
value = [];
|
||||
dependencies[type] = value;
|
||||
value = new HashSet<Type>();
|
||||
}
|
||||
|
||||
// Handle [UpdateAfter(typeof(Other))] -> Other comes before This
|
||||
@@ -229,8 +231,13 @@ public abstract class SystemGroup : ISystem
|
||||
foreach (var attr in type.GetCustomAttributes(typeof(UpdateBeforeAttribute), true))
|
||||
{
|
||||
var targetType = ((UpdateBeforeAttribute)attr).SystemType;
|
||||
if (!dependencies.ContainsKey(targetType)) dependencies[targetType] = [];
|
||||
dependencies[targetType].Add(type);
|
||||
ref var targetDeps = ref CollectionsMarshal.GetValueRefOrAddDefault(dependencies, targetType, out exists);
|
||||
if (!exists || targetDeps == null)
|
||||
{
|
||||
targetDeps = new HashSet<Type>();
|
||||
}
|
||||
|
||||
targetDeps.Add(type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,7 +253,10 @@ public abstract class SystemGroup : ISystem
|
||||
foreach (var sys in systems)
|
||||
{
|
||||
var type = sys.GetType();
|
||||
if (visited.Contains(type)) continue;
|
||||
if (visited.Contains(type))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if all dependencies for this system are already visited/sorted
|
||||
var canRun = true;
|
||||
@@ -297,7 +307,7 @@ public abstract class SystemGroup : ISystem
|
||||
|
||||
if (_systems.Count == 0)
|
||||
{
|
||||
_sortedSystems = [];
|
||||
_sortedSystems = new List<ISystem>();
|
||||
_sortedVersion = _version;
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user