This file provides guidance to AI coding agents when working with code in this repository.
This project uses XMake as its build system. All commands below assume you are in the project root.
# Configure (debug mode, Clang-cl)
xmake f -m debug --toolchain=clang-cl
# Configure (release mode)
xmake f -m release --toolchain=clang-cl
# Build all targets
xmake
# Run a target
xmake r playground
xmake r editor# Enable Tracy profiling
xmake f -m debug --toolchain=clang-cl --profile=y
# Disable ISPC acceleration for math
xmake f -m debug --toolchain=clang-cl --ispc=nTests are organized into groups. Run individual test targets with:
xmake r math_test
xmake r memory_test
xmake r memory_benchmark
xmake r file_io_manager_test
xmake r timer_test
xmake r gfx_test
xmake r shader_compiler_test
xmake r device_test
xmake r render_graph_testAlso, you can run test with group flag like this:
xmake r -g test/math
xmake r -g test/renderer
xmake r -g test/ecs
xmake r -g test/asset
xmake r -g test/renderer
xmake r -g test/* # for all groupsTo build only a specific target group: xmake build -g test/math, xmake build -g test/gfx, etc.
All engine code uses C++23 modules (.cppm files) with the export module xxx; pattern. Regular .cpp files contain module implementations. Headers (.h/.hpp) are only used at module boundaries for third-party libraries via module; global fragment blocks.
Following the layered architecture from Game Engine Architecture (Jason Gregory), higher layers depend on lower ones — never the reverse:
┌─────────────────────────────────────────────────────┐
│ engine │ ← Engine Shell
├──────────┬─────────────────────────┬────────────────┤
│ debugger │ gui │ render │ ← Gameplay Foundations
├──────────┴──────────────┬──────────┴────────────────┤
│ ecs │ asset │ ← Scene & Resources
├─────────────────────────┴───────────────────────────┤
│ render_graph │ gfx (Vulkan · DX12) │ ← Rendering Engine
├─────────────────────────┴───────────────────────────┤
│ app (SDL3) │ hid │ ← Platform Independence
├─────────────────────────┴───────────────────────────┤
│ core │ ← Core Systems
│ (memory · threading · I/O · timer) │
├──────────────────────────┬──────────────────────────┤
│ math │ utils │ ← Foundation
└──────────────────────────┴──────────────────────────┘
| Namespace | Module | Purpose |
|---|---|---|
hitagi |
engine, app, core |
Top-level engine, application, runtime modules |
hitagi::gfx |
gfx, gfx.base |
Graphics device abstraction |
hitagi::rg |
gfx.render_graph |
Render graph |
hitagi::ecs |
ecs |
Entity Component System |
hitagi::asset |
asset |
Asset management |
hitagi::render |
render |
Renderer implementations |
hitagi::math |
math |
Math library (row-major matrices) |
hitagi/core — RuntimeModule is the base class for all engine subsystems. Each module has a Tick() method and can contain child sub-modules. All modules are registered in a global map accessible via RuntimeModule::GetModule(name). Includes PMR-based memory allocator, file I/O, thread pool, and timer.
hitagi/gfx — Graphics abstraction with DX12 and Vulkan backends. Create a device with gfx::create_device(Device::Type::Vulkan). The backend is selected at runtime from hitagi.json (gfx_backend field). Matrices are row-major on both CPU and GPU.
hitagi/gfx/render_graph — Frame-scoped render graph (rg::RenderGraph). Resources are created/imported each frame via typed handles (TextureHandle, GPUBufferHandle, etc.), passes are recorded via RenderPassBuilder/ComputePassBuilder, then Compile() + Execute() runs the graph.
hitagi/ecs — Archetype-based ECS. ecs::World owns EntityManager and SystemManager; parallel task scheduling via Taskflow.
hitagi/platform — Application base class with SDL3 backend. Created via Application::CreateApp(config) or from hitagi.json.
hitagi/asset — AssetManager for loading scenes, meshes, materials, textures. Assimp for model import; custom parsers for PNG, JPEG, BMP, TGA. Materials are defined with named instances (e.g., "Phong").
hitagi/render — IRenderer interface with two concrete implementations: ForwardRenderer (single-pass Phong shading) and DeferredRenderer (G-Buffer MRT pass + fullscreen lighting pass). Both renderers own the swapchain and render graph instance. The engine defaults to ForwardRenderer; switch via Engine::SetRenderer().
hitagi/engine — Top-level Engine class that composes everything. Initialized from hitagi.json at the project root. Usage pattern: construct Engine, call engine.Tick() in the game loop.
import engine;
import asset;
int main() {
hitagi::Engine engine; // reads hitagi.json
// ... set up scene, camera, etc. ...
while (!engine.App().IsQuit()) {
engine.GuiManager().DrawGui([&]() { /* imgui calls */ });
// ... render graph setup ...
engine.Tick();
}
}hitagi.json in the project root controls runtime settings: gfx_backend ("Vulkan" or "DX12"), window size, asset root path, log level.
- Create
hitagi/<name>/with.cppm(interface) and.cpp(implementation) files. - Add
target("<name>")inhitagi/<name>/xmake.luawithadd_deps(...)for dependencies. - Include the new
xmake.luafromhitagi/xmake.lua. - Export the module from
hitagi/engine/engine.cppmif it should be part of the engine aggregate.
- Windows is the primary platform; DX12 backend is Windows-only (
is_plat("windows")). - Vulkan backend works on Windows and Linux (Wayland).
- Runtime is set to
MD/MDd(dynamic CRT) on Windows. - Source files use UTF-8 encoding (
set_encodings("utf-8")).