What is Horizon Engine?
Horizon is a centralized and modular game engine. It mainly targets desktop games via DirectX 12. The overall flow is built on services that live within the core application’s lifetime scope. Multi-threading is split into frame-based and instant tasks, handled by the JobSystem and the WorkSystem. The JobSystem focuses on frame-based tasks such as the RenderGraph, ECS and game modules. The WorkSystem, on the other hand, handles tasks such as the AssetStreamer’s load and unload, asset importer pipelines, etc. The game world runs on a sparse-set entity component system, resolved through a multi-threaded system graph. Meanwhile, the scene is rendered through a multi-threaded RenderGraph.
Sparse-set ECS
For those who don’t know, a sparse-set entity component system is an approach where your scene holds multiple component arrays. It runs best when you query a single component, but it’s still fast because we still get the benefits of cache locality.
Please check out this amazing person’s blog.
If you want to learn more about archetype ECS, check this out as well.
Runtime Reflection System
Like every automated engine, Horizon also has a runtime reflection system. It facilitates internal communication within the engine and the management of its features, while also effectively preventing code designs on the editor side from becoming bloated. Its most significant feature is that it automates many registration processes. Unlike commercial engines, this approach does not involve modifying the files in which the code is written.
System & Render Graphs
Horizon runs both the game world and the frame through dependency graphs, and both of them find their nodes by themselves via runtime reflection. Each system declares the components it reads or writes, and the SystemGraph uses this to run the independent systems in parallel on the JobSystem. The RenderGraph does the same for render passes. It sorts them, creates their resources and places the barriers automatically.
If you want to learn more about graph theory, check this link.
Jolt Integration
I chose Jolt because it’s a very successful physics engine, it’s very verbose about what it does, and integrating and using it is extremely easy in a system that is split into modules like mine. I also believe that, together with my ECS, it will deliver top-level performance in physics-heavy scenes.
CPU and GPU Profiler
Profiler::Mark measures CPU scopes with the OS’s high-resolution timer, while GPU timings come from DX12 timestamp queries and are submitted through Profiler::SubmitGpu. The reason for using the OS-based timer is entirely about getting a sharp and accurate answer.
Under the Hood
Most of Horizon’s core is hand-written instead of taken from a library. Below are the modern systems I built myself, and the passes a frame goes through.
Hand-written Core
- Mesh Asset Streamer
- Texture Asset Streamer
- Job (Frame-based) & Work (Instant) Systems with Work Stealing
- Sparse-set ECS
- Render Graph
- Rendering Hardware Interface (Default D3D12)
- Platform Abstraction Layer
- Runtime Reflection System
Render Flow
- Pre-depth Pass
- Hierarchical Z Pass
- Cluster Build Pass
- Cluster Pass
- Cascaded PCF Shadow Pass
- GBuffer Pass
- Lighting Pass
- Procedural Sky Pass
- Volumetrics Pass
- Tonemap Pass
- FXAA Pass