Refactor render graph error handling and resource APIs

- RenderGraph.Compile/Execute now return Error for better failure detection; error handling is propagated throughout compiler and executor.
- Renamed ScheduleReleaseResource to ReleaseResource for clarity; updated all usages.
- ResourceManager now calls ReleaseResource directly on Mesh, Material, and Shader types.
- Camera exposes Actual/Virtual size properties and Render returns Error.
- RenderingContext now uses IResourceManager for mesh/resource ops.
- Replaced custom BinaryWriter with BufferWriter in RenderGraphHasher.
- Improved variable naming, interface signatures, and code formatting.
- Added Error extension for IsSuccess/IsFailure.
- Minor FMOD/native interop and test code cleanups.
- No breaking API changes except for new Error return values on some methods.
This commit is contained in:
2026-02-25 19:08:54 +09:00
parent 30090f84ab
commit 162b71f309
93 changed files with 537 additions and 593 deletions

View File

@@ -7,7 +7,7 @@ using System.Runtime.CompilerServices;
namespace Ghost.Entities;
internal unsafe sealed class ChunkDebugView
internal sealed unsafe class ChunkDebugView
{
[DebuggerDisplay("{Name,nq}: {Data}")]
internal class ComponentArrayView
@@ -541,27 +541,27 @@ internal unsafe struct Archetype : IDisposable
ref var chunk = ref _chunks[chunkIndex];
int oldCount = chunk._count;
int removeCount = sortedIndicesToRemove.Length;
int newCount = oldCount - removeCount; // The boundary between "Keep" and "Drop"
var oldCount = chunk._count;
var removeCount = sortedIndicesToRemove.Length;
var newCount = oldCount - removeCount; // The boundary between "Keep" and "Drop"
var chunkBase = chunk.GetUnsafePtr();
var world = World.GetWorldUncheck(_worldID); // Typo fixed from 'wrold'
// Pointers for the swap logic
// 1. 'holePtr' tracks which index in the sorted list we are processing
int holePtr = 0;
var holePtr = 0;
// 2. 'candidateIndex' starts at the end of the OLD array and moves backward
int candidateIndex = oldCount - 1;
var candidateIndex = oldCount - 1;
// 3. 'removalTailPtr' tracks removals at the end of the array to skip them
int removalTailPtr = sortedIndicesToRemove.Length - 1;
var removalTailPtr = sortedIndicesToRemove.Length - 1;
// Iterate through the holes that are strictly INSIDE the new valid range
while (holePtr < removeCount)
{
int holeIndex = sortedIndicesToRemove[holePtr];
var holeIndex = sortedIndicesToRemove[holePtr];
// If the current hole is beyond the new count, it's in the "Drop Zone".
// Since the list is sorted, all subsequent holes are also in the drop zone.
@@ -574,7 +574,7 @@ internal unsafe struct Archetype : IDisposable
while (candidateIndex >= newCount)
{
// Check if the current candidate is actually marked for removal
bool isCandidateRemoved = false;
var isCandidateRemoved = false;
// Because sortedIndices is sorted, we check the end of the list
// to see if the candidateIndex matches a removal request.

View File

@@ -181,7 +181,7 @@ public class ComponentManager : IDisposable
_archetypes.Add(new Archetype(arcID, _world.ID, componentTypeIDs));
_archetypeLookup.Add(signatureHash, arcID);
for (int i = 0; i < _entityQueries.Count; i++)
for (var i = 0; i < _entityQueries.Count; i++)
{
ref var query = ref _entityQueries[i];
query.AddArchetypeIfMatch(in _archetypes[arcID.Value]);

View File

@@ -455,7 +455,7 @@ public unsafe partial struct EntityQuery : IDisposable
return 0;
}
for(var i = 0; i < _matchingArchetypes.Count; i++)
for (var i = 0; i < _matchingArchetypes.Count; i++)
{
var archetypeID = _matchingArchetypes[i];
ref var archetype = ref world.ComponentManager.GetArchetypeReference(archetypeID);

View File

@@ -204,7 +204,7 @@ public abstract class SystemGroup : ISystem
foreach (var sys in systems)
{
var type = sys.GetType();
if (!dependencies.TryGetValue(type, out HashSet<Type>? value))
if (!dependencies.TryGetValue(type, out var value))
{
value = [];
dependencies[type] = value;
@@ -234,7 +234,7 @@ public abstract class SystemGroup : ISystem
// We loop until we have sorted everyone
while (sortedList.Count < systems.Count)
{
bool addedAny = false;
var addedAny = false;
foreach (var sys in systems)
{
@@ -242,7 +242,7 @@ public abstract class SystemGroup : ISystem
if (visited.Contains(type)) continue;
// Check if all dependencies for this system are already visited/sorted
bool canRun = true;
var canRun = true;
if (dependencies.TryGetValue(type, out var deps))
{
foreach (var dep in deps)

View File

@@ -24,7 +24,7 @@ public unsafe partial struct EntityQuery
var it = _mask.writeAccess.GetIterator();
while (it.Next(out var id))
{
for (var i =0; i < 1; i++)
for (var i = 0; i < 1; i++)
{
if (id == compTypeIDs[i])
{
@@ -111,7 +111,7 @@ public unsafe partial struct EntityQuery
var it = _mask.writeAccess.GetIterator();
while (it.Next(out var id))
{
for (var i =0; i < 2; i++)
for (var i = 0; i < 2; i++)
{
if (id == compTypeIDs[i])
{
@@ -202,7 +202,7 @@ public unsafe partial struct EntityQuery
var it = _mask.writeAccess.GetIterator();
while (it.Next(out var id))
{
for (var i =0; i < 3; i++)
for (var i = 0; i < 3; i++)
{
if (id == compTypeIDs[i])
{
@@ -297,7 +297,7 @@ public unsafe partial struct EntityQuery
var it = _mask.writeAccess.GetIterator();
while (it.Next(out var id))
{
for (var i =0; i < 4; i++)
for (var i = 0; i < 4; i++)
{
if (id == compTypeIDs[i])
{
@@ -396,7 +396,7 @@ public unsafe partial struct EntityQuery
var it = _mask.writeAccess.GetIterator();
while (it.Next(out var id))
{
for (var i =0; i < 5; i++)
for (var i = 0; i < 5; i++)
{
if (id == compTypeIDs[i])
{
@@ -499,7 +499,7 @@ public unsafe partial struct EntityQuery
var it = _mask.writeAccess.GetIterator();
while (it.Next(out var id))
{
for (var i =0; i < 6; i++)
for (var i = 0; i < 6; i++)
{
if (id == compTypeIDs[i])
{
@@ -606,7 +606,7 @@ public unsafe partial struct EntityQuery
var it = _mask.writeAccess.GetIterator();
while (it.Next(out var id))
{
for (var i =0; i < 7; i++)
for (var i = 0; i < 7; i++)
{
if (id == compTypeIDs[i])
{
@@ -717,7 +717,7 @@ public unsafe partial struct EntityQuery
var it = _mask.writeAccess.GetIterator();
while (it.Next(out var id))
{
for (var i =0; i < 8; i++)
for (var i = 0; i < 8; i++)
{
if (id == compTypeIDs[i])
{
@@ -808,7 +808,7 @@ public unsafe partial struct EntityQuery
var it = _mask.writeAccess.GetIterator();
while (it.Next(out var id))
{
for (var i =0; i < 1; i++)
for (var i = 0; i < 1; i++)
{
if (id == compTypeIDs[i])
{
@@ -896,7 +896,7 @@ public unsafe partial struct EntityQuery
var it = _mask.writeAccess.GetIterator();
while (it.Next(out var id))
{
for (var i =0; i < 2; i++)
for (var i = 0; i < 2; i++)
{
if (id == compTypeIDs[i])
{
@@ -988,7 +988,7 @@ public unsafe partial struct EntityQuery
var it = _mask.writeAccess.GetIterator();
while (it.Next(out var id))
{
for (var i =0; i < 3; i++)
for (var i = 0; i < 3; i++)
{
if (id == compTypeIDs[i])
{
@@ -1084,7 +1084,7 @@ public unsafe partial struct EntityQuery
var it = _mask.writeAccess.GetIterator();
while (it.Next(out var id))
{
for (var i =0; i < 4; i++)
for (var i = 0; i < 4; i++)
{
if (id == compTypeIDs[i])
{
@@ -1184,7 +1184,7 @@ public unsafe partial struct EntityQuery
var it = _mask.writeAccess.GetIterator();
while (it.Next(out var id))
{
for (var i =0; i < 5; i++)
for (var i = 0; i < 5; i++)
{
if (id == compTypeIDs[i])
{
@@ -1288,7 +1288,7 @@ public unsafe partial struct EntityQuery
var it = _mask.writeAccess.GetIterator();
while (it.Next(out var id))
{
for (var i =0; i < 6; i++)
for (var i = 0; i < 6; i++)
{
if (id == compTypeIDs[i])
{
@@ -1396,7 +1396,7 @@ public unsafe partial struct EntityQuery
var it = _mask.writeAccess.GetIterator();
while (it.Next(out var id))
{
for (var i =0; i < 7; i++)
for (var i = 0; i < 7; i++)
{
if (id == compTypeIDs[i])
{
@@ -1508,7 +1508,7 @@ public unsafe partial struct EntityQuery
var it = _mask.writeAccess.GetIterator();
while (it.Next(out var id))
{
for (var i =0; i < 8; i++)
for (var i = 0; i < 8; i++)
{
if (id == compTypeIDs[i])
{

View File

@@ -1168,7 +1168,7 @@ public unsafe partial struct EntityQuery
var it = _mask.writeAccess.GetIterator();
while (it.Next(out var id))
{
for (var i =0; i < 1; i++)
for (var i = 0; i < 1; i++)
{
if (id == runner.componentIDs[i])
{
@@ -1324,7 +1324,7 @@ public unsafe partial struct EntityQuery
var it = _mask.writeAccess.GetIterator();
while (it.Next(out var id))
{
for (var i =0; i < 1; i++)
for (var i = 0; i < 1; i++)
{
if (id == runner.componentIDs[i])
{
@@ -1507,7 +1507,7 @@ public unsafe partial struct EntityQuery
var it = _mask.writeAccess.GetIterator();
while (it.Next(out var id))
{
for (var i =0; i < 1; i++)
for (var i = 0; i < 1; i++)
{
if (id == runner.componentIDs[i])
{
@@ -1717,7 +1717,7 @@ public unsafe partial struct EntityQuery
var it = _mask.writeAccess.GetIterator();
while (it.Next(out var id))
{
for (var i =0; i < 1; i++)
for (var i = 0; i < 1; i++)
{
if (id == runner.componentIDs[i])
{
@@ -1954,7 +1954,7 @@ public unsafe partial struct EntityQuery
var it = _mask.writeAccess.GetIterator();
while (it.Next(out var id))
{
for (var i =0; i < 1; i++)
for (var i = 0; i < 1; i++)
{
if (id == runner.componentIDs[i])
{
@@ -2218,7 +2218,7 @@ public unsafe partial struct EntityQuery
var it = _mask.writeAccess.GetIterator();
while (it.Next(out var id))
{
for (var i =0; i < 1; i++)
for (var i = 0; i < 1; i++)
{
if (id == runner.componentIDs[i])
{
@@ -2509,7 +2509,7 @@ public unsafe partial struct EntityQuery
var it = _mask.writeAccess.GetIterator();
while (it.Next(out var id))
{
for (var i =0; i < 1; i++)
for (var i = 0; i < 1; i++)
{
if (id == runner.componentIDs[i])
{
@@ -2827,7 +2827,7 @@ public unsafe partial struct EntityQuery
var it = _mask.writeAccess.GetIterator();
while (it.Next(out var id))
{
for (var i =0; i < 1; i++)
for (var i = 0; i < 1; i++)
{
if (id == runner.componentIDs[i])
{