Files
GhostEngine/Ghost.RenderGraph.Concept/Program.cs
Misaki 954e3756aa Refactor Render Graph: unified resources, benchmarking
Major overhaul of Render Graph system:
- Replaced texture handles with generic Identifier<T> for unified, type-safe resource management (textures, buffers, etc.)
- Refactored resource registry and pooling for performance and extensibility
- Added AccessFlags and TextureAccess for precise resource usage tracking
- Split passes into Raster and Compute types; introduced builder interfaces for safer pass construction
- Modernized pass setup API (SetColorAttachment, UseTexture, etc.)
- Updated command buffer and context structs to use new resource system
- Refactored barrier and aliasing logic for improved correctness
- Integrated BenchmarkDotNet for performance/memory benchmarking
- Improved blackboard type safety and removed obsolete code/extensions
- Added BenchmarkDotNet NuGet package

These changes make the Render Graph more extensible, efficient, and ready for future resource types and advanced features.
2026-01-12 23:48:56 +09:00

43 lines
1.2 KiB
C#

using Ghost.Core;
using Ghost.RenderGraph.Concept;
using Ghost.RenderGraph.Concept.Benchmark;
var renderGraph = new RenderGraph();
#if !DEBUG
BenchmarkDotNet.Running.BenchmarkRunner.Run<RenderGraphBenchmark>();
return;
//const int _ITERATION = 500000;
//for (var i = 0; i < _ITERATION; i++)
//{
// RenderGraphBenchmark.ExecuteGraph(renderGraph);
//}
//GC.Collect();
//GC.WaitForPendingFinalizers();
////Thread.Sleep(1000); // Leave a gap in visual studio allocations timeline
//var sw = new System.Diagnostics.Stopwatch();
//var gcBefore = GC.GetAllocatedBytesForCurrentThread();
//sw.Start();
//for (var i = 0; i < _ITERATION; i++)
//{
// RenderGraphBenchmark.ExecuteGraph(renderGraph);
//}
//sw.Stop();
//var gcAfter = GC.GetAllocatedBytesForCurrentThread();
//Console.WriteLine($"{sw.Elapsed.TotalNanoseconds / _ITERATION} ns (per iteration)");
//Console.WriteLine($"GC Allocated Bytes: {(gcAfter - gcBefore) / _ITERATION} bytes (per iteration)");
#else
// Run twice to demonstrate cache hit
Console.WriteLine("=== FRAME 1 (Cache Miss Expected) ===");
RenderGraphBenchmark.ExecuteGraph(renderGraph);
Console.WriteLine("\n\n=== FRAME 2 (Cache Hit Expected) ===");
RenderGraphBenchmark.ExecuteGraph(renderGraph);
#endif