Primal — notes for Claude
Primal is a C++ game engine (D3D12 + Vulkan) with a C# WPF editor. This repo is Charles Smith's ("Chuck") fork of
Arash Khatami's Primal. Work is done on two machines: Linux (CachyOS, AMD RX 6800 XT, clang 23 / GCC 16, CMake +
Ninja, Vulkan) and Windows (Visual Studio / MSBuild, D3D12 + Vulkan, the editor). Claude's memory is per machine, so
this file and Docs/ are the shared state: keep them current as work goes.
Where things are
Docs/LinuxVulkanPort.md: the port plan (done 2026-11-08) and the "Open items" list. Open items A is the next-Windows-session checklist and B is known bugs. Read its "Start here" paragraph first.- Forgejo issues are the backlog (migrated from
Docs/Tickets/on 2026-11-10, from Gitea to Forgejo on 2026-11-16): https://forgejo.unflavoredmeson.com/UnflavoredMeson/Primal/issues. The oldgitea.address redirects; Gitea tokens don't work. The token file keeps its old name.- T01–T21 are issues #1–#21, with the old
Tnn —title prefix. #25 (pinned) is the suggested order. - Labels:
area/*,priority/*,size/*,bug,needs-windows-check,roadmap. - Read and update them through the API (
/api/v1/repos/UnflavoredMeson/Primal/issues) with the token in~/.config/primal-gitea-token(Authorization: token …; each machine needs its own copy of the file). Never print the token. The repo is public, so the issues are too: no personal paths or hostnames in them. - Add new ideas as new issues. Record progress as a comment or a body edit, and close an issue when it is done.
- T01–T21 are issues #1–#21, with the old
Docs/Multithreading.md: the design for the job system and logging (issues #1 and #19), with what each step did and measured.Docs/RendererThreading.md: the renderer's frame and threading model for #3 (step 8 of #1).Docs/Renderer.md: #3's plan (one renderer for both backends: duplication measured, option A decided, the renderer reading the ECS components, order of work, the user's decisions).Docs/Math.md: the math library evaluation for #6 (benchmarks, recommendation, decisions).Docs/Ecs.md: the ECS for #31 (benchmarks, the user's decisions, the in-engine prototype); the rest is #52.Docs/Actors.md: the actor model for #59 (editor-first: prefabs, actors with typed parts and behaviors on top of the ECS, how they interact, decisions for the user).Docs/Reflection.md: scripts and components declaring themselves and their fields for #41 + #52 step 3 (prototype, compile times, recommendation, decisions).Docs/CSharpScripting.md: the CoreCLR experiment for #47 (hosting, C# scripts in the frame phases and #41's tables, interop cost, GC, hot reload, decisions).Docs/LinuxVulkanPortSteps.md: a commit-by-commit rebuild of port phases 0–5. The user may redo these steps themselves.Docs/VulkanPortDrivers/: scripted test drivers from Phase 6.Tools/CI/and.forgejo/workflows/: CI on Forgejo Actions (Tools/CI/README.md; the Linux jobs are listed at the top ofci.sh;publish-image.shpublishes the image;WindowsRunner.mdis the Windows runner, a VM the user runs since 2026-11-17).Tools/WinVM/: the Windows 11 development VM (issue #37; KVM, driven over SSH):winvm.sh synccopies the working tree toC:\primal,winvm.sh run '<PowerShell>'runs there (Invoke-MSBuild,Invoke-Interactivefor GUI programs). Use it for Windows checks that don't need the real GPU (D3D12 runs on WARP); reboot for performance and visual checks.winvm.sh screenshotshows the VM's own screen, never the host desktop. Complete since 2026-11-13: all four configurations + 8 EngineTest variants build, D3D12 runs on WARP, Vulkan on lavapipe (Invoke-GuiProgramruns the GUI tests).winvm.sh shutdownat the end of the day;winvm.sh revert clean-2026-11-13restores the provisioned state. The FBX SDK isn't used any more (#38: ufbx); the VM'sC:\winvm\baseline\holds the SDK-builtContentTools.dllandC:\winvm\fbx\the SDK's sample files, for comparisons.Tools/WindowsCompileDb/: compile databases that let clang-tidy check Windows-only code on Linux. The README covers setup and lessons learned.Tools/EditorAutomation/EditorUi.psm1: drives the WPF editor through UI Automation (Windows PowerShell 5.1): open a project, click, read the log panel.Tools/DebugOutput/Capture-DebugOutput.ps1: runs a Windows program under the debugging API and prints itsOutputDebugStringoutput (CRT leak report, D3D12 live objects). Usage in the files.- Code areas:
Engine/: the engine.Engine/ECS/: the entity component system (#31;Ecs.hAPI,World.cppcore).Engine/Graphics/Direct3D12,Engine/Graphics/Vulkan: one module per D3D12 module.Engine/Graphics/Shaders: the shared HLSL.EngineDLL/: the C API the editor calls.ContentTools/: asset import. Windows-only except geometry processing and FBX import (ufbx), which CMake builds as the static libraryContentToolsfor UnitTests.EngineTest/: four interactive test programs (entity components, window, surfaces, renderer).UnitTests/: the automated tests that need no window or GPU (doctest). One executable.GraphicsTests/: the automated tests that open windows and render (doctest), on Vulkan or D3D12. One executable.ShaderCompilerTool/: compiles the engine shaders at build time.PrimalEditor/: the WPF editor, frozen (bug fixes only) until the new C++ editor reaches parity.Editor/(new, #13): the C++ editor on Dear ImGui inside the engine (Docs/Editor.md).
Docs/Editor.md: the new editor's design for #13 (decisions, architecture, order of work).
Current state / next step (2026-11-24)
-
#13 redesigned (user, 2026-11-24): a C++ editor on Dear ImGui inside the engine, side by side with the frozen WPF editor, same project files (
Docs/Editor.md). Avalonia, Uno, Qt and C# ImGui bindings were rejected (section 4 there). Step 1, ImGui in the engine, done in the code 2026-11-24 (uncommitted parts;Docs/Editor.mdsection 9, plan doc A59 for the desktop): the renderer's UI pass (SurfaceFrame::ui), the platform's pointer/text/focus events, cursor, clipboard and display scale, the ImGui backend inEditor/UI/, theEDITOR_UIEngineTest. Step 2, offscreen views and theme v1, done in the code 2026-11-24 (uncommitted; plan doc A60): offscreen surfaces (graphics::create_offscreen_surface()), shown by the UI pass (UiDrawCommand::surface_id,imgui_backend::surface_image()), readback (graphics::request_readback()),Editor/UI/Theme.*(Inter + Lucide, fonts copied tox64/<Config>/fonts/). Next: step 3 (Docs/Editor.mdsection 6). Game UI on the same pass: #82 (after #13). The parented-window work is dropped (viewports render to textures). #78 and the plain view-model library of #61 are dropped. -
Was next until 2026-11-24: #13 as the Avalonia editor. #61, #63, #38 and #12 are done in the code (uncommitted, bullets below). Not needed before #13: #64, #68, #5, #10, #46, #39, #33, #71-#77. Open checks: plan doc A48-A58 (desktop), the CI image publish, the runner's desktop session. Right after #13: #81 (user, 2026-11-23), replacing DirectXTex's CPU BC7/BC6H encoders; until then BC7 uses
TEX_COMPRESS_BC7_QUICK. -
#12 ContentTools on Linux done in the code (2026-11-23, uncommitted;
Docs/ContentTools.mdsection 6, plan doc A58). Everything builds on both OSes: DirectXTex compiled from the downloaded sources (vcpkg gone; Linux adds DirectX-Headers and stb_image), no D3D11 (BC6H/BC7 on DirectXTex's CPU encoders, in strips on the job system), IBL on ContentTools' own Vulkan compute device (VulkanCompute.*,ContentTools.shaders→shaders/ContentTools.shaderpack, compiled by ShaderCompilerTool and, in the editor configurations, byInitializeEngine()). CMake: staticContentTools+ sharedlibContentTools.so(only the 8 exports). The Vulkan SDK is needed for ContentTools on Windows; UnitTests'/GraphicsTests' ContentTools parts are conditional on it. Tests: UnitTests "texture import" and "primitive meshes", GraphicsTests "image based lighting",benchmark:cases for both. Checked on Linux (clang, GCC, tidy, checks, ASan/UBSan, TSan) and in the VM (4 configurations, UnitTests, GraphicsTests both backends, editor tests, the editor's start). Open: A58 on the desktop, a comparison withC:\winvm\baseline\(needs a texture dump tool). The bullets below are the history, newest work near the top of each group. -
#38 ufbx done in the code (2026-11-23, uncommitted; plan doc A57): FBX import uses ufbx 0.23.1 (downloaded, hash-pinned:
cmake/PrimalDependencies.cmake+ContentTools/ThirdParty.targets); the FBX SDK is gone. Compared with the SDK importer on 9 files: the same up to n-gon triangulation; 10-20x faster. MikkTSpace is downloaded the same way (pinned to commit3e895b4; the vendored copy is gone). ContentTools' geometry + FBX import build on Linux (CMake targetContentTools, static, linked by UnitTests): the first piece of #12. Open: A57 on the desktop. Next: #12. -
#63 cause found, fixed in the code (2026-11-23, uncommitted; plan doc A56): "everything black" = scenes without lights (and no ambient light editor, #64). Decided (user): new scenes and the templates get a directional light (
Scene.AddsDefaultLight); lights added by any actor go into the scene's light set. Open: the desktop checks of A56 (the lit cube was not seen in the VM), then the rest of #63's list (FBX, material textures). Next: #38. -
#61 editor tests done in the code (2026-11-23, uncommitted; plan doc A55):
PrimalEditor.Tests(36 tests, run in the VM), the seams (engine API interfaces,EditorServices), no WPF types inActor/ActorPart, Windows CI step. Decided (user): seams now, the plain view-model library at #13; xUnit v3. A test found a real bug (removing a behavior duplicated another in the engine), fixed. Open: A55 on the desktop, the CI run after the push; then #63. -
Where things stand (2026-11-13): #30 (script registration +
GameScript), #37 (Windows VM) and #40 are done; the Windows VM (Tools/WinVM/) is where MSVC checks happen now, as edits are made. Next, in the user's order (roadmap #25, rewritten 2026-11-13): #18 → #17 items 1–4 → #4 groups A + C (C = decisions for the user) → #14 (Windows CI runner in the VM; no longer held) → #31 + #41 (decisions, before #3) → #3 + #4 group B → #28 (no longer held) → #5/#10 → content and editor (#35, #38, #39, #33, #12, #13, #16). #4 is now a checklist of what's left (updated 2026-11-13). Next Windows boot: plan doc A28 (FBX SDK 2020.3.11 on the desktop) and A29 (rebuild game projects for #30;REGISTER_SCRIPTis gone). -
#18 Vulkan function loader done (2026-11-14, uncommitted, branch
vulcan_loader): newEngine/Graphics/Vulkan/VulkanLoader.h/.cpp; nothing links the Vulkan loader on either OS. Checked on Linux (clang- GCC, ASan/UBSan, tidy, validation + sync validation; GPU-AV 0 errors) and in the Windows VM (4 configurations, D3D12 + Vulkan runs). Left for the desktop: plan doc A30 (Vulkan on the real GPU).
-
#17 items 1–4 done (2026-11-14, uncommitted, branch
unify_shader_logic): one tile size (LightCullingTileSize), one engine shader table, the binding contract inShaderBindings.h, and a build-time layout check of the shared structs ("Shaders" below). Checked on Linux (clang + GCC, Debug + Release, tidy, validation) and in the VM (4 configurations, D3D12 + Vulkan runs). Left for the desktop: plan doc A31. Items 5–7: next bullet. -
#17 items 5–7 done on Linux (2026-11-15, uncommitted, branch
unify_shader_logic), with the engine half of #35: shader packs (material shaders + variants per backend, compiled at build time), shader hot reload on both backends, Debug shader debug info, the Slang decision (stay on HLSL/DXC),MaxAverageLightsPerTileshared. The editor stores DXIL and SPIR-V per material variant (C#, blind). Checked on Linux (clang + GCC, Debug + Release, tidy, UnitTests 148, GraphicsTests 21 with validation, renderer test + a live hot reload) and in the VM the same day (4 configurations + 8 variants, D3D12 + Vulkan hot reload, the editor on both backends). #17 and #35 closed. Left for the desktop: plan doc A32 (end) / #46. Known limit: the distro DXC makes no DXIL on Linux (B13). Next per roadmap #25 (updated 2026-11-15): #4 groups A + C. New tickets: #45 Slang experiment, #46 shader follow-ups, #47 C# scripting prototype. -
#4 group A done (2026-11-15, uncommitted, branch
slang_experiment):std::to_underlyingfor the engine's enum casts, and 11 wrapper enums →enum class(ShaderType,InputCode,MaterialType,AssetType, the camera/light parameters, ...). Bitmasks, array-slot enums and enums nested in data structs stay wrappers on purpose (the list and reasons: #4).InputCode::invalidis the platform key maps' "unknown key". Checked on Linux (clang, GCC, tidy, tests) and in the VM (4 configurations + 8 variants, renderer test on both backends). Also fixed:gen_windb.pydidn't defineVK_NO_PROTOTYPES(since #18 every Windows database with Vulkan code failed to parse). -
#4 group C decided and applied (2026-11-15, uncommitted; the rules:
Docs/Preferences.md):utl::vectorstays (theUSE_STL_VECTORswitch and its workarounds are gone).free_listrelocated its items as bytes: fixed by #48 (2026-11-16, below).- Headers include what they use (gradual).
Tools/check_layers.pychecks the layer table (inci.sh checks).std::expectedfor fallible functions from now on (no.value()).- The game API headers (
EngineAPI/) include only a public set (checked by the same script).
Game projects whose scripts relied on what
CommonHeaders.hbrought in throughGameEntity.h(<mutex>,<unordered_map>,utl::free_list) need their own includes. Next per roadmap #25: #14 is on hold (user, 2026-11-16); #31 followed (next bullet). -
#31 ECS done and closed (2026-11-16, uncommitted, branch
ecs_test). Decided (user): an own archetype ECS, scripts stay objects (Docs/Ecs.mdsection 5,Docs/Preferences.md). The benchmarks behind it:Prototypes/EcsBench/(opt-in-DPRIMAL_ECS_BENCH=ON, CMake only; downloads EnTT and flecs pinned). The in-engine prototype (Docs/Ecs.mdsection 7):Engine/ECS/, and transforms are ECS components ("ECS" under Backend notes). Checked on Linux (clang + GCC, ASan/UBSan, TSan, tidy, UnitTests 159, GraphicsTests 21) and in the VM (4 configurations + 8 variants, UnitTests, renderer on D3D12 + Vulkan). Desktop: plan doc A34. The rest: #52. Next per roadmap #25 (reevaluated 2026-11-16): #6 (keep DirectXMath or switch), then #41 (with #52 step 3), #52 steps 1-2, #3. -
#6 math library decided and done (2026-11-17, uncommitted, branch
math_library), closed.Prototypes/MathBench/(opt-in-DPRIMAL_MATH_BENCH=ON; downloads GLM and rtm pinned) compared DirectXMath, GLM, rtm and an own SSE prototype. Decided (user): DirectXMath stays behindmath::; the storage types (v3,m4x4, ...) are the engine's own structs inMathTypes.h(no DirectXMath there any more);rotate3()is faster andmath::Frustumis new (Docs/Math.mdsection 6). Checked on Linux and in the VM. Next per roadmap #25: #41 (with #52 step 3). -
#52 steps 4-5, game API + editor + game.bin v2, done (2026-11-19, branch
better_script_reflection; code committed in9f34259, the 2026-11-19 fixes uncommitted) (Docs/Ecs.mdsection 10; decided: every recommendation of 10.6). Engine:EngineDLL/EditorSupport.*, the new EngineDLL exports,SaveGame, game.bin v2. The editor (scene tree, several scripts, reflection-driven field editor, the game's components, game.bin throughSaveGame) was driven in the VM on 2026-11-19 and works (results: plan doc A41,Docs/Ecs.md10.7); one fix there (a value the engine refuses no longer sticks,ReflectedComponent.cs). Linux all green (clang, GCC, ASan/UBSan, TSan, tidy,ci.sh checks, UnitTests 218, GraphicsTests 21) after two tidy fixes and a layer table entry (Content → Core, ECS). Desktop: plan doc A41, done on the desktop 2026-11-19 (issue #52; that session's doc edits weren't committed and are only on the desktop). Next: the actor model, #59 (user, 2026-11-19; before #3 on roadmap #25; #58 closed into it). Design noteDocs/Actors.md(rewritten 2026-11-19: editor-first, prefabs as the unit, our own names Actor/Behavior/Part/Prefab); all 12 decisions of its section 16 decided (user: every recommendation; summary inDocs/Preferences.md"Actors"). Next: its step 1, one engine as a shared library. Then #3. -
#59 step 1, one engine library, done (2026-11-19, branch
actor_based_model, uncommitted;Docs/Actors.mdsection 17). The engine isPrimalEngine.dll/libPrimalEngine.so; a game executable also linksEngineMain(itsmain()/WinMain). Exports are markedPRIMAL_API(Linux: hidden visibility, so a missing mark fails the Linux link). One reflection registry and one ECS for every binary: a header's type registered again by the same C++ type (TypeInfo::identity) is no error; types a library registers betweenreflect::begin_library_load()andend_library_load()are copied so they outlive it. EngineDLL no longer uses game DLL exports; log forwarding is gone. Checked on Linux (clang, GCC, tidy, ASan/UBSan, UnitTests 218 with a realdlopengame library, GraphicsTests 21) and in the VM (4 configurations + 8 variants, UnitTests, renderer test both backends, ScriptTest's DLL and executable, the editor). Workaround:JobTests.cppwithout/GL(MSVC 14.52 LTCG crash, plan doc B16). Desktop: plan doc A42. Exports are marked member by member (no C4251 pragma).UnitTests/GameExecutable/is a test game executable (CTest labelgraphics, run byci.sh's graphics step). Shipping one static executable: #60 (later). One export macro while the engine is one library (Docs/Preferences.md). -
#59 step 2, the actor runtime, done (2026-11-19, branch
actor_based_model, uncommitted;Docs/Actors.mdsection 18).Engine/EngineAPI/Actor.h(game API) +Engine/Actors/(new layer):actor::Actor,Part,Behavior,ActorOwner,ActorRef/PartRef,spawn()/destroy(), ticking in the frame. "Actors" under Backend notes. Checked on Linux and in the VM (results: the plan doc A43). Next: step 3, the engine's parts (MeshPart, lights,CameraPart) and their components; ask the user before starting it.ActorRef/PartRefconvert from a pointer implicitly (user, 2026-11-19). Step 1 is committed in226c139, step 2 in9fcb52b. -
#59 step 3, the engine's parts and the scene sync, done (2026-11-20, branch
actor_based_model, committed in0f0115b;Docs/Actors.mdsection 19).render::MeshRenderer, the four light components andrender::Camera(Engine/EngineAPI/RenderComponents.h), the part classes that write them (RenderParts.h), andgraphics::scene::sync()(Engine/Graphics/SceneSync.h), which makes the renderer's objects from them each frame (decided by the user: an adapter at render time, the renderer test converted to actors). Also fixed:actor::destroy()of an empty reference asserted,destroy_all()was quadratic, and both Linux Release builds failed at the step 2 commit (Entity.cpp). Checked on Linux (clang + GCC, Debug + Release, ASan/UBSan, tidy, UnitTests 239, GraphicsTests 22, renderer test) and in the VM (4 configurations + 8 variants, UnitTests, renderer test exit 0 on D3D12 and Vulkan). Desktop: plan doc A44, checked by the user the same day (the picture right). Next: step 4, reflection (started 2026-11-20). -
#59 step 5, prefabs and game.bin v3, done (2026-11-20, branch
actor_based_model, committed indb7854c;Docs/Actors.mdsection 21).Engine/Actors/Prefab.h(actor records,capture(), building with default-part matching, prefab registry and assets, instance overrides),actor::spawn_prefab()/PrefabRefin the game API, game.bin v3 (plain entities, prefabs, actors). AlsoFieldType::s64/u64(user) andprefab_ref. Checked on Linux (clang + GCC, Debug + Release, ASan/UBSan, tidy, UnitTests 252, GraphicsTests 22, the test game) and in the VM (4 configurations, UnitTests, renderer test on D3D12 + Vulkan). Desktop: plan doc A46. Next: step 6, the editor, on the Windows desktop (next bullet). -
#3 step 3, one frame for every surface, done (2026-11-23, committed in
a1938dc;Docs/Renderer.mdsection 10). Decided (user): one call per frame,graphics::render_frame(std::span<const SurfaceFrame>);Surface::render()is gone. Both backends: one fence wait, one submission and one present call per engine frame; each surface has its own gpass render targets, barrier tracker, gpass cache and light buffers. The editor's export isRenderFrames(count, ids, cameras, light sets), called once per loop byRenderSurfaceHost.cs. Four windows: 1.92 → 1.84 ms (noise; RADV). Checked: plan doc A50. -
#3 step 4 done (2026-11-23, committed in
5b936e6;Docs/Renderer.mdsection 11). A surface is prepared first (render targets, constant buffer data, light buffers,delight::prepare()resizes the light culling buffers), thengpass::record_batches()records both scene passes' batches in one parallel pass, then the frame's list. D3D12'sExecuteIndirectpath andPRIMAL_D3D12_DRAW_INDIRECTare gone. Four windows 1.60 → 1.28 ms, 6,400 items 0.78 → 0.70 ms (RADV). Checked on Linux and in the VM (plan doc A51). -
#3 step 5 done (2026-11-23;
Docs/Renderer.mdsection 12). Render items are collected in jobs (per surface and per 1,024 items) under shared content locks (std::shared_mutex);gpass::prepare()only allocates and sets addresses;gpass::plan_jobs()/run_job()put every surface's data fill and batches into one parallel pass. Four windows 1.28 → 0.84 ms, 6,400 items 0.70 → 0.60 ms (RADV).scene::prepare()per chunk was left out (0.04 ms). Checked on Linux (also TSan) and in the VM (plan doc A52). Committed inaa9c480(step 4:5b936e6). -
#28 done in the code (2026-11-23, uncommitted; plan doc A54):
GraphicsTests.vcxproj, the tests on the backendPRIMAL_GRAPHICSnames,graphics::validation_stats()for both backends, a D3D12 restart hang fixed (B17), andci.sh coverage(clang source-based coverage,PRIMAL_ENABLE_COVERAGE; acoveragejob uploads the HTML). Windows CI runs the graphics tests when the repository variablePRIMAL_CI_GRAPHICSistrue(the runner needs a desktop session first). The CI image tag is2026-11-09-d(addsllvm): publish it before the push. #28's items 3, 5-7 are #74-#77. Next: see the first bullet of this section. -
#3 step 6 done (2026-11-23, uncommitted;
Docs/Renderer.mdsection 13).vkx::set_name()/d3dx::set_name()replace theNAME_*_OBJECTmacros; per-pass debug markers (vkx::ScopedMarker,d3dx::ScopedMarker);std::spanat the content reads. Duplication measured again withTools/measure_backend_duplication.py: 44% → 34% identical, 1,653 fewer backend lines. RAII left for #67/#71. Follow-ups #71-#73 created. #3's code is done; it stays open for the desktop checks: one list, plan doc A53. Next: #28 (done, bullet above), then the #13 path (first bullet of this section). -
#3 step 2 done (2026-11-22, committed in
54bfffe;Docs/Renderer.mdsection 9), with #52 step 6: the renderer reads the render components: cameras (camera::camera_of()), lights (light::rebuild()) and meshes (graphics::scene,Scene.*, wasSceneSync.*) each frame; the light/camera/render-item API,graphics::Camera/Lightand the old geometry component are gone (decided by the user: every recommendation of section 9). Checked on Linux and in the VM (also the editor). Desktop: plan doc A49. -
#3 step 1 done (2026-11-21, committed in
54bfffe;Docs/Renderer.mdsection 8): camera, light sets + the light API, engine shader loading andframe_buffer_countare shared inEngine/Graphics/(Camera.*,Lights.*,EngineShaderFile.*,FramesInFlight.h); each backend keeps its light buffers (derived fromlight::LightBuffers) and its byte code wrapper.D3D12Camera.*was moved,VulkanCamera.*deleted: the user stages those. Checked on Linux and in the VM. Desktop: plan doc A48. -
#3 planned (2026-11-21;
Docs/Renderer.md). Decided (user): option A (shared CPU-side modules, the frame packet as the boundary; render graph #66 and RHI #67 later), the renderer reads the ECS components (#52 step 6;SceneSyncand the object API go), every other recommendation (section 7). Plan: section 6. Started 2026-11-21 (user). -
#59 step 7, conversion, done (2026-11-21; desktop, then the Linux checks and the VM; code in
8f333d9, the Linux fixes uncommitted;Docs/Actors.mdsection 23). #59 is closed. Next per roadmap #25: #3 (ask the user). Decided (user): entity scripts are removed (EntityScript,PRIMAL_SCRIPT(), script components and their exports, scripts in game.bin, now v5); old scenes' plain entities are dropped on load with a warning (the plain-entity UI and the old light entities are gone); one New Class dialog (Behavior, Actor, Part, Game Script). Done and checked on the desktop (4 configurations, UnitTests 238, renderer test, the editor driven: warning, New Class, build, Run, clean exit).game_entity::Entityhas transform setters now (they wereEntityScript's). Linux checks done 2026-11-21 (all green; fixes uncommitted: formatting, one tidy fix, the test game's game.bin v5). The VM's ScriptTest is converted to behaviors and loads in the editor. Ambient light in editor scenes: issue #64. -
#59 step 6 done (2026-11-21, desktop, uncommitted). Was "in progress" below.
-
#59 step 6 in progress (2026-11-20 evening, desktop, uncommitted; next session starts here). A42/A45/A46 passed. Decided (user): every recommendation (
Docs/Actors.mdsection 22: editor scenes are actors only, C# holds the values, saving a prefab rebuilds open instances, new-script template cleanup). Slices 1-4 done and driven (outliner, details, Add Actor, undo, game.bin v4 with actor attachments and without the editor's viewport cameras: section 22 "Progress"); slice 5, prefabs, done and driven 2026-11-21 (UnitTests 255; resultsDocs/Actors.mdsection 22); decided with every recommendation (.assettype, Edit Prefab as a temporary scene, decision-6 overrides only). Every game project must be run once from the editor again (v3 is refused). Nullable is on for the whole editor project (472 warnings left;Actor.cs/ActorView.xaml.csclean). C# tests: issue #61. The C++ of slice 4 (ContentLoader.*,EngineDLL/Common.h,EngineAPI.cpp,EntityAPI.cpp,UnitTests/PrefabTests.cpp,ContentLoaderTests.cpp) still needs the Linux checks (clang, GCC, tidy, sanitizers). New C# rules (user, 2026-11-20; full textDocs/Preferences.md"C# (the editor)", IDE checks.editorconfig[*.cs]): newer C# syntax, braces on everyif/else/loop body, LINQ in method syntax only, and nullable reference types:#nullable enablein new and changed files,?on what may be null, null handled at the access, never silenced (!,#pragma,= null!). New and touched code only, no pass. Still to do:Components/Actor.csandActorView.xaml.cswere written before the nullable rule (enable + fix). Driving the editor on the desktop: seeTools/EditorAutomation/EditorUi.psm1(lessons of 2026-11-20 at the top). -
#59 step 6, the editor: continues on the Windows desktop (user, 2026-11-20). Handoff for that session:
- Pull
actor_based_model(code of steps 1-5 in226c139..db7854c; check thatDocs/and this file are committed too). Build the four configurations. - Desktop checks first: plan doc A45 and A46 (A44 is done). Every game project must be run once from the editor (Ctrl+F5) to write game.bin v3; a v2 file is refused with "build the game again".
- Read
Docs/Actors.mdsections 6, 9, 10, 12, 15 (step 6) and 21 (the record, prefab assetsPPFB, overrides, game.bin v3). The engine side for the editor isEngine/Actors/Prefab.h(capture(),spawn(),save_asset()/load_asset(),capture_overrides()); EngineDLL needs new C exports for it (EDITOR_INTERFACE, UTF-8, the Avalonia constraints).SaveGamewrites only plain entities so far. - Step 6's scope: outliner and details for actors (section 9), prefab editing, save as prefab, the content browser
drag, Add Actor. 64-bit fields stay text in the editor, never
double(Docs/Preferences.md). - On the desktop the editor runs directly (real GPU, the user watches); the Linux checks (clang, GCC, tidy,
sanitizers,
ci.sh checks) of the C++ written there come after, on Linux or through CI on push: plan doc Open items C.
- Pull
-
#59 step 4, reflection, done (2026-11-20, branch
actor_based_model, committed in4bba32b;Docs/Actors.mdsection 20).PRIMAL_ACTOR()/PRIMAL_PART()/PRIMAL_BEHAVIOR()(the generated body writesis_a()/class_name()),spawn_by_name()/add_part_by_type()/add_behavior_by_type(),ActorRef/PartReffields (stored as entities), log helpers on actors and behaviors, the render components and engine parts reflected. Checked on Linux (clang + GCC, Debug + Release, tidy, UnitTests 245, GraphicsTests 22) and in the VM (4 configurations + 8 variants, UnitTests, renderer test on D3D12 + Vulkan). Desktop: plan doc A45. Next: step 5, prefabs and files (ask the user first). -
#52 step 2, scripts and components, done (2026-11-18, uncommitted) (
Docs/Ecs.mdsection 9): scripts write transforms directly (#57 fixed: 17.2 → 0.32 ms for 10,000 moving scripts),Entity::get<T>()/write<T>()/has<T>()/queue_add_component(), several scripts per entity (add_script(),script<T>()),late_update(),Ecs.hin the game API. Desktop: plan doc A40. #58 (new): entity trees from code and prefabs. Next per roadmap #25: #3 (with #52 step 6), or #52 steps 4-5 first: ask the user. -
#52 step 1, the transform hierarchy, done (2026-11-18, branch
better_script_reflection, uncommitted) (Docs/Ecs.mdsection 8; decided: world space for the short names,local_*relative to the parent, reparenting keeps the world transform, removing a parent removes its children, a depth-sorted child list).transform::Parent+HierarchyDepth,game_entity::set_parent()/queue_set_parent(),EntityInfo::parent, children updated level by level on the job system. Checked on Linux (clang, GCC, TSan, ASan, tidy, UnitTests 206, GraphicsTests) and in the VM (4 configurations, UnitTests, renderer on D3D12 + Vulkan). Desktop: plan doc A39. Next: #52 step 2 (scripts reaching components; #57 there). -
#41 reflection done (2026-11-18, branch
better_script_reflection, uncommitted), with #52 step 3. Decided (user;Docs/Reflection.mdsection 7,Docs/Preferences.md"Reflection"): the generatorPrimalReflectGenwith Unreal-style markers ("Scripts" below), C++26 reflection later. #47 (C#) was decided against the same day: the experiment is in the history on branchcore_clr(8ec6a81,Docs/CSharpScripting.md);Prototypes/CSharpScripting/here holds only ignoredbin//obj/folders, safe to delete. Done: the runtime (one registry for scripts and components), the generator (ReflectionTool/) with CMake (cmake/PrimalReflection.cmake) and MSBuild (Engine/Reflection.targets) integration, every script converted, the editor's templates, ECS components by name (ecs::find_component()), the transform components reflected. Checked on Linux (clang + GCC, tidy, UnitTests 192, GraphicsTests 21) and in the VM (4 configurations, UnitTests, a template game project). Desktop: plan doc A38 (the editor's blind C#). Open: the editor ABI andgame.bin(#52 step 5). Next per roadmap #25: #52 steps 1-2. -
#14 Windows CI done and closed (2026-11-17), with the move to Forgejo. Workflows are in
.forgejo/workflows/;windows.ymlruns on the user's Windows runner VM (host mode, labelwindows, one job at a time;Tools/CI/WindowsRunner.md): four configurations, EngineTest variants, UnitTests, the entity-components test, a build without Vulkan. Linux and Windows both green on the first run with the fixes. The CI image is in Forgejo's registry (Tools/CI/publish-image.sh). Next per roadmap #25: #41. -
#48 done and closed (2026-11-16, uncommitted, branch
ecs_test):utl::free_listkeeps its items in blocks that never move (8, 16, 32, ... slots), with a live bit per slot: any type can go in, references stay valid,remove()of a dead id is refused in every build, the destructor andclear()destroy what's left.ShaderGroupholds its map directly. Lookups cost ~1.4 ns (0.2-0.5 before); a 6,400-item frame is unchanged. Checked on Linux (all CI jobs) and in the VM (4 configurations, UnitTests, renderer on D3D12 + Vulkan). Windows:(std::max)in headers that<windows.h>may precede. -
#45 Slang experiment done and closed (2026-11-15, branch
slang_experiment). Decision (user): stay on DXC, keep the Slang path as a tested opt-in. Slang 2026.18.2 (distroshader-slang) compiles every engine and material shader to SPIR-V next to DXC: opt-in with CMake-DPRIMAL_ENABLE_SLANG=ONandPRIMAL_SHADER_COMPILER=slangat run time (EngineDLL/SlangCompilation.h, Linux only). Results on #45: validation, sync validation and GPU-AV clean, GraphicsTests 21/21, the layout check passes, RADV's final ISA practically identical (no frame-time difference), compiles ~6x slower (~50 ms per shader), no DXIL on Linux (same DXC crash, B13). Kept for both compilers: the heap at set 1 binding 2 (ShaderBindings.h) and typed heap casts (Texture2D<float4>(ResourceDescriptorHeap[i])). Checked in the VM; desktop: plan doc A33. Committed (908057d). CI (2026-11-15, uncommitted):ci.sh slang(build with Slang, recompile the shaders with it, unit + graphics tests withPRIMAL_SHADER_COMPILER=slang), aslangjob inlinux.yml, a Slang pass inci.sh tidy,shader-slangin the image (tag2026-11-09-c, same snapshot). Run in a local build of the image;Tools/CI/publish-image.shmust run before the push (not published yet). -
#2 closed out (2026-11-14, uncommitted, branch
code_style): CLion inspection review (comment on #2). Small fixes inLog.cpp,Renderer.cpp,Input.cpp,ContentToEngine.cpp,VulkanContent.cpp,D3D12Content.cpp,EngineTest/Test.h. New:Docs/Preferences.md(all style and workflow preferences, imported below), the shared CLion profile/scope/dictionary in.idea/(.gitignorenow tracks only those),Docs/Inspections/ignored. New rule:consteverywhere it fits, in new and touched code. -
Uncommitted (2026-11-13, A25/A26 fixes): clang-format in
Log.h,Log.cpp,D3D12Core.cpp,D3D12Gpass.cpp; clang-tidy fixes inUnitTests/LogTests.cpp,EngineTest/RenderItem.cpp,D3D12Gpass.cpp(blind); newTools/WinVM/(untracked); FBX SDK path as a property (ContentTools.vcxproj,FbxImporter.cpp,README.md,Tools/CI/WindowsRunner.md). Code before that is committed (HEAD00d1d6e);Docs/,CLAUDE.md,Tools/CI/WindowsRunner.mdandTools/WindowsCompileDb/README.mdare staged, not committed. The bullets below are the history: their "uncommitted" marks are outdated, and their "Not yet seen by MSVC" notes are all settled. -
Windows session 2026-11-11: A13, A14, A16, A17.1 checked with MSVC (plan doc "Windows session 2026-11-11"). All 4 configurations + the 8 EngineTest variant builds clean,
UnitTests.exe83/83 in Debug and Release, both renderer tests exit 0 (Vulkan validation clean, picture right per the user). One fix (uncommitted):ContentToEngine.cppgpu_id_from_fake_pointer()lost itsconstexpr(MSVC C3615:reinterpret_castin aconstexprfunction); clang-tidy re-run on Linux 2026-11-11: clean. Editor run OK too (user: FBX/texture import, primitive mesh, materials, reload), so A13 is closed. A generated script project builds clean with MSBuild (A14.3). Issues #2, #20 and #21 are closed (CI was green one3b428b). Left on Windows: the editor building and loading a script DLL itself (A12.5, needs Visual Studio), A16.4 (scene naming a missing script, optional), the Windows CI runner (A15, #14) andGraphicsTestson Windows (#28); the user holds #14 and #28 until after the deeper rewrites. #22 (0x80000003) closed as not reproducible. The "Not yet seen by MSVC" notes below are settled by this. -
Issue #23 done and closed (2026-11-11, uncommitted): the editor offers to update an old game project's
.vcxprojon load (PrimalEditor/GameProject/GameProjectUpgrade.cs, called fromProject.Load(); plan doc B11). Its target values (v145,stdcpp23, the$(PRIMAL_ENGINE)paths, theVulkan.propsimport) are constants: change them together with the fourMSVCProjecttemplates. -
A12 (MSVC check of the Linux-only work) is done, incl. FBX/texture import and primitive mesh in the editor. Only the in-editor script build is left (needs Visual Studio; the user doesn't want it installed for now). Old game projects retargeted to v145 + C++23 (B11; 2 still have old-API scripts). Results: plan doc "Windows session 2026-11-09" under Phase 6. Fixes made there (uncommitted):
EngineTest.vcxprojtest defines +/W4,Engine/Vulkan.props/IGNORE:4199,FbxImporter.cppconst, game project templates → v145 +stdcpp23, script template[[maybe_unused]] dt, all engine.vcxprojstdcpplatest→stdcpp23. -
Windows machine notes: VS 18 BuildTools only (no IDE, no debugger, no
nuget.exe: restore withmsbuild /t:Restore /p:RestorePackagesConfig=true). User env varPRIMAL_ENGINEnow points at Primal_Plus. -
T02
/WXdone on Windows (2026-11-09; opt out with/p:PrimalWarningsAsErrors=false). -
T02 cast pass done on Linux (2026-11-09, uncommitted): no C-style casts left,
modernize-avoid-c-style-castis on,gen_windb.pyuses/std:c++23preview. Details: T02 ticket "Done, part 4". Not yet seen by MSVC: plan doc Open items A13 is the next Windows session's checklist (FbxImporter.cppwas edited without any compiler). -
T20 done on Linux (2026-11-09, uncommitted): no include cycles, every header compiles alone, includes are sorted. Not yet seen by MSVC: plan doc Open items A14.
-
T14 CI, Linux part done (2026-11-10): Gitea Actions,
.gitea/workflows/linux.yml→Tools/CI/ci.shin the image fromTools/CI/Dockerfile. Runs on the Gitea runner on every push.windows.yml.disabledis commented out and never run (Open items A15). How-to: the comments at the top ofTools/CI/ci.sh. -
Remotes (2026-11-10;
originmoved to Forgejo 2026-11-16):originis the user's Forgejo (primary, CI runs there),githubthe public mirror,upstreama private Gitea mirror of Arash's repo (push disabled). -
T21 automated tests done on Linux (2026-11-10, uncommitted):
UnitTests/with 83 doctest cases (ids,utl::vector,utl::free_list, math, blob streams, entities/transforms/scripts, input,load_game, thePSHBshader file) andGraphicsTests/with 15 (windows, surfaces, a hand-made scene through the whole Vulkan renderer; no assets needed).ci.sh buildandsanitizersrun both, the graphics tests on Xvfb + lavapipe with validation on. Not yet seen by MSVC: plan doc Open items A16 and A17 (UnitTests.vcxprojis blind;GraphicsTestshas no.vcxproj: issue #28, with the other follow-ups). Issue #21 closed 2026-11-11. -
Issue #6 first step done on Linux (2026-11-11, uncommitted): DirectXMath is named only in
Engine/Utilities/MathTypes.hand the newMathSimd.h(math::vec,math::matand thinmath::functions, plusquat_from_euler(v3) -> v4,to_v3(),to_v4()).Tools/check_math_usage.pyenforces it inci.sh checks. The storage types are still DirectXMath aliases, and keep-or-switch is still open in #6. 90 unit tests now. Not yet seen by MSVC: plan doc Open items A18 (thevecoperator lookup andXM_CALLCONVcan only be checked there; the D3D12 and ContentTools edits were blind). -
Issues #1 + #19: design proposal written (2026-11-11, branch
job_system):Docs/Multithreading.md. Nothing is implemented; its section 8 lists the decisions the user still has to make, section 9 the order of work (logging first). All decided by the user 2026-11-11 (own job system, no fibers, scripts stay serial for now, a Vulkan-only prototype of parallel recording at the end of #1). -
#19 logging, steps 1 and 2 done on Linux (2026-11-11, committed): everything logs through
primal::log(Engine/Core/Log.h/.cpp):log::info(log::Category::vulkan, "text {}", value). Logger thread, console sink (stderr + debugger on Windows), log file (primal.log/EngineTest.lognext to the executable), ring buffer,DrainLogin EngineDLL with a timer in the editor.Tools/check_log_usage.py(inci.sh checks) fails on directOutputDebugString/printf/std::cout. 100 unit tests. Not yet seen by MSVC, and the editor's C# is unbuilt: plan doc Open items A19. Still open in #19: a log helper for game scripts, and routing the D3D12 debug layer's messages into the log. -
Module trial (2026-11-11, committed in
e9efb4f): logging was converted to a module and reverted (see "Modules" below). Kept from it: CMake 3.28, the module steps inci.sh tidyandgen_windb.py,Engine/Modules.propsand its imports in five.vcxprojfiles (blind). -
#1 step 3 done (2026-11-12, committed
e9efb4f): ThreadSanitizer optionPRIMAL_ENABLE_TSAN, presetlinux-tsan,ci.sh tsanand atsanjob inlinux.yml(made during the module trial; the user kept them).ci.sh tsannow also runs the graphics tests;Tools/CI/tsan.suppsuppresses lavapipe and LLVM. The 28 reports were one real lock-order inversion (DescriptorHeap::free(), both backends, plan doc B12; D3D12 blind: A19.8), now fixed. Checked in the CI image (twice clean) and on RADV. -
#1 step 4 done on Linux (2026-11-12, committed
bb86a00): the job system, the first named module.Engine/Core/Jobs.ixx(primal.jobs) +Jobs.cpp, 12 tests inUnitTests/JobTests.cpp(112 in all). Clean on clang and GCC, Debug and Release, clang-tidy (Linux and Windows databases) and TSan. Nothing calls it yet. Differences from the design:Docs/Multithreading.mdsection 9, step 4. Not yet seen by MSVC: plan doc Open items A20 (the first module on MSVC, and the first real use ofEngine/Modules.props). -
#1 step 5 done on Linux (2026-11-12, committed
1303f06): the first users of the job system. The pool runs in the game'smain(), EngineDLL, EngineTest and GraphicsTests. Loader threads → background jobs, eager transform matrices withparallel_for(transform::update_matrices()), per-worker script caches, per-object data withparallel_for(both backends). Measured: matrices 3.5-4x faster with 100,000 entities; loading and render preparation unchanged at today's sizes (numbers inDocs/Multithreading.mdstep 5 and issue #1). ContentTools keeps its threads. Not yet seen by MSVC: plan doc Open items A21 (D3D12 and EngineDLL parts blind). -
#1 step 6 done on Linux (2026-11-12, committed
5be9776): explicit frame phases. Moduleprimal.frame(Engine/Core/Frame.ixx):frame::run(dt, render)= sync point, scripts, transforms, render. Entity command queue (game_entity::queue_create/queue_remove),TicketMutex→std::mutexin EngineDLL (blind). Details and what was left out on purpose:Docs/Multithreading.mdstep 6. Not yet seen by MSVC: plan doc Open items A22. The editor renders on its own thread (RenderSurfaceHost.cs), outside the pool: A21.2 was corrected. -
#1 step 7 done on Linux (2026-11-12, uncommitted): parallel command recording on Vulkan (prototype). More than 512 render items are recorded in jobs into secondary command buffers (
record_pass()inVulkanGPass.cpp), with command pools per thread and frame (VulkanCore.cpp); the gpass cache is per surface. A frame with 6,400 items: 3.3 ms → 2.25 ms; recording itself ~4x faster, render preparation (~1.5 ms) is now the largest cost. Numbers:Docs/Multithreading.mdstep 7.PRIMAL_VULKAN_PARALLEL_RECORDING=0turns it off.Engine/Utilities/Threading.hdeleted (stage it withgit rm; until thenci.sh checksfails on it). Not yet seen by MSVC: plan doc Open items A23. -
Script lifetime (2026-11-12, uncommitted):
begin_play()was never called; now it runs at the sync point after a script is created, and the newend_play()runs before a script is removed (only after itsbegin_play()). 6 tests inUnitTests/FrameTests.cpp. The editor's new-script template hasend_play()(blind). Registration rework and script kinds: issue #30. Not yet seen by MSVC: plan doc Open items A24. -
CMake presets per EngineTest test (2026-11-12):
linux-debug-renderer,-surfaces,-window,-entity-components,linux-release-renderer; CLion shows them as profiles. -
#1 step 8 done (2026-11-12):
Docs/RendererThreading.md, the design note for #3. #1 is done on Linux; it stays open (labelneeds-windows-check) until the MSVC checks A20-A24 pass. -
Windows session 2026-11-12: A18–A24 checked with MSVC (plan doc "Windows session 2026-11-12"). All 4 configurations + 8 EngineTest variants clean,
UnitTests.exe125/125 Debug and Release, renderer tests D3D12 + Vulkan exit 0 (picture right per the user), editor fine (user). Fixes (committed in2260632):MathSimd.hC4459 (tolerance),ContentToEngine.cppconstexpragain (the 2026-11-11 fix was lost),Log.cppC4530 (<chrono>pragma +PRIMAL_LOG_HAS_EXCEPTIONS),Modules.propsC5050 off in importers. Next on Linux: plan doc Open items A25 (clang-format/clang-tidy/GCC re-check of those and of the #19 work below). Then #30 or #3 (Docs/RendererThreading.md); #31 (ECS evaluation: DOTS, Unreal Mass, EnTT, flecs) comes after #30. -
Same session, later (committed in
2260632): the editor builds and runs game code without Visual Studio (MSBuild + VS Code,PrimalEditor/GameDev/VisualStudio.CommandLine.cs; A12.5 done), a built game finds the engine shaders (copied on Run), and #19's last two parts: script log helpers (log_info()etc. onEntityScript), game DLL log forwarded into the editor, D3D12 debug layer messages in the log. #19 closed (2026-11-13, all checked on Windows). Also fixed: an editor crash on a game code reload (RemoveScriptComponents), and games with meshes no longer crash on Run (meshes left out ofgame.binfor now: issue #33). Details: plan doc "Windows session 2026-11-12", second half. -
D3D12 parallel recording + direct draws (2026-11-13, committed in
577e005): D3D12 now draws directly by default (ExecuteIndirectwas 2.5-4x slower on the GPU;PRIMAL_D3D12_DRAW_INDIRECT=1for it) and records batches in jobs like Vulkan. Both backends' per-frame constant buffer grows with the item count (it crashed above ~4,000 objects). Stress optionPRIMAL_TEST_EXTRA_SPHERES. Numbers: plan doc "Windows session 2026-11-12", second half. Linux check: plan doc Open items A25 and A26. -
Windows checks finished (2026-11-13). A19.4 passes (no CRT leaks;
Tools/DebugOutput/Capture-DebugOutput.ps1capturesOutputDebugStringwithout a debugger installed). A16.4 passes. A23.3 (the editor on Vulkan) fails: material shaders in assets are DXIL only, issue #35. Left on Windows: #14 and #28 (held by the user then; no longer held since 2026-11-13), #33 and #35 (new work, later). Old test game projects are left as they are. -
Driving the editor from scripts:
Tools/EditorAutomation/EditorUi.psm1(Windows PowerShell 5.1, UI Automation, no screenshots). Ask the user only for what a script can't do, in short numbered steps. -
Docs/,CLAUDE.mdandTools/WindowsCompileDb/README.mdare staged but not committed yet (2026-11-13). The user knows.
Preferences and code style
All of the user's standing preferences (working rules, language, naming, const, modules, formatting, CLion
inspections and their known false positives) are in Docs/Preferences.md, imported here so every session loads it.
Add new decisions there, not here.
@Docs/Preferences.md
Scripts (engine API)
- Reflection (#41, 2026-11-18;
Docs/Reflection.md): types declare themselves with markers thatPrimalReflectGen(ReflectionTool/) reads before compiling:PRIMAL_COMPONENT(),PRIMAL_GAME_SCRIPT(),PRIMAL_ACTOR(),PRIMAL_PART(),PRIMAL_BEHAVIOR()before a class (options:.name = "..."),PRIMAL_ENUM()before anenum classat namespace scope,PRIMAL_GENERATED_BODY()inside each class,PRIMAL_PROPERTY(.min = 0.f, .tooltip = "...")before a member. Components reflect every field, classes onlyPRIMAL_PROPERTYones.PRIMAL_SCRIPT()is gone (#59 step 7): the generator says to make the class a behavior. The file's last include is#include "<file name>.generated.h". A new file with markers goes inprimal_reflect(<target> ...)in itsCMakeLists.txt; MSBuild runs the generator on every item of a project that importsEngine\Reflection.targets(a header must be aClIncludeitem). Field types:bool,s32,u32,s64,u64(name hashes, seeds),f32,v2-v4,m4x4,game_entity::Entity,PRIMAL_ENUM()enums,std::arrayof those; in classes alsostd::vector/utl::vectorof those andstd::string(not in components: they allocate). No C arrays. One registry for every reflected type (Engine/EngineAPI/Reflection.h,Engine/Reflection/Reflection.cpp), keyed by the FNV-1a hash of the name: the class name, or.name(the engine's own types use qualified names:transform::Position). A duplicate name is logged as an error in every build and the first registration stays.reflect::find_type(),ecs::find_component(name_hash)(the same id ascomponent_id<T>()).PRIMAL_SCRIPT(Type);after the class is gone (no backwards compatibility): game projects are converted by hand. Actor classes:PRIMAL_ACTOR(),PRIMAL_PART(),PRIMAL_BEHAVIOR()(Docs/Actors.mdsection 20); theirPRIMAL_GENERATED_BODY()goes first in the class (it ends withprivate:), and their fields may also beactor::ActorRef<T>/PartRef<T>(in components too). - Behaviors are the per-object logic (entity scripts are gone since #59 step 7):
PRIMAL_BEHAVIOR()+class X : public actor::Behaviorwithusing Behavior::Behavior;, reaching the actor withowner(). Plain entities have no per-entity logic: ECS systems are theirs, andEntity::set_position()etc. write their transforms. - Game scripts:
PRIMAL_GAME_SCRIPT()+class X : public script::GameScriptfor game-level logic with no actor (game mode, managers). Every registered one runs: created andbegin_play()at the first frame's sync point (before actors begin play),update(dt)before the actors,end_play()+ destroyed byscript::end_game_scripts()(the game calls it inengine_shutdown()before unloading its entities); a later frame starts them again. The editor runs no frames, so it never starts them. Game scripts share the name registry with every other reflected type;ScriptBasehas their name and log helpers. - Game DLL ABI (since #59 step 1): the game DLL links
PrimalEngine.dlllike EngineDLL, and exports nothing: its classes and components register in the engine's registry while EngineDLL loads it (reflect::begin_library_load()/end_library_load()aroundLoadLibrary,release_library_types()beforeFreeLibrary), and EngineDLL finds them there by name. A game project still linkingEngine.libdoesn't build: the editor's upgrade replaces it withPrimalEngine.lib;EngineMain.lib;.
Building and running
Linux (CMake presets; all write to x64/<Config>/, so the last build wins)
cmake --preset linux-debug -DPRIMAL_ENGINE_TEST=RENDERER # or ENTITY_COMPONENTS, WINDOW, SURFACES, EDITOR_UI
cmake --build --preset linux-debug
-
Or a preset per test, each with its own build folder (in CLion: one CMake profile each, then run the
EngineTestconfiguration):linux-debug-renderer,linux-debug-surfaces,linux-debug-window,linux-debug-entity-components,linux-debug-editor-ui,linux-release-renderer. They still write tox64/<Config>/. The editor UI test (Dear ImGui's demo) stops afterPRIMAL_TEST_FRAMES=<n>frames when set. -
Presets:
linux-debug,linux-release(clang) andlinux-gcc-debug,linux-gcc-release. -
The engine is a shared library,
x64/<Config>/libPrimalEngine.so(Windows:PrimalEngine.dll+.lib), next to the programs, which find it throughRUNPATH $ORIGIN. New engine API that another binary calls getsPRIMAL_API(Docs/Preferences.md, "The engine library"). -
-DPRIMAL_ENABLE_SANITIZERS=ONturns on ASan and UBSan. -
The test content assets are already in
x64/. They were generated on Windows, before ContentTools built on Linux (#12). On Linux ContentTools isx64/<Config>/libContentTools.so(no editor calls it yet: #13).
Windows
- Open
Primal.slnxand build Debug, Release, DebugEditor or ReleaseEditor. - Pick the EngineTest test with
/p:PrimalEngineTest=RENDERER|ENTITY_COMPONENTS|WINDOW|SURFACES|EDITOR_UI. - Building
EngineTest.vcxprojalone needs/p:SolutionDir=<repo>\. - The Vulkan backend builds only when the Vulkan SDK is installed (
Engine\Vulkan.props,PrimalVulkan). - The tests are GUI-subsystem. Use
Start-Process -Wait -NoNewWindow -RedirectStandardError <file>to capture the log.
Automated tests
x64/<Config>/UnitTestsruns every test and exits non-zero when one fails (ctest --test-dir build/<preset>does the same).-ts="utl::vector"runs one suite,-tc="*erase*"matching cases,--helplists the options.- doctest is one header, downloaded and not in the repo (the user's choice): CMake fetches it at configure time
(
cmake/PrimalDependencies.cmake), MSBuild in aDownloadDoctesttarget ofUnitTests.vcxproj(intopackages\). Both pin the same version and SHA-256: change them together. - One
.cppper area inUnitTests/. A new file goes inUnitTests/CMakeLists.txtandUnitTests.vcxproj. - The entity, transform, script and input systems are global and keep their state between test cases: a test must not rely on particular ids or on empty systems, and removes what it creates.
- Tests need their own checks (
CHECK): the engine'sasserts are off in Release. - Test files go in
UnitTests/Data/(PRIMAL_TEST_DATA_DIR, both build systems):ImportTest.fbxis the FBX import tests' scene (ASCII, written with the FBX SDK before #38; its expected numbers are the SDK importer's). - The editor's tests (
PrimalEditor.Tests/, xUnit v3, issue #61):x64\<DebugEditor|ReleaseEditor>\EditorTests\PrimalEditor.Tests.exe(Windows only: the WPF runtime; built with the solution, in the VM too;-method "*Behavior*"picks tests,-?lists options). On Linuxdotnet build PrimalEditor.Tests -c DebugEditor -p:Platform=x64 -p:EnableWindowsTargeting=truechecks that it compiles. View-model tests run againstFakeEngine.cs(actors, parts, behaviors, fields as text; extend it with what a new test needs) throughEditorTest, which installs it and makes an in-memory project; the editor's statics make the tests run one at a time (xunit.runner.json).NativeEngineTestscallEngineDll.dll(no window, GPU or game code) and remove what they make. A failedDebug.Assertfails the test. x64/<Config>/GraphicsTestsruns the graphics tests the same way (same doctest options), on the backendPRIMAL_GRAPHICSnames (the platform's default otherwise: D3D12 on Windows). It needs a display (on Windows a desktop session: swapchains fail over SSH) and a device (Vulkan 1.3, or D3D12 incl. WARP), and shows its windows for a few seconds;xvfb-run -a x64/<Config>/GraphicsTestsruns it on a virtual display where lavapipe is installed (the CI image).ctest -LE graphicsleaves it out.- A test starts the renderer with
graphics_test::Sessionand ends withshutdown_and_check(): in Debug, any validation error or warning fails it (graphics::validation_stats(): Vulkan's layer, D3D12's debug layer), also those reported while the device is destroyed.PRIMAL_TEST_REQUIRE_VALIDATION=1also fails a Debug run whose validation isn't active. - Content is made in memory (
GraphicsTests/TestContent.h: meshes in the three vertex formats ofTestShader.hlsl, LODs, textures, cube maps). Nothing is read fromx64/, so new tests must not need assets. - Sizes are compared with each other, never with the numbers asked for: a window manager may scale a window or choose its size.
- New sources go in
GraphicsTests/CMakeLists.txtandGraphicsTests.vcxproj. - In the VM: run it inside
Invoke-Interactive(a desktop session). doctest's-tcsplits on commas, so a test name with a comma is selected with a*in its place.
- A test starts the renderer with
- Benchmarks are test cases named
benchmark: ...and marked* doctest::skip(), so they don't run by default:x64/Release/UnitTests -tc="benchmark*" --no-skip(alsoGraphicsTests). They print their numbers withMESSAGE; comparePRIMAL_JOBS=0with the default. No commas in test names:-tcsplits on them. Tools/CI/ci.sh build <preset>builds everything and runs the tests the way CI does;ci.sh graphics [Debug]runs only the graphics tests of an existing build.- GCC 16 at
-O2/-O3reports false-Wstringop-overflowerrors insidestd::vector::insert(range)andassign(n, value)in test code: useresize()+std::memcpy, or astd::array. - doctest's
CAPTURE/INFO/*_MESSAGEmacros tripmisc-const-correctnesswith the MSVC headers only (Tools/WindowsCompileDb, databaseunittests): put aNOLINTNEXTLINEon them inUnitTests/.
Shaders
ShaderCompilerToolruns as a build step on both build systems. It writesx64/<Config>/shaders/{d3d12,vulkan}/shaders.bin, aPSHBv2 layout read bycontent::get_engine_shaders().shaders.bin.keyholds a hash of the format version, the DXC version and all arguments; shaders recompile only when it changes.- The HLSL is shared by both backends and compiled with DXC (T17 has the decision).
- Single sources (#17, 2026-11-14): a constant both C++ and HLSL need goes in
CommonConstants.hlsliasPRIMAL_SHARED_CONSTANT uint Name = ...;(C++ readshlsl::NamethroughSharedTypes.h; no-Ddefines). The engine shaders are one table,Engine/Graphics/Shaders/EngineShaders.h(a new engine shader is an id + a row there). The binding contract (register → Vulkan set/binding, the-fvk-*-shiftvalues) isEngine/Graphics/Shaders/ShaderBindings.h, documented for HLSL at the top ofCommon.hlsli. - Layout check: on every run,
PrimalShaderCompilercompiles a generated shader with each struct ofCommonTypes.hlslito SPIR-V, reads DXC's offsets and strides, and compares them withoffsetof/sizeof(ShaderCompilerTool/ShaderLayoutCheck.cpp); a difference fails the build. A new shared struct gets a row in itsshared_structstable, with the usage the engine binds it with (constant or structured buffer). - Material shaders are shader packs (#17, 2026-11-15): a manifest (
*.shaders, format at the top ofEngineTest/TestShader.shaders) lists groups (stage, file, entry point) and their variants (key +-Ddefines).PrimalShaderCompiler --pack <manifest> <pack>compiles it at build time (same up-to-date check,<pack>.key) intox64/<Config>/shaders/TestShader.shaderpack, with DXIL + SPIR-V on Windows and SPIR-V only on Linux (the distro DXC can't make DXIL, plan doc B13). Format:Engine/Content/ShaderPack.ixx(moduleprimal.shader_pack); load withcontent::add_shader_pack(blob, size, platform, groups). Variant keys mean one thing everywhere:content::shader_variant_key()(vertex shaders: the elements type; other stages:u32_invalid_id). A new manifest gets a--packline inShaderCompilerTool/CMakeLists.txtandShaderCompilerTool.vcxproj. - Shader hot reload (
EngineDLL/ShaderHotReload.h, programs that link the compiler):watch_engine_shaders(),watch_shader_pack(manifest, groups, platform), thenshader_hot_reload::update()between frames andstop()before the groups go. It compiles in a background job and applies withcontent::update_shader_group()+graphics::reload_shaders(), which rebuilds every pipeline in place (render items keep their pipeline ids). The renderer test does it: editTestShader.hlslor an engine shader while it runs. Not in the editor yet (it renders on its own thread; needs a hook there). Pipelines remember their sources (PsoSource, with shader group serials:content::shader_group_serial()), and the pipeline caches are keyed by shader hashes, not byte code pointers. - Debug shader info: SPIR-V gets
-Zi(the full source in OpSource + OpLine, for RenderDoc); not-fspv-debug=vulkan*, which crashes DXC 1.10. DXIL PDBs go tox64/Debug/shaders/d3d12/pdb/(PIX search path). - Editor materials hold both bytecodes (#35):
ShaderGroup(PrimalEditor/Content/Shader.cs) keeps byte code perGraphicsPlatform; the asset writes-2where the variant count was (older assets: DXIL only), and upload compiles a missing backend from the stored source.EngineAPI.GraphicsPlatform(exportGetGraphicsPlatform) is the backend that runs. - Slang (#17 item 7, user 2026-11-15): stay on HLSL/DXC. Revisit for Metal/WebGPU targets or if the material
system needs generics/interfaces. #45 measured it (numbers there) and confirmed the decision; the Slang path stays
as an opt-in that CI tests (
ci.sh slang). What Slang needs from the HLSL: heap casts with the type (Texture2D<float4>(ResourceDescriptorHeap[i]), notTexture2D(...)); its bindless set is fixed (samplers binding 0, resources binding 2), so the contract follows it; Debug SPIR-V embeds the module path and the whole command line, so the source is passed by file name only and nothing per file goes on the command line (hot reload compares byte code hashes).
Runtime environment variables
PRIMAL_GRAPHICS=vulkan|d3d12picks the backend. The default is D3D12 on Windows and Vulkan on Linux.PRIMAL_VULKAN_VALIDATION=0turns off the validation layers.PRIMAL_JOBS=<n>sets the number of job system workers (0: every job runs on its caller).PRIMAL_VULKAN_PARALLEL_RECORDING=0/PRIMAL_D3D12_PARALLEL_RECORDING=0record every draw on the rendering thread.PRIMAL_SHADER_COMPILER=slangcompiles every SPIR-V shader with Slang instead of DXC (only in a build configured with-DPRIMAL_ENABLE_SLANG=ON; needs theshader-slangpackage; issue #45). The up-to-date keys name the compiler, so switching recompiles.- Renderer test only:
PRIMAL_TEST_EXTRA_SPHERES=<n>adds n spheres (stress test),PRIMAL_TEST_VSYNC=0starts without vsync. VK_KHRONOS_VALIDATION_GPUAV_ENABLE=1turns on GPU-assisted validation.
Verification standard for a change
- The affected configurations build with 0 warnings.
- clang-tidy reports 0 warnings.
UnitTestspasses, and the relevant EngineTest runs and exits 0. New non-graphics engine code gets unit tests.- For graphics changes,
GraphicsTestspasses in Debug (validation and sync validation clean), and a new renderer feature gets a test case there when it can be reached without assets. - The user does the visual checks.
Troubleshooting
-
ninja 1.13.2 asserts (
Plan::RefreshDyndepDependents ... Assertion 'edge && !edge->outputs_ready()') in an existing build folder after files start importing a module: deletebuild/<preset>and configure again. It hides compile errors while it happens (the build stops before compiling), so don't trust a build that printed it. Seen 2026-11-12 three times, once with "ninja: warning: premature end of file; recovering" before it; a small project didn't reproduce it. -
CMake 4.5 (on the Linux machine since 2026-11-12; the CI image still has 4.4.5) adds the standard library's module source (
/usr/include/c++/16/bits/std.cc) to the compile database:ci.sh tidychecks only files under the repository (fixed 2026-11-13). Do the same when runningrun-clang-tidyby hand. -
Unit tests fail with "Two types are registered as ..." right after switching compilers: the clang and GCC presets write to the same
x64/<Config>/, and an incremental build relinks only what changed, so GCC-built programs end up next to a clang-builtlibPrimalEngine.so(or the other way round). Rebuild with--clean-first(seen 2026-11-21). -
If the frame rate looks throttled (about 21 fps) or XWayland hangs, compare against a build of HEAD first. It is usually the display session (for example, a locked screen), not the code.
Backend notes
- Logging:
log::debug/info/warning/error(log::Category::x, "format {}", args)(Engine/Core/Log.h,std::formatsyntax), neverprintf/OutputDebugString/std::cout(Tools/check_log_usage.py). No trailing\n, no "Vulkan:" prefix: the category says it.error()waits until the message is written, so don't call it per frame. Actors, behaviors and game scripts uselog_info("fmt", ...)etc. (categoryscriptplus their name). A game DLL in the editor logs into the one log (one engine library); the ring buffer copies file names, since a game DLL's go away with it. In Debug, D3D12 debug layer messages arrive as[d3d12] Debug layer: ...(ID3D12InfoQueue1callback; don't callSetMuteDebugOutput(TRUE), it stops the callback). - Editor without Visual Studio: when VS's COM server isn't registered (or
PRIMAL_EDITOR_BUILD=msbuild), the editor builds game projects with MSBuild, edits the.vcxprojfor new scripts, opens them in VS Code, and runs the game as a process with its stderr in the log panel (VisualStudio.CommandLine.cs). - GUI tests on Windows without the user: post
WM_CLOSEto each top-level window of the process after a few seconds (EnumWindows+PostMessage); a kill loses the log's queued lines.PRIMAL_VK_DEBUG_BREAK()andDXCalllog before they break. A program callslog::initialize()at start andlog::shutdown()at the end; command-line tools whose output a build reads uselog::set_console_style(log::ConsoleStyle::plain). - Vulkan design: push descriptors stand in for D3D12 root descriptors, and a mutable-descriptor resource heap
stands in for the D3D12 descriptor heap. There is reversed Z, an FP16 scRGB swapchain when available, and direct
gpass draws (D3D12 too; its
ExecuteIndirectpath was removed in #3 step 4). Both record more than 512 items in jobs. The reasons for each difference are in the plan doc's "Phase 6x – done" sections. - Vulkan functions are loaded, not linked (#18,
Engine/Graphics/Vulkan/VulkanLoader.h):VK_NO_PROTOTYPESeverywhere, and each function is a global pointer with its Vulkan name, so calls stay::vkX(...). A function the engine starts to use goes in one of the X-macro lists there (global, instance, device; VK_EXT_debug_utils is loaded only when enabled, so null-check those). Window-system surface functions are fetched inVulkanSurface.cppwithloader::instance_function<>(). VMA getsvkGet*ProcAddrand loads its own. - Frame phases: a frame is
frame::run(dt, render)(Engine/Core/Frame.ixx). Inside it (game code, jobs, render) entities are created and removed only throughgame_entity::queue_create()/queue_remove(), which run at the next sync point; the immediatecreate()/remove()/update_component()assert that they run between frames. A queued entity exists from the next frame. - Job system in the frame:
transform::update_matrices()runs at the end ofscript::update()and before eachgraphics::render_frame(); after it, render preparation reads transforms from several threads, so nothing there may write to a component. Game code writes transforms directly (transform::apply()); it runs one object at a time on the frame thread, which makes that safe (parallel game code needs queued writes:Docs/Ecs.md9.6). - Behavior lifetime (
Engine/EngineAPI/Actor.h; game scripts: "Scripts" above): constructor →begin_play()at the next sync point →update(dt)each frame →late_update(dt)after every update and the game systems →end_play()when the behavior or its actor goes (only afterbegin_play()) → destructor. The editor runs no frames, so nothing begins play there. - ECS (
Engine/ECS/Ecs.h,Docs/Ecs.mdsection 7):game_entity::world()is the game world; its ids are the entity ids. Components are plain data (trivially copyable, alignment <= 16);const Tin a query or system means read-only.get<T>()reads,write<T>()marks the chunk as changed (versions per chunk and component),locate()for several accesses to one entity. Structural changes are immediate only between frames or at the sync point; inside a frame,game_entity::queue_add_component<T>()/queue_remove_component<T>()(orworld.queue_*). Systems:world.add_system<const A, B>(name, group, [](const ecs::ChunkView &chunk) {...}), run byrun_systems(group); a system's function runs on several threads at once. Transforms are six components (transform::Position, ... inComponents/Transform.h) plusParent/HierarchyDepthon children; position, rotation and scale are relative to the parent. Derived ones (local frame = world axes, matrices) are current aftertransform::update_matrices()(roots, then children level by level, then frames and inverses), and readers compute them before that.position()etc. are world space,local_*relative to the parent. At most 64 component types (u64 masks). - New game classes: the editor's New Class dialog (
PrimalEditor/GameDev/NewClassDialog.xaml.cs) writes a behavior, actor class, part class or game script from its template and adds it to the game's.vcxproj. - Actors (
Engine/EngineAPI/Actor.h,Docs/Actors.mdsections 3-8 and 18): an actor owns a part tree (each part one entity withactor::ActorOwner, attached like the tree; the first part is the root) and behaviors. Every class derived fromActor,PartorBehavioris markedPRIMAL_ACTOR()/PRIMAL_PART()/PRIMAL_BEHAVIOR(); one the generator can't see (a template, a local class) saysPRIMAL_ACTOR_CLASS(Self, Base)and isn't registered.spawn()is immediate between frames and at the sync point, queued inside a frame;destroy()/remove_part()are immediate between frames only;add_part()/add_behavior()are immediate only,queue_add_*()inside a frame. Actors begin play at the sync point (behaviors first), tick in spawn order after the scripts (only those that overrideupdate()), and are destroyed byactor::destroy_all()at the game's shutdown. Never remove an actor's entity withgame_entity::remove()(asserts); removing a plain entity detaches actors attached to it. - Render parts and the scene (
Engine/EngineAPI/RenderParts.h,RenderComponents.h,Engine/Graphics/Scene.h;Docs/Renderer.mdsections 3 and 9):MeshPart, the light parts andCameraPartwriterender::components on their entity; plain entities may have them too. They are the only way to draw something: the renderer has no light, camera or render-item objects of its own, and nographics::Camera/Lighthandles. Callgraphics::scene::prepare()once a frame in the render function before the surfaces render (it rebuilds the light sets from the light components and keeps one backend render item perMeshRendererentity), and again after removing entities and before destroying the content they used. A frame isgraphics::render_frame()overSurfaceFrame{surface, FrameInfo{.light_set_key, .camera_entity, ...}}s (one wait, submission and present for all of them): it adds the visible meshes and their LOD (distance to the camera). A light set is the lights whose components name its key.