LinuxVulkanPort

Chuck Smith edited this page 2026-11-25 01:11:16 +00:00 · 1 commit

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Linux + Vulkan Port Plan (Engine & EngineTest)

Scope: get Engine and EngineTest building and rendering on Linux with a Vulkan backend, while keeping the Windows/D3D12 build (Primal.slnx / .vcxproj) working, and without painting ourselves into a corner for a future AvaloniaUI editor on Linux.

Target dev machine: CachyOS, AMD RX 6800 XT (RADV, Vulkan 1.4), clang/gcc, ninja.

Step-by-step, commit-by-commit rebuild of the work done so far (code, verification, lessons learned): LinuxVulkanPortSteps.md.

Start here (new session): the port is done (Phase 7, 2026-11-08); work now follows the tickets in Forgejo issues. Open items A12 (MSVC check of the Linux-only work) is done (Windows session 2026-11-09); its last part, the in-editor script build, works since 2026-11-12 without Visual Studio (MSBuild + VS Code). T02's /WX and cast pass are done too (the cast pass on Linux only: Open items A13 is its MSVC check). T20 (self-contained headers, sorted includes) is done on Linux too (A14 is its MSVC check), and so are T14 (CI on Linux) and T21 (automated tests: UnitTests/ and the headless GraphicsTests/; A16 and A17 are their MSVC checks, and the CI image 2026-11-09-b has to be published before the commit that uses it is pushed, see A17). Issue #6's first step (DirectXMath only behind math::) is done on Linux too (2026-11-11). A13–A24 (MSVC checks up to the job system, frame phases and script lifetime) are done (Windows sessions 2026-11-11 to 2026-11-13); A25 and A26 (the Linux re-check of what was written on Windows) are done too (2026-11-13). A27 is a small MSVC check of the fixes they needed (one blind const in D3D12Gpass.cpp). A42, A45 and A46 passed on the desktop (2026-11-20). #59 and the code of #3 and #28 are done (2026-11-23). Now (roadmap #25, 2026-11-23): the desktop checks A48-A60; #61, #63, #38 and #12 are done in the code (A55-A58), #13 steps 1 and 2 too (A59, A60). Next: #13, whose first step is parented child windows on Linux. Then "Open items" (B: known bugs, C: still to verify) → "Verification" (how every step is checked). Phase 6 details and the reasons for every Vulkan-vs-D3D12 difference are in the "Phase 6x – done" sections. Scripted test drivers from Phase 6: VulkanPortDrivers/. Future work beyond the port: Forgejo issues.

Status

  • Phase 0 – Prerequisites (identified; packages need installing, see below)
  • Phase 1 – CMake build alongside the .vcxproj files (configures; remaining errors are Phase 2)
  • Phase 2 – Core portability → TEST_ENTITY_COMPONENTS runs (clang; ASan/LSan/UBSan clean; Windows build not yet re-verified)
  • Phase 3 – Platform layer → TEST_WINDOW runs; shared platform API on both platforms (Windows not yet compiled)
  • Phase 4 – Content and paths (Linux game executable runs with a hand-made game.bin; renderer assets still to be copied from Windows)
  • Phase 5 – Shader pipeline (HLSL → SPIR-V via DXC): engine shaders + TestShader variants compile and pass spirv-val
  • Phase 6 – Vulkan backend (milestones a–g) — done on Linux and Windows (2026-11-08)
    • Windows D3D12 compile check (2026-11-06; 3 fixes, see "Windows checkpoint" under Phase 6) — manual visual/keyboard checks and the RenderDoc reference capture still open
    • Vulkan on Windows, build + surface (pulled ahead of milestone b, 2026-11-06): steps 1–4, 6, 7 done and the SURFACES test passes on Windows (AMD, validation + sync validation clean). Steps 5 and the RenderDoc part of 8 wait for a rendered frame (milestone c).
    • Milestone b (2026-11-06; Linux verified, Windows not compiled yet): VMA, resource heap, push-descriptor root signatures, static samplers, buffers/textures/render textures/depth buffers — see "Phase 6b – done"
    • Milestone c (2026-11-07; Linux verified): engine shaders, gpass buffers + transitions, post-process to the swapchain, pipeline helpers, FP16 scRGB back buffer — see "Phase 6c – done"
    • Milestone d (2026-11-08; Linux verified): upload, content (meshes, textures, materials, render items, pipelines), DXGI → VkFormat table, SPIR-V entry points = main — see "Phase 6d – done"
    • Milestone e (2026-11-08; Linux verified, visual check OK): camera, gpass depth prepass + main pass draws (direct, push descriptors), mesh repacking for storage buffer alignment — see "Phase 6e – done"
    • Milestone f (2026-11-08; Linux verified, visual check OK): lights, tiled light culling (2 compute passes), light data in the gpass and post-process — see "Phase 6f – done"
    • Milestone g (2026-11-08; Linux verified, visual check OK via the Phase 7 renderer test): IBL ambient light + sky, BC/float-filtering guarantees, GPU-assisted validation clean (fixed a data race in CullLights.hlsl) — see "Phase 6g – done"
    • Windows build + run of b–g (2026-11-08, Open items A1–6 + A9): all 4 configs + PrimalVulkan=false build clean (0 C++ warnings at /W4); SURFACES and the full renderer test on Vulkan validation-clean, picture matches D3D12; D3D12 regression check OK. 2 bugs fixed (see "Windows session 2026-11-08" under Phase 6).
  • Phase 7 – EngineTest renderer test on Vulkan — done 2026-11-08; the port is complete. Step 1 (backend selection, PRIMAL_GRAPHICS) done and verified on Windows 2026-11-08. Steps 2–5 done on Linux 2026-11-08 (builds + runs; validation, sync validation, GPU-AV, ASan/LSan/UBSan clean; Wayland + X11; see "Phase 7 – Linux (2026-11-08)"). Visual check OK (user). Step 6 (Windows, both backends) and the pass-by-pass RenderDoc comparison (A7) done by the user 2026-11-08.

Open items (consolidated — keep this list current)

Everything still open from the sections below, in one place. Windows is checked once, at the end of Phase 6 (user's choice); until then Windows-side edits are made blind from Linux.

A. Next Windows boot — checklist (in order)

Items 1–11 are done (results: "Windows session 2026-11-08" under Phase 6). Still open:

  1. RenderDoc: Done 2026-11-08 (captures and the pass-by-pass comparison below). Capture a D3D12 reference frame of the renderer test (same camera/frame) and a Vulkan one (PRIMAL_GRAPHICS=vulkan) on Windows, and compare ("Vulkan on Windows" step 8). D3D12 only runs on Windows, so the reference capture has to be made there; Linux can only capture the Vulkan side. Captured 2026-11-08 (RenderDoc 1.32, Debug, window 4 800×600, same queued frame): x64\captures\d3d12.rdc, x64\captures\vulkan.rdc (Vulkan with PRIMAL_VULKAN_VALIDATION=0; x64/ is git-ignored — copy them elsewhere to keep them). Final-image thumbnails (renderdoccmd thumb) match: same camera, geometry, IBL/sky, brightness and tone; only the animated objects (fan angle, wobbly statue) differ by timing. renderdoccmd capture didn't inject (no overlay, no log) — launch from qrenderdoc's "Launch Application" tab (working dir x64\Debug, env vars set there). Pass-by-pass comparison in qrenderdoc (gpass color/depth, light-culling grid/index buffers, post-process): done 2026-11-08 (user).

  2. Fix D3D12Shaders.cpp (see B1) and test it there. Done 2026-11-08 (see B1).

  3. Existing game projects (made before 2026-11-06) need the <Import> of Engine\Vulkan.props by hand. Done 2026-11-08: added the guarded import (same line as the templates, before Microsoft.Cpp.targets) to all 12 projects in Documents\PrimalProject\ and Documents\PrimalProjects\ (.vcxproj.bak backups next to them). Note: the user env var PRIMAL_ENGINE (set by the editor) points at <repo>\ (the other repo, no Vulkan), so today the import is skipped and these projects build against Primal. With PRIMAL_ENGINE → Primal_Plus the import activates (checked with msbuild /pp: vulkan-1.dll delay-load present). 3 old projects (AwesomeProject, Test, PrimalProjects\NewProject) hardcode the PRIMAL path in Primal_IncludePath and would keep using Primal's headers/libs even then.

  4. Optional: HDR on (Windows HDR setting) with the Vulkan FP16 scRGB swapchain vs D3D12. Done 2026-11-08: with Windows HDR on, the AMD surface adds R16G16B16A16_SFLOAT/EXTENDED_SRGB_LINEAR, A2B10G10R10 HDR10_ST2084 and BT2020_LINEAR. Vulkan renderer test: every swapchain (incl. after F11) format 97, color space 1000104002 (FP16 scRGB, same as D3D12), validation clean, exit 0. Picture matches D3D12 on the HDR display (user).

  5. Windows check of everything done blind on Linux since 2026-11-08. Done 2026-11-12 (every step; marked 2026-11-21). Steps 1–4 done 2026-11-09 (3 fixes, see "Windows session 2026-11-09" under Phase 6). Step 5 partly: new project + load + engine rendering in the editor OK (user). Script template checked by building a generated game project with BuildTools (templates fixed: v145 + C++23). FBX import, texture import and primitive mesh all work in the DebugEditor (user). Done 2026-11-12: the in-editor script build/load works without Visual Studio (MSBuild backend, VisualStudio.CommandLine.cs). Original procedure: Commits to check, oldest first: T09/T08/B-list work, 7837688 (T02: PascalCase types, trailing return types, ufps clang-format, ::/std:: calls — touches every C++ file), 53f3c85 (clang-tidy auto-fixes: const, braces, structured bindings, noexcept, PRIMAL_NOINLINE; GCC -Wextra -Werror), 4d31ec3 (EDITOR_INTERFACE per compiler, Progression typo). On Linux the Windows-only code (D3D12, Win32, EngineDLL, ContentTools) was only parsed by clang-cl with xwin headers (Tools/WindowsCompileDb/), never compiled by MSVC, and FbxImporter.cpp not even parsed (needs the FBX SDK). Do the steps in order; fix what breaks on Windows, then record the result here (like "Windows session 2026-11-08" under Phase 6) and tick the item.

    1. Restore + build. NuGet restore (new project ShaderCompilerTool, packages.config = DXC, same as EngineTest). Primal.slnx /t:Rebuild for Debug, Release, DebugEditor, ReleaseEditor. Expect 0 C++ warnings at /W4 (only the old C# CS0649 ×2 in PrimalEditor/Content/Material.cs). ShaderCompilerTool builds before EngineTest (Debug/Release only) and its CompileEngineShaders step writes x64\<Config>\shaders\d3d12\shaders.bin (+ vulkan\ with the Vulkan SDK) and a shaders.bin.key. MSVC-specific risks to look at first if it fails: EDITOR_INTERFACE auto f() -> T (extern "C" __declspec(dllexport) before a trailing return type), PRIMAL_NOINLINE auto f() -> void (D3D12Core.cpp, D3D12LightCulling.cpp), narrowing in braced inits, structured bindings / const added by clang-tidy where MSVC disagrees, std::scoped_lock, /W4 warnings clang and GCC don't give.
    2. Test variants (B5). Build EngineTest\EngineTest.vcxproj with each /p:PrimalEngineTest= value (ENTITY_COMPONENTS, WINDOW, SURFACES, RENDERER; no /FORCE:UNRESOLVED needed any more) — all link. /p:PrimalEngineTest=BOGUS must fail with a clear error. Needs /p:SolutionDir=<repo>\ when built alone.
    3. Shader build (T09). Break one line of an engine HLSL file (Engine\Graphics\Shaders\) → the build fails with DXC's message in the build output; undo it. Second build with nothing changed → shaders are not recompiled (the .key matches).
    4. Run. Renderer test on D3D12 (default) and on Vulkan (PRIMAL_GRAPHICS=vulkan): picture unchanged from 2026-11-08 (meshes, lights, IBL, sky), F11 + Alt+Enter + resize OK, Vulkan validation clean, exit 0 (D3D12 now reads shaders.bin through content::get_engine_shaders(), PSHB v2 layout; shaders moved to Engine\Graphics\Shaders\, graphics::hlsl instead of d3d12::hlsl). Also TEST_ENTITY_COMPONENTS (no asserts) and TEST_WINDOW.
    5. Editor. Create + load a project, add a script (the new template generates EntityScript, game_entity::Entity and trailing returns — must compile in the game project; script names are looked up by class name, e.g. "CameraScript"), import an FBX and a texture through ContentTools (FbxImporter.cpp was edited by hand), create a primitive mesh.
    6. When all of that is clean: tell the user; the next items are T02's remaining steps (/WX for MSVC in the .vcxproj files, then C-style casts → C++ casts, see issue #2 (T02) "Remaining").
  6. MSVC check of the T02 cast pass (2026-11-09, Linux; issue #2 (T02) "Done, part 4"). Done 2026-11-11 (1 fix, see "Windows session 2026-11-11" under Phase 6): builds clean, both renderer tests exit 0 with the right picture (user), and the editor run is OK (user: FBX + texture import, primitive mesh, materials, reload). Original procedure: every Windows TU parses with clang-cl, but MSVC hasn't seen it:

    1. Rebuild Primal.slnx in all 4 configurations + the 4 EngineTest variants (Debug/Release), /W4 /WX. Look first at: FbxImporter.cpp (edited by hand, parsed by no compiler: static_cast<FbxMesh *> / static_cast<FbxLODGroup *> from FbxNodeAttribute *, static_cast<f32>/<u32> on FBX values); EngineAPI.cpp (reinterpret_cast<u64>(host), reinterpret_cast<HWND>(...), static_cast<u8 *> of CoTaskMemAlloc, const_cast in patch_material_data()); D3D12Upload.cpp (reinterpret_cast<ID3D12Resource *>(uintptr_t{1})); D3D12Content.cpp (create_pso_if_needed()); PlatformWin32.cpp (HWND ↔ u64); MSVC warnings on reinterpret_cast/static_cast that clang doesn't give (C4311/C4312 pointer truncation, C4838).
    2. Run the D3D12 and Vulkan renderer tests + the editor (import an FBX and a texture, create a primitive mesh, load a project with materials): utl::free_list and BlobStreamReader/Writer now use std::memcpy, and patch_material_data() changed.
  7. MSVC check of T20 (self-contained headers + sorted includes, 2026-11-09, Linux; issue #20 (T20)). Done 2026-11-11, issue closed: no include-order problem with MSVC ("Windows session 2026-11-11"). Step 3 was done with MSBuild instead of Visual Studio (a generated script project builds clean); the editor starting that build itself stays with A12.5. Original procedure: clang-cl parses every TU and every header alone, MSVC hasn't built it:

    1. Rebuild Primal.slnx (4 configurations) + the 4 EngineTest variants. Includes were reordered in 83 files; look first at Windows-header order problems (<Windows.h> now sorts with the other <x.h> headers; files that need WIN32_LEAN_AND_MEAN/NOMINMAX define them before it), EngineTest/Test.h (now lean Windows.h), the D3D12 files that include D3D12Helpers.h/D3D12Resources.h themselves now, and FbxImporter.h/.cpp (reordered without a compiler).
    2. Engine.vcxproj + .filters list the new Common\CommonDefinitions.h (edited blind) — check it shows up.
    3. Game projects' scripts include engine headers through EngineAPI/*.h: build one in-editor script project if Visual Studio is available (GameEntity.h includes CommonHeaders.h instead of ComponentsCommon.h).
  8. Windows CI workflow Done 2026-11-17 (#14 closed). .forgejo/workflows/windows.yml on the user's Windows runner VM (Forgejo Runner, host mode, label windows; Tools/CI/WindowsRunner.md), green on the first commit that had both fixes: all four configurations, the EngineTest variants, UnitTests.exe and the entity-components test in Debug and Release, the build without Vulkan (2-8 min per job). What the first runs needed: the ci account's script policy (RemoteSigned), GITHUB_ENV written without a byte order mark, and on the Linux runner ALLOW_ARCHIVE=1 in its socket proxy (the server's config, not this repo).

  9. MSVC check of the unit tests (T21, issue #21; written on Linux 2026-11-10). Step 4 done 2026-11-13: a project whose scene names a missing script loads with the warning "Unable to find script with name ... created without script component!", no crash, no assert. Steps 1–3 done 2026-11-11, issue closed: builds clean, 83/83 pass in Debug and Release ("Windows session 2026-11-11"). Not checked: the second half of step 4 (a project whose scene names a script the game DLL doesn't have), only if one is at hand; the unit tests cover the engine side. Original procedure: clang-cl parses all ten files against the MSVC headers with 0 clang-tidy warnings, but MSVC hasn't built or run them:

    1. Build Primal.slnx Debug + Release: the new project UnitTests\UnitTests.vcxproj (written blind; it is in the solution for Debug and Release, not the editor configurations). Things to look at: the DownloadDoctest target (MSBuild DownloadFile + VerifyFileHash tasks; it should put doctest.h in packages\doctest.2.5.3\ once and check its SHA-256 on every build), the ExternalIncludePath for that folder with ExternalWarningLevel off (doctest must not trip /W4 /WX), linking engine.lib into a console program, the Engine\Vulkan.props import.
    2. Run x64\Debug\UnitTests.exe and x64\Release\UnitTests.exe: 83 test cases, exit code 0. A console program, so no Start-Process is needed. Two suites were added later the same day and deserve a look on Windows: content::load_game (ContentLoaderTests.cpp) writes game.bin into a folder under std::filesystem::temp_directory_path() and makes it the working directory (then restores it), and content::get_engine_shaders (ShaderBlobTests.cpp).
    3. Engine\Utilities\Vector.h: erase() and erase_unordered() got void * casts on their memmove/memcpy (clang -Wnontrivial-memcall). No behavior change, but every project compiles it.
    4. Two engine fixes the new tests needed (2026-11-10), both in code Windows also runs: script::detail::get_script_creator() returns nullptr for a name that isn't registered (it asserted in Debug and dereferenced end() in Release) — the editor's EngineAPI.cpp and load_game() already check for nullptr; and content::unload_game() clears its entity list (a second unload removed the same entities again). Load a project whose scene names a script that the game DLL doesn't have, if one is at hand.
  10. Graphics tests and the Vulkan validation counter on Windows Closed 2026-11-21: step 1 done, step 2 is #28, step 3 is obsolete (the CI image is in Forgejo's registry since #14 and CI runs on it). (T21 second half, issue #21; 2026-11-10, Linux). Step 1 done 2026-11-11 (clean run prints no "validation error(s)" line; the case with errors was not provoked). Steps 2 and 3 are not Windows-boot items.

    1. Build all four configurations: VulkanCore.cpp now counts validation errors and warnings in std::atomic<u32>s and resets them in core::initialize() instead of core::shutdown(); VulkanInterface.h includes PrimitiveTypes.h and declares vulkan::validation_stats() (defined in VulkanInterface.cpp, so only in builds with PrimalVulkan). Run the Vulkan renderer test once: the "N validation error(s) were reported" line at shutdown must still appear only when there were errors.
    2. GraphicsTests/ has no .vcxproj: it is built by CMake only, so Windows doesn't build or run it. Its sources avoid POSIX-only calls (an _dupenv_s branch for MSVC is there, unbuilt), and it only drives the Vulkan backend. A Windows project and a D3D12 run are issue #28, not part of the next boot.
    3. CI image: Tools/CI/Dockerfile gained vulkan-swrast, vulkan-validation-layers and xorg-server-xvfb, and linux.yml names the tag 2026-11-09-b. The image was built and all jobs were run in it on the desktop, but it is not published: build and push it on the Gitea server (Tools/CI/README.md) before pushing the commit, or every job fails to start.
  11. MSVC check of the math:: layer Done 2026-11-12 (one fix, the C4459 of step 7; "Windows session 2026-11-12"). (issue #6 first step; done on Linux 2026-11-11). DirectXMath is now named only in Engine/Utilities/MathTypes.h and the new MathSimd.h (math::vec, math::mat, math::load(), math::store(), …); 25 files were converted, the D3D12 and ContentTools ones blind. clang-cl parses all of it with 0 clang-tidy warnings (except FbxImporter.cpp, which has no math), MSVC hasn't built it:

    1. Rebuild Primal.slnx (4 configurations) + the 4 EngineTest variants. Two things only MSVC can show:
      • vec operators. With MSVC math::vec (__m128) is a class in the global namespace and its + - * / are functions in namespace DirectX. MathSimd.h brings them into primal::math::vec_operators and adds using namespace math::vec_operators; to namespace primal, in place of the old using namespace DirectX; at each use. If that fails, the errors are C2676/C2677 (binary '-': ... does not define this operator) in D3D12Light.cpp, VulkanLight.cpp, Transform.cpp, EngineAPI.cpp, EngineTest/Scripts.cpp or ContentTools/Geometry.cpp. (The lookup was tried on Linux with a mock of the same layout; clang and GCC use built-in vector operators, so the real code can't show it.)
      • XM_CALLCONV (__vectorcall) on every function in MathSimd.h, written as inline auto XM_CALLCONV f(...) noexcept -> T.
    2. Engine.vcxproj + .filters list Utilities\MathSimd.h (edited blind).
    3. UnitTests.exe: 90 test cases now (7 new in the math suite pin down the conventions: row vectors, quaternion order, right-handed, reversed Z).
    4. D3D12 renderer test and Vulkan renderer test: picture as before (cameras, light culling spheres and the per-object matrices all went through the conversion).
    5. Editor: move/rotate an entity (EntityAPI.cpp), import an FBX with a smoothing angle and make a primitive UV sphere (Geometry.cpp, PrimitiveMesh.cpp), import an HDR environment map (EnvMapProcessing.cpp). One deliberate change there: XMScalarNearEqual(a, b, eps) became math::is_equal(a, b, eps), which tests < where the old one tested <=.
    6. Old game projects' scripts that write DirectX::XM… still compile (the header is still included, and transform::Component::calculate_*() return the same type under its new name math::vec). New scripts should use math::.
    7. Likely C4459 (added 2026-11-12). MathSimd.h:212 near_equal4(..., FXMVECTOR epsilon): the parameter hides math::epsilon (MathTypes.h). clang's -Wshadow-all reports it; MSVC's C4459 ("declaration hides global declaration", /W4) is the same warning, and with /WX it fails every project that includes CommonHeaders.h. If it does: rename the parameter (tolerance) and re-run UnitTests.
  12. MSVC check of the logging work Done 2026-11-12/13 (one fix: C4530 in Log.cpp). Step 4's leak check done 2026-11-13 with Tools/DebugOutput/Capture-DebugOutput.ps1 (a debugger-API runner, no Visual Studio): no CRT leak report after the D3D12 or the Vulkan renderer test (a deliberate 16-byte leak as a control showed up as expected); the D3D12 live-object report lists only the device (refcount 1, held by the debug device). The debug layer messages reach the log since 2026-11-12. (issue #19 steps 1 and 2; written on Linux 2026-11-11, design in Docs/Multithreading.md). Everything now logs through primal::log (Engine/Core/Log.h/.cpp). clang-cl parses all of it with 0 clang-tidy warnings; MSVC hasn't built it, and the editor's C# was written without a compiler:

    1. Build all four configurations + the 4 EngineTest variants + UnitTests. Edited blind:
      • Engine.vcxproj + .filters (Core\Log.cpp, Core\Log.h), UnitTests.vcxproj (LogTests.cpp).
      • Log.h: the consteval constructor of log::detail::Format (a format string plus std::source_location); Log.cpp: std::vformat_to into a custom output iterator, _wfopen_s, designated initializers under /W4 /WX.
      • D3D12CommonHeaders.h: DXCall logs with log::error before __debugbreak(); NAME_D3D12_OBJECT calls the new d3d12::detail::log_object_created() (WideCharToMultiByte to UTF-8, log::debug). D3D12Core.cpp, D3D12Helpers.cpp, D3D12Shaders.cpp, D3D12Surface.cpp: OutputDebugString → log::.
      • EngineDLL/EngineAPI.cpp: log::initialize() in InitializeEngine, log::shutdown() in ShutdownEngine, and the new export DrainLog(buffer, size, cursor).
      • ShaderCompilerTool.vcxproj links engine.lib, where Log.cpp now lives: check that it still links.
    2. UnitTests.exe: 100 test cases (10 in the log suite: two with threads, one writes a file under the temp folder).
    3. Shader build step: PrimalShaderCompiler prints plain lines (log::ConsoleStyle::plain). Repeat the A12.3 check: a syntax error in an engine shader must still fail the build with the file(line,col): error line in the build output. "Shader hash" lines appear in Debug builds only now.
    4. Run the D3D12 and Vulkan renderer tests with stderr redirected: lines look like [ 1.2345] [info ] [vulkan] Device: ..., the same text is in the debugger output (OutputDebugStringA, no colors) and in x64\Debug\EngineTest.log (the previous run is kept as EngineTest.1.log). In Debug, D3D12 prints one "Object created" line per named object. The CRT leak check at exit must stay silent (the log's state is a static object that frees itself).
    5. Editor (PrimalEditor/DllWrappers/EngineAPI.cs DrainEngineLog(), a 250 ms DispatcherTimer in MainWindow.xaml.cs): engine messages appear in the editor's log panel as [category] text, with warning and error types mapped. Things that can be wrong: the LibraryImport of DrainLog with a byte* and a ref ulong, the 40-byte header layout (LogMessageHeader in EngineAPI.cpp), and closing the editor (the timer stops, then ShutdownEngine stops the logger thread).
    6. Engine\Modules.props (new 2026-11-11, written blind, no module uses it yet). It is imported by Engine, EngineDLL, EngineTest, ShaderCompilerTool and UnitTests, in preparation for the job system module. It turns on ScanSourceForModuleDependencies, sets AllProjectBMIsArePublic, and gives the four other projects a ProjectReference to Engine.vcxproj with LinkLibraryDependencies=false (until now they only had a build dependency in Primal.slnx). Check that everything still builds with it, also EngineTest.vcxproj alone (/p:SolutionDir=...), which now builds the engine through the reference. If it causes trouble before a module exists, remove the five Import lines.
    7. A rule, not a check: the logger thread must be stopped with log::shutdown() before EngineDLL is unloaded (ShutdownEngine does it). A thread can't be joined while the Windows loader unloads a DLL. In a program, the log stops its thread itself at exit.
    8. D3D12Resources.cpp DescriptorHeap::free() (2026-11-12, blind; clang-tidy clean with the Windows database). It now sets the deferred-release flag after releasing the heap mutex, not under it (lock-order inversion, B12). Build it, and run the D3D12 renderer test in Debug: no debug-layer errors when windows are resized or closed.
  13. MSVC check of the job system, the first C++ named module Done 2026-11-12 (Modules.props works; C5050 turned off in the importers). (issue #1 step 4; written on Linux 2026-11-12, design in Docs/Multithreading.md section 5). clang-cl parses it with 0 clang-tidy warnings (the Windows databases precompile primal.jobs); MSVC hasn't seen a module of this repo yet.

    1. Build Primal.slnx, all 4 configurations. New: Engine\Core\Jobs.ixx (interface) and Jobs.cpp (implementation unit) in Engine.vcxproj + .filters, and UnitTests\JobTests.cpp (import primal.jobs; after its #includes) in UnitTests.vcxproj. This is the first real test of Engine\Modules.props (A19.7): UnitTests must get primal.jobs.ifc from the engine through the ProjectReference. Errors to expect if it doesn't: C2230 / "could not find module 'primal.jobs'". Also build EngineTest.vcxproj alone.
    2. Things only MSVC can show: std::launder + placement new into the job's std::array<std::byte, 48>; thread_local variables in an implementation unit; the exported requires clauses; _dupenv_s for PRIMAL_JOBS (same code as use_validation()); no try/catch is used (exceptions are off). Also new: the *_invalid_id constants in PrimitiveTypes.h are inline constexpr (so the module's initialize(u32 worker_count = u32_invalid_id) may name them); nothing else should notice.
    3. UnitTests.exe: 112 test cases, 12 in the jobs suite. Run it a few times (they start threads), in Debug and Release.
    4. Worker threads are named primal-job-N on Linux only; Windows (SetThreadDescription) is not done.
  14. MSVC check of the job system's first users Done 2026-11-12/13 (step 3, a built game with a script: 2026-11-13). (issue #1 step 5; written on Linux 2026-11-12). clang-cl parses all of it with 0 clang-tidy warnings; MSVC hasn't built it. New import primal.jobs; lines (each after the file's last #include) in engine files (Transform.cpp, Script.cpp, D3D12Gpass.cpp, VulkanGPass.cpp, MainWin32.cpp), in EngineDLL/EngineAPI.cpp, EngineTest/Main.cpp + RenderItem.cpp and UnitTests/EntityTests.cpp: these need A20 (Modules.props) to work.

    1. Blind: D3D12Gpass.cpp fill_per_object_data() (per-object data listed per entity, one constant buffer block, filled with jobs::parallel_for) and MainWin32.cpp (jobs::initialize()/shutdown() around the game loop). Run the D3D12 renderer test in Debug and Release: picture as before (user), no debug-layer errors.
    2. EngineDLL: InitializeEngine() starts the pool, ShutdownEngine() stops it before the log (and on both failure paths of InitializeEngine()). In the editor: open a project, move entities, import an asset, close the editor; nothing hangs at exit and there is no assert. The pool's frame thread is the thread that called InitializeEngine() (the UI thread): jobs::shutdown() asserts if another thread stops it. (Corrected 2026-11-12) RenderFrame() runs on the editor's own render thread (RenderSurfaceHost.cs), outside the pool: its parallel_for jobs run on the workers and it waits without helping. Expected to work; watch for a hang while rendering.
    3. Game scripts in a game DLL call EntityScript::set_position() etc., which now use jobs::worker_index() (Script.cpp). In a game DLL with its own copy of the engine library, that copy's pool isn't running, so the index is 0: check that a game project with a script still moves its entity in the editor and in the built game.
    4. UnitTests.exe (113 test cases, 1 skipped benchmark) and both renderer tests. The renderer test logs "Test content loaded in ... ms (N threads)": compare with PRIMAL_JOBS=0 set.
  15. MSVC check of the frame phases Done 2026-11-12/13 (step 4, built game: 2026-11-13). (issue #1 step 6; written on Linux 2026-11-12). clang-cl parses all of it with 0 clang-tidy warnings; MSVC hasn't built it.

    1. Build: the second module, Engine\Core\Frame.ixx + Frame.cpp (in Engine.vcxproj + .filters). Entity.cpp and Core\Engine.cpp import it, UnitTests\FrameTests.cpp (new, in UnitTests.vcxproj) and EngineTest\TestRenderer.cpp too.
    2. EngineDLL (blind): the editor lock is a std::mutex now (EntityAPI.cpp, extern in EngineAPI.cpp), and Utilities\Threading.h is no longer included anywhere. In the editor: rendering while entities are moved, added and removed in the UI; no stutter or hang.
    3. Debug asserts that may fire in the editor: game_entity::create/remove/update_component assert frame::structural_changes_allowed(). The editor never runs frame::run(), so the phase stays between_frames and they shouldn't; if one does, note the call stack.
    4. A game project: a script that changes its transform still moves its entity in the built game (engine_update() uses frame::run() now).
    5. UnitTests.exe (119 test cases, 1 skipped benchmark) and both renderer tests.
  16. Vulkan parallel recording on Windows Done 2026-11-12/13. The parallel path runs on Windows since the stress option (2026-11-13). Step 3, the editor on Vulkan, fails: issue #35 (material shaders in assets are DXIL only). (issue #1 step 7; written on Linux 2026-11-12). VulkanCore.cpp and VulkanGPass.cpp are part of the Windows build too (with the Vulkan SDK); clang-cl parses them with 0 clang-tidy warnings, MSVC hasn't built them.

    1. Build all 4 configurations: VulkanCore.cpp now imports primal.jobs and reads PRIMAL_VULKAN_PARALLEL_RECORDING with _dupenv_s.
    2. Run the Vulkan renderer test (PRIMAL_GRAPHICS=vulkan) in Debug: validation clean. It has only 16 render items, so it records serially; the parallel path needs more than 512. GraphicsTests would cover it (its "1100 objects" case), but it has no .vcxproj yet (#28).
    3. Editor with PRIMAL_GRAPHICS=vulkan: RenderFrame() runs on the editor's render thread, which uses the extra command pool slot for threads outside the job system. Only matters with more than 512 render items in a viewport.
    4. Engine\Utilities\Threading.h was deleted (2026-11-12, TicketMutex unused since step 6), and its ClInclude lines removed from Engine.vcxproj + .filters, blind: check that the projects load and build.
  17. Script lifetime hooks Done 2026-11-12/13 (step 3, begin_play once in a built game: 2026-11-13; step 1, old test projects: left as they are, user). (2026-11-12, written on Linux). EntityScript (Engine\EngineAPI\GameEntity.h) has a new virtual end_play(), and begin_play() is now called (at the sync point of frame::run()).

    1. Game projects must be rebuilt: the class's virtual table changed, so a game DLL built against the old header calls the wrong functions. Rebuild the test game projects.
    2. Editor (blind): the new-script template (PrimalEditor\GameDev\NewScriptDialog.xaml.cs) now also generates end_play(). Create a script in a project and build it.
    3. A built game with a script whose begin_play() logs: the line appears once, before the first update.
    4. UnitTests.exe (125 test cases, 1 skipped benchmark).
  18. Linux re-check of the fixes from the Windows session 2026-11-12 Done 2026-11-13 (Linux), together with A26. ci.sh checks, build for all four presets (clang/GCC, Debug/Release: 0 warnings, UnitTests 128/128, GraphicsTests 16/16 with validation and sync validation clean), tsan (no reports), tidy, and clang-tidy over every Windows database. Found and fixed:

    • clang-format: Log.h/Log.cpp (write_forwarded() fits on one line now), D3D12Core.cpp and D3D12Gpass.cpp (whitespace only).
    • clang-tidy (Linux): UnitTests/LogTests.cpp a LogTest that can be const (and LogTest::collector is now mutable: the sink writes to it through a pointer, which is undefined behavior for a member of a const object; four tests were already const); EngineTest/RenderItem.cpp bugprone-integer-division in the sphere grid (row/column named first, same result).
    • clang-tidy (Windows databases): D3D12Gpass.cpp prepare_render_frame() const GpassCache &. Blind: check with MSVC next Windows session (A27).
    • Nothing else: PRIMAL_LOG_HAS_EXCEPTIONS doesn't trip cppcoreguidelines-macro-usage, and Linux takes the try path (__cpp_exceptions is defined). GCC 16 accepts script_type_index<T>. (FbxImporter.* reports in the contenttools database are expected: no FBX SDK, see Tools/WindowsCompileDb/README.md.)

    The original checklist:

    1. Engine/Core/Log.cpp: <chrono> moved out of the sorted std group into its own #pragma warning block (_MSC_VER only), and the new PRIMAL_LOG_HAS_EXCEPTIONS macro around the try in format_text(). Check clang-format (the include order), clang-tidy (Linux and Windows databases; a macro may trip cppcoreguidelines-macro-usage) and that Linux still takes the try path (exceptions are on in CMake).
    2. Engine/Utilities/MathSimd.h: near_equal4() parameter tolerance.
    3. Engine/Content/ContentToEngine.cpp: gpu_id_from_fake_pointer() without constexpr (also still open from 2026-11-11). Committed in 2260632.
    4. Engine/Modules.props: C5050 off outside the engine (Windows only; gen_windb.py doesn't read it).
    5. Rule for later: any engine .cpp that includes <chrono> itself needs the same #pragma (C4530 under Engine.vcxproj's no-exceptions setting); <thread>/<mutex> alone are fine.
    6. #19 work done on Windows (written with MSVC only): Log.h/Log.cpp (set_forward(), write_forwarded(), submit() split out of write(), forwarded_files in State), GameEntity.h (script log helpers, script_name(), set_script_type_name<T>(), REGISTER_SCRIPT change, <format> etc. included), Script.cpp (name table, log_message(), set_log_forward export under USE_WITH_EDITOR), D3D12Core.cpp (Windows only), UnitTests/LogTests.cpp and FrameTests.cpp (3 new tests). Build with clang and GCC, Debug and Release; run UnitTests (128) and GraphicsTests; clang-format; clang-tidy (both databases; the NOLINT on debug_layer_message, the reinterpret_cast of GetProcAddress in EngineAPI.cpp); TSan (write_forwarded() takes forwarded_files_mutex without the queue lock). GCC 16: script_type_index<T> is an inline variable template used in a header (no module involved).
  19. Linux check of the constant buffer and stress-test work Done 2026-11-13 (Linux): builds, tidy and TSan as in A25 (TSan runs the "1100 objects" graphics test, so the lock-free allocate() was exercised in parallel). Renderer test on RADV (RX 6800 XT, Release, vsync off, 4 windows, frame time in ms, Vulkan parallel / serial), next to the Windows Vulkan column:

    Extra spheres Linux RADV par./ser. Windows Vulkan par./ser.
    0 1.74 / 1.73 2.32 / 2.30
    1,000 3.61 / 3.60 4.27 / 4.27
    6,400 13.73 / 13.72 15.08 / 14.87

    GPU-bound like on Windows (parallel recording doesn't change the frame time); no warnings or errors in the log. (Run with timeout -s INT 12, so the exit codes say nothing; the exit path is covered by GraphicsTests.)

    The original checklist (2026-11-13, written and run on Windows only):

    1. Vulkan code edited with MSVC only: VulkanResources.h/.cpp (ConstantBuffer::reserve(), atomic offset, lock-free allocate()/range()), VulkanGPass.h/.cpp (collect_render_items(), material_data_size(), surface_cache(SurfaceId)), VulkanCore.cpp (reserve() in render_surface()). Build with clang and GCC, clang-tidy, and run GraphicsTests (Debug, validation) and ci.sh tsan: allocate() is now lock-free.
    2. EngineTest/Test.h test_env_u32() (_dupenv_s on Windows, std::getenv on Linux) and the stress options: run the renderer test with PRIMAL_TEST_EXTRA_SPHERES=6400 PRIMAL_TEST_VSYNC=0 on RADV and compare with the Windows table ("Windows session 2026-11-12", second half).
    3. clang-tidy with the Windows databases on D3D12Core.cpp, D3D12Gpass.cpp, D3D12Resources.* (new code: env_flag(), ThreadCommandLists, record_pass(), queue_and_continue()).
  20. MSVC check of the A25/A26 fixes Done 2026-11-13 in the Windows VM (#37, Tools/WinVM/), the first check made there: Debug and Release build with 0 warnings (/W4 /WX, MSBuild 18.12.2), UnitTests.exe 128/128 in both, and the D3D12 renderer test (Debug, debug layer on, WARP) renders all four windows, logs no warning or error and exits 0 after WM_CLOSE. About 2.8 s per frame on WARP: a correctness check only. Not built in the VM: the editor configurations (they need the FBX SDK, installed by hand).

    The original checklist (made on Linux):

    1. Blind: Engine/Graphics/Direct3D12/D3D12Gpass.cpp prepare_render_frame(): const GpassCache &cache (only parsed by clang-cl). Build Debug + Release; run the D3D12 renderer test.
    2. clang-format-only edits in D3D12Core.cpp/D3D12Gpass.cpp (line breaks inside DXCall(...) and NAME_D3D12_OBJECT_INDEXED(...)): they build if 1. builds.
    3. UnitTests.exe (128): LogTests.cpp now has a mutable member in LogTest.
  21. Done on the desktop (user, confirmed 2026-11-21). Windows desktop: FBX SDK 2020.3.11 (2026-11-13, made in the VM). The FBX SDK path is now one MSBuild property, PrimalFbxSdkDir in ContentTools.vcxproj (default: 2020.3.11 in its default folder), instead of the 2020.3.7 path in the .vcxproj and six #pragma comment(lib) lines in FbxImporter.cpp; a missing SDK stops the build with "FBX SDK not found". 2020.3.11's libxml2 needs bcrypt.lib (added). Built and checked in the VM (DebugEditor, ReleaseEditor).

    1. Install FBX SDK 2020.3.11 (VS2022) on the desktop (the installer is in the Linux machine's Downloads; /S installs silently). Until then the editor configurations stop with "FBX SDK not found" (or build with /p:PrimalFbxSdkDir="C:\Program Files\Autodesk\FBX\FBX SDK\2020.3.7\").
    2. Build DebugEditor and import an FBX in the editor (user): the SDK version changed.
  22. #30 script registration (2026-11-13; built and tested with MSVC in the VM). On the desktop:

    1. Done on the desktop 2026-11-19 (#52 comment): old projects converted; the upgrade check now also warns about REGISTER_SCRIPT(Type); (8d945bc). The original item: Rebuild every game project you still use: their DLLs export the old get_script_creator(size_t), so the editor can't load them ("Failed to load game code DLL"). Scripts written with REGISTER_SCRIPT don't compile any more (removed, no backwards compatibility): write PRIMAL_SCRIPT(Type); after the class.
    2. Editor: New Script + build done in the VM 2026-11-13 (after #40): the dialog writes PRIMAL_SCRIPT in the header, the editor builds the game code with MSBuild and loads it ("Game code DLL loaded successfully", which needs the new export). Left for a desktop session (user): put a script on an entity and run the game: begin_play runs.
    3. Optional: a game script (PRIMAL_GAME_SCRIPT) that logs in begin_play()/end_play(): run the built game (Ctrl+F5) and close it; both lines appear once in its primal.log.
  23. Done on the desktop (user, confirmed 2026-11-21). #18 Vulkan function loader (2026-11-14; built and run with MSVC in the VM). Nothing links the Vulkan loader any more: Engine/Graphics/Vulkan/VulkanLoader.h/.cpp opens vulkan-1.dll / libvulkan.so.1 and loads every function (VK_NO_PROTOTYPES); Engine/Vulkan.props lost vulkan-1.lib, delayimp.lib, DelayLoadDLLs and /IGNORE:4199. In the VM: all 4 configurations build, dumpbin /dependents shows no vulkan-1.dll in EngineTest.exe (Debug, Release) or EngineDLL.dll, UnitTests.exe 139/139, renderer test exit 0 on D3D12 (WARP) and Vulkan (lavapipe, validation clean). On the desktop (real GPU):

    1. Renderer test with PRIMAL_GRAPHICS=vulkan, Debug: validation clean, picture right (user).
    2. The editor still starts and renders on D3D12 (no source change there; EngineDLL simply has no Vulkan import now).
  24. Done on the desktop (user, confirmed 2026-11-21). #17 items 1–4: shared shader constants, one engine shader table, binding contract, layout check (2026-11-14; built and run with MSVC in the VM). LightCullingTileSize (CommonConstants.hlsli, read by C++ through SharedTypes.h) replaces TILE_SIZE everywhere, also in the editor's DefaultMaterialShaders.hlsl; the engine shader table is Engine/Graphics/Shaders/EngineShaders.h, the binding values ShaderBindings.h; PrimalShaderCompiler checks the shared struct layouts on every run (ShaderLayoutCheck.cpp). In the VM: all 4 configurations build with 0 C++ warnings, the check passes with MSVC's layouts, UnitTests.exe 139/139 (Debug, Release), renderer test exit 0 on D3D12 (WARP) and Vulkan (lavapipe, validation clean). On the desktop (user):

    1. Renderer test, D3D12 and Vulkan: picture right, light culling unchanged (lights light the right tiles).
    2. Editor (DebugEditor): open the material editor with the default material. It compiles DefaultMaterialShaders.hlsl at run time, which now reads LightCullingTileSize from Common.hlsli instead of its own #define TILE_SIZE.
  25. Done on the desktop (user, confirmed 2026-11-21). #17 items 5–6 + #35: shader packs, hot reload, debug info, materials for both backends (2026-11-15; Linux checked with MSVC in the VM the same day; only the desktop checks at the end are left, also tracked in #46). VM results: all 4 configurations + 8 EngineTest variants build, 0 C++ warnings (one fix: C4100 in Release, create_pipeline_state() in D3D12Content.cpp); UnitTests.exe 148/148 Debug + Release; the pack has both backends; 9 PDBs in Debug; renderer test hot reload on D3D12 (WARP) and Vulkan (lavapipe) with no debug-layer or validation messages, exit 0; editor: old material on Vulkan compiles its SPIR-V and renders, a regenerated default material holds both bytecodes (207 → 371 KB), and renders on Vulkan; all exit 0. (The editor took up to 5 minutes to start while Windows Update ran: give Start-Editor -TimeoutSeconds 240 then.) Were blind: the D3D12 halves of graphics::reload_shaders() (D3D12Content.cpp PSO cache rewrite with PsoSource/rebuild_pipelines(), D3D12Shaders.cpp reload(), D3D12LightCulling.cpp/D3D12PostProcess.cpp recreate_pipelines(), D3D12Interface.cpp), the DXIL PDBs (write_pdb() in ShaderCompilation.cpp, IDxcBlobWide), EngineDLL (ShaderData::platform, GetGraphicsPlatform()), the editor's C# (Shader.cs, EngineAPI.cs), and every .vcxproj edit (ShaderPack.ixx/.cpp in Engine.vcxproj, ShaderHotReload.cpp in EngineDLL.vcxproj and EngineTest.vcxproj, ShaderPackTests.cpp in UnitTests.vcxproj, the --pack step in ShaderCompilerTool.vcxproj). In the VM:

    1. All 4 configurations + the 8 EngineTest variants build, 0 warnings; x64\<Config>\shaders\TestShader.shaderpack is written with DXIL and SPIR-V (the first pack with both; Linux can't make DXIL, B13).
    2. UnitTests.exe (new suites "shader pack", "shader groups").
    3. Renderer test on D3D12 (WARP) and Vulkan (lavapipe) exits 0. Then hot reload: while it runs, append a line to EngineTest\TestShader.hlsl and touch Engine\Graphics\Shaders\PostProcess.hlsl; the log shows "Shader hot reload: done" and "... pipeline states rebuilt" (D3D12) without debug-layer errors.
    4. Debug: x64\Debug\shaders\d3d12\pdb\*.pdb exist after the engine shaders compile.
    5. Editor (DebugEditor), D3D12: a new project's default material is created with both bytecodes and renders; an old project's material (old asset format) still loads. Then PRIMAL_GRAPHICS=vulkan: the editor starts and renders (#35's crash), old materials compile their SPIR-V from the stored source on upload. On the desktop (user): the picture after a hot reload on both backends; PIX finds the shader PDBs with x64\Debug\shaders\d3d12\pdb in its search path.
  26. Done on the desktop (user, confirmed 2026-11-21). #45 Slang experiment: new Vulkan heap binding (2026-11-15; Linux + built and run with MSVC in the VM the same day). ResourceDescriptorHeap[] moved from set 1 binding 0 to set 1 binding 2 (and the unused sampler heap from set 2 to set 1 binding 0), Slang's fixed bindless layout, so SPIR-V from DXC and Slang fits the same pipeline layout (ShaderBindings.h, VulkanResources.cpp, DXC's -fvk-bind-*-heap). The heap casts in CullLights.hlsl, PostProcess.hlsl and TestShader.hlsl name the type (Texture2D<float4>(...); DXC's SPIR-V is byte-identical). The Slang path itself (EngineDLL/SlangCompilation.cpp, CMake option PRIMAL_ENABLE_SLANG) is Linux-only: no .vcxproj compiles it. VM results: all 4 configurations build, 0 C++ warnings (the editor configurations' 4 are the old C# CS0649 in Material.cs); UnitTests.exe 148/148 Debug + Release; renderer test exit 0 on D3D12 (WARP) and Vulkan (lavapipe, validation on), no warnings or errors in either log. On the desktop (user): the renderer test on Vulkan, picture right (the textured and IBL materials read the heap at its new binding); the editor on Vulkan renders a material.

  27. Done on the desktop (user, confirmed 2026-11-21). #31 ECS prototype: transforms are ECS components (2026-11-16; Linux + built and run with MSVC in the VM the same day). New layer Engine/ECS/ (Ecs.h, World.cpp; Docs/Ecs.md section 7). Entity ids come from the ECS world; position, rotation, scale, local frame and both matrices are components, and three systems compute the derived ones (local frames + world matrices in parallel, then the inverses) in transform::update_matrices(). get_transform_matrices() and the light culler's change flags keep their API (versions per chunk). VM results: all 4 configurations and the 8 EngineTest variants build with 0 C++ warnings; UnitTests.exe 159/159 Debug (15 runs) + Release; renderer test exit 0 on D3D12 (WARP) and Vulkan (lavapipe, validation on), no warnings or errors in either log. On the desktop (user): the renderer test on both backends, picture right (objects in place, the moving ones move, lights follow), and the editor: an entity moved, rotated and scaled in the viewport.

  28. Done on the desktop (user, confirmed 2026-11-21). #48 utl::free_list rewrite (2026-11-16; Linux + built and run with MSVC in the VM the same day). Items in blocks that never move, a live bit per slot (Engine/Utilities/FreeList.h); every free list of both backends (surfaces, textures, render items, cameras, lights, windows) uses it. VM results: all 4 configurations, 0 C++ warnings; UnitTests.exe Debug + Release; renderer test exit 0 on D3D12 (WARP) and Vulkan (lavapipe), clean logs. On the desktop (user), with A34: the renderer test on both backends with several windows opened and closed (surfaces come and go), and the editor loading a project with materials (shader groups).

  29. Done on the desktop (user, confirmed 2026-11-21). #6 own math storage types (2026-11-17; Linux + built and run with MSVC in the VM the same day). v3, m4x4, ... are the engine's own structs with DirectXMath's layout (Engine/Utilities/MathTypes.h); rotate3() uses the cross-product form; new math::Frustum (Docs/Math.md section 6). Blind on Linux and fixed in the VM: EngineDLL/EntityAPI.cpp (a v3 from a float pointer) and C4324 on the aligned types (turned off around them). VM results: all 4 configurations and the 8 EngineTest variants build with 0 C++ warnings; UnitTests.exe Debug + Release; renderer test exit 0 on D3D12 (WARP) and Vulkan (lavapipe), clean logs. On the desktop (user), with A34: the renderer test on both backends, picture right (objects rotated as before), and the editor: an entity's rotation shown and changed in the inspector (the editor passes transforms through EngineDLL).

  30. Done on the desktop (user, confirmed 2026-11-21). MSVC's /std:c++23 (seen 2026-11-18 in the VM, #41 prototype). The VM's Build Tools warn D9048 on /std:c++23preview ("deprecated, use /std:c++23"); the .vcxproj files (stdcpp23) build without it, so that toolset maps stdcpp23 to the new switch. On the desktop: check whether its toolset does the same. Result: both toolsets map stdcpp23 to /std:c++23. clang-cl 23 ignores /std:c++23 (unused argument, C++20 stays), so gen_windb.py keeps /std:c++23preview; only the docs' notes changed. Once both have it, change Tools/WindowsCompileDb/gen_windb.py (clang-cl gets /std:c++23preview) and the /std:c++23preview notes in Docs/Preferences.md and CLAUDE.md.

  31. #47 C# scripting experiment on Windows (2026-11-18, Prototypes/CSharpScripting/; built and run on Linux only). Obsolete 2026-11-21: #47 was decided against (2026-11-18); the experiment is on branch core_clr. The host's Windows paths (wchar_t char_t, LoadLibraryW, libnethost.lib with NETHOST_USE_AS_STATIC) were written blind. The VM needs the .NET 10 SDK first (installing it from a script was blocked; the user installs it or allows it). Then build the experiment there (CMake, or cl like Prototypes/Reflection/build-msvc.ps1) and run it: all checks pass, timings comparable.

  32. #41 reflection in the editor (2026-11-18; C# written blind, the rest checked in the VM). On the desktop (user):

    1. Done on the desktop 2026-11-19 (#52 comment: the prompt checked with both answers, a converted script builds, loads and runs). Open an old game project: the editor offers to add Engine\Reflection.targets to its .vcxproj and warns about each PRIMAL_SCRIPT(Type); (GameProjectUpgrade.cs); convert those scripts by hand (marker before the class, PRIMAL_GENERATED_BODY() inside, #include "<file>.generated.h" last).
    2. Create a script with the New Script dialog: the header has the markers, the project builds (MSBuild runs PrimalReflectGen from the engine's x64\<Debug|Release>\), the script shows in the script list and runs.
    3. A new project from each of the four templates builds.
  33. Done on the desktop (user, confirmed 2026-11-21). #52 step 1, the transform hierarchy (2026-11-18; Linux + built and run with MSVC in the VM the same day). Children, set_parent(), world/local values; cameras and lights read world values. VM results: all 4 configurations, 0 C++ warnings; UnitTests Debug + Release; renderer test exit 0 on D3D12 (WARP) and Vulkan (lavapipe, validation on), clean logs. On the desktop (user): the renderer test on both backends, picture as before (the test scene has no children yet), and the editor: moving, rotating and scaling an entity in the viewport.

  34. Done on the desktop (user, confirmed 2026-11-21). #52 step 2, scripts and components (2026-11-18; Linux + built and run with MSVC in the VM the same day). Scripts write transforms directly, several scripts per entity, late_update(). VM results: all 4 configurations, 0 C++ warnings; UnitTests Debug + Release; renderer test exit 0 on D3D12 and Vulkan, clean logs. On the desktop (user): the renderer test on both backends, the moving and rotating objects as before (their scripts write transforms the new way), and the editor: a game project's script running (Run) and moving its entity.

  35. Done on the desktop 2026-11-19 (#52 comment: a new Empty project, two scripts and a game component, every field editor, the scene tree, a child's transforms, save + restart, Run logs the edited values, exit 0; renderer test, hot reload and surfaces clean on D3D12 and Vulkan on the real GPU with MSVC 14.52 and Vulkan SDK 1.4.363.1). Found there: B15. The desktop session's edits of this file and the other docs weren't committed, so they never reached the Linux machine: merge them from the desktop's working tree if it still has them. The original item: #52 steps 4-5, the editor and game.bin v2 (2026-11-18; engine side checked in the VM; the editor driven in the VM 2026-11-19). State: Docs/Ecs.md 10.7. VM results (2026-11-19, DebugEditor, ScriptTest, D3D12 on WARP): entities named, two scripts and the game's Armor component on one entity; every field editor (number, check box, enum, entity, string, vector) edits, clamps to .max and undoes/redoes; a rejected value (text the engine can't parse) is refused and adds no undo step (fixed that day: it used to stay in the field); drag onto an entity parents, below the list unparents, onto a descendant is refused, collapse hides children, undo/redo of each; removing a parent removes its subtree and undo brings it back with its scripts and values; a game code rebuild with a new field keeps every value; save + reopen keeps the tree and the values; Run (Ctrl+F5) builds Debug, writes game.bin v2, and the game's scripts log the edited values, the entity reference, the child and the component, exit code 0. On the desktop (user): the same by hand in the real editor (it was driven by UI Automation only: look at the inspector layout, the tree's indent and arrows, dragging with a real mouse), a game project from each of the editor's templates built and run, and the transform exports, which now return values relative to the parent: the inspector and the viewport gizmo on a child.

  36. Checked on the desktop 2026-11-20 (user: upgrade, scripts, Run, rebuild while open all fine). #59 step 1, one engine library (2026-11-19, branch actor_based_model; Linux + built and run with MSVC in the VM the same day). The engine is PrimalEngine.dll (+ PrimalEngine.lib), a game executable also links the new EngineMain.lib (WinMain); game projects link PrimalEngine.lib;EngineMain.lib; in every configuration, and the editor's project upgrade rewrites Engine.lib. Exports are marked per member (MSVC's C4251 stays on). EngineDLL no longer needs any export of the game DLL, the game DLL logs into the editor's log directly, and the editor copies PrimalEngine.dll (+ .pdb) next to the game on Run. VM results: all 4 configurations + 8 EngineTest variants, 0 C++ warnings; UnitTests Debug + Release; renderer test exit 0 on D3D12 and Vulkan in Debug (validation clean) and Release; ScriptTest updated by hand (the same replacement as the upgrade), its DebugEditor DLL 4.5 → 1.4 MB, loads in ~3 ms (reload 0.8 → 0.6 ms); its Debug executable runs on PrimalEngine.dll, scripts begin play with their saved values, exit 0; the editor opens ScriptTest, builds and loads its game code. On the desktop (user):

    1. Build all four configurations. Open each game project you use: the editor offers the upgrade ("Engine library: Engine.lib → PrimalEngine.lib;EngineMain.lib"); say Yes and build.
    2. In the editor: the script list, scripts and the game component on entities, field edits, then Run (Ctrl+F5): the game starts (PrimalEngine.dll copied next to it) and logs as before.
    3. A game DLL rebuild while the editor runs (edit a script, build): values and components stay, the log shows the script's messages with their file names.
    4. Debugging in Visual Studio (if installed): breakpoints in engine code from the game work (the .pdb is copied too).

    Left in the VM from this session (2026-11-19): C:\primal-head (a build of HEAD 50087f6, used to compare the renderer test and the link-time crash, B16; safe to delete), and ScriptTest's project file updated by hand with a backup next to it (ScriptTest.vcxproj.before-engine-dll). C:\winvm\time-game-load.ps1 times LoadGameCodeDll (-EngineDll, -GameDll, -Runs). In Invoke-Interactive commands, don't end with exit: it leaves the task script before it writes its result, and the call waits until it times out.

  37. #59 step 2, the actor runtime (2026-11-19; Linux + built and tested with MSVC in the VM the same day). Engine/EngineAPI/Actor.h, Engine/Actors/Actor.cpp; actors tick in the frame after the scripts. VM results: all 4 configurations, 0 C++ warnings; UnitTests Debug + Release (the 14 actor cases among them). Nothing in the editor or the renderer uses actors yet. On the desktop: nothing to look at; a build of the four configurations with the other items is enough.

  38. Checked on the desktop 2026-11-20 (user: the renderer test looks right). #59 step 3, the engine's parts and the scene sync (2026-11-20; Linux + built and run with MSVC in the VM the same day). MeshPart, the four light parts and CameraPart (Engine/EngineAPI/RenderParts.h) write ECS components (RenderComponents.h); graphics::scene::sync() (Engine/Graphics/SceneSync.cpp) makes the renderer's render items, lights, light sets and cameras from them each frame. The renderer test's whole scene is actors now (meshes, the IBL light, 6 directional and 16,000 point/spot lights, the 4 cameras). VM results: all 4 configurations + 8 EngineTest variants, 0 C++ warnings; UnitTests Debug + Release; renderer test exit 0 on D3D12 (WARP) and Vulkan (lavapipe) in Debug, D3D12 in Release; clean logs. On the desktop (user):

    1. The renderer test on D3D12 and Vulkan, Debug and Release: the picture as before (same models, spheres, lights and colors: the random lights use the same numbers in the same order), the fan, the interior model and the fembot move as before, WASD/QE + mouse move the camera, resizing a window keeps its aspect ratio.
    2. F11 (restart) and Esc on one window (its camera actor goes, the others keep rendering): not driven in the VM.
    3. Frame times: Linux Release with vsync off was the same as before (1.73 ms vs 1.74-1.80 ms at HEAD).
  39. Checked on the desktop 2026-11-20 (user: no render:: components in "Add component", Run works). #59 step 4, reflection of actor classes (2026-11-20; Linux + built and run with MSVC in the VM the same day). Markers for actor, part and behavior classes, ActorRef/PartRef fields, making classes by name, the render components reflected. VM results: all 4 configurations + 8 EngineTest variants, 0 C++ warnings (the editor's two CS0649 in Material.cs are older); UnitTests Debug + Release; renderer test exit 0 on D3D12 and Vulkan in Debug. One blind C# line: the editor's "Add component" list leaves out render:: components (ReflectedTypes.cs). On the desktop (user): build the four configurations; in the editor, "Add component" on an entity lists the game's components but no render::... ones, and a game project still builds and runs (Ctrl+F5). Nothing else to look at.

  40. Checked on the desktop 2026-11-20 (user: Run writes v3, scripts log their values). Seen once: a new project's first build from the editor left no game DLL (scripts disabled); reopening the project fixed it, not reproduced. #59 step 5, prefabs and game.bin v3 (2026-11-20; Linux + built and run with MSVC in the VM the same day). game.bin is version 3 now: game projects must be rebuilt and run again from the editor (an old game.bin is refused with "build the game again"). VM results: all 4 configurations, 0 C++ warnings; UnitTests Debug + Release (the prefab tests among them); renderer test exit 0 on D3D12 and Vulkan in Debug. The editor's Run wasn't driven in the VM. On the desktop (user): open a game project, Run (Ctrl+F5): the game starts, its scripts log their saved values as before (the editor writes v3 through SaveGame).

  41. #59 step 6, the editor Done 2026-11-21 (desktop; Linux checks in C, same day). #59 step 6, the editor, is done on the Windows desktop (user, 2026-11-20), after A45 and A46: the editor runs there on the real GPU instead of being driven blind in the VM. Handoff: CLAUDE.md, the "#59 step 6" bullet. Its C++ (EngineDLL exports, engine changes) gets the Linux checks afterwards (C below). State 2026-11-20 evening: slices 1-3 written (Docs/Actors.md section 22 "Progress"); a Debug assert when adding a point light (light set 0 made twice) is the first thing to fix. New C++ for the Linux checks so far: EngineDLL/EditorSupport.*, EntityAPI.cpp actor exports, EngineAPI.cpp (RenderFrame, light sets), Graphics/SceneSync.* (add_light_set()), Actors/Actor.cpp + ActorSystem.h (renames, RenderParts.h), UnitTests/ActorReflectionTests.cpp.

  42. #3 step 1, shared camera, lights and shader loading (2026-11-21; Linux + built and run with MSVC in the VM the same day; Docs/Renderer.md section 8). Nothing should look different. On the desktop (user): the renderer test on D3D12 and on Vulkan (lights, IBL, sky as before; Space/F11 as before), and the editor's viewport lights.

  43. #3 step 2, the renderer reads the components (2026-11-22; Linux + built and run with MSVC in the VM the same day; Docs/Renderer.md section 9). On the desktop (user): the renderer test on D3D12 and on Vulkan (the lights and the IBL as before; the LOD sphere/geometry now switches with the distance to the camera); the editor: a project with mesh actors and light parts (the viewport shows them lit; a light set selected in the viewport; resizing a viewport keeps the aspect), Edit Prefab, Run; a clean exit. Game projects are rebuilt (the game API lost graphics::Camera/Light and the geometry component).

  44. #3 step 3, one frame for every surface (2026-11-23; Linux + built and run with MSVC in the VM the same day; Docs/Renderer.md section 10). graphics::render_frame() replaces Surface::render(); one fence wait, submission and present per frame; render targets, barriers, gpass cache and light buffers per surface; the editor calls RenderFrames once for all viewports. Linux: clang Debug + Release and GCC Debug 0 warnings, clang-tidy 0 on the changed files, UnitTests 239, GraphicsTests 22 (validation + sync validation clean), the four-window benchmark. VM: four configurations, 0 C++ warnings; UnitTests Debug 238 + Release 240; renderer test on D3D12 (WARP) exit 0, no debug layer errors; Vulkan (lavapipe, validation on) exit 0, no validation messages; all four windows draw the scene from their own cameras on both, and the two backends' pictures match (VM screenshots; the scene looks very bright on both, compare with before on the desktop). The editor (DebugEditor, D3D12) opens ScriptTest; its four viewports render at 65 Hz each through one RenderFrames call per loop; exit 0 without errors (the scene is empty, so only the clear color shows). On the desktop (user): the renderer test on D3D12 and Vulkan with all four windows (each its own camera; resizing, minimizing and closing one window while the others keep rendering; Space toggles vsync), the editor with two viewports open (both render; the UI stays responsive), and the four-window benchmark (x64\Release\GraphicsTests.exe -tc="benchmark*windows*" --no-skip, Vulkan only) with and without vsync on the real GPU.

  45. #3 step 4, resizing out of recording and one parallel recording pass (2026-11-23; Linux + built and run with MSVC in the VM the same day; Docs/Renderer.md section 11). Each surface is prepared first (gpass targets, the per-object and material data, light buffers, the light culling buffers: delight::prepare()), then the depth prepass's and the gpass's batches are recorded in one parallel pass, then the frame's list/buffer. D3D12's ExecuteIndirect path and PRIMAL_D3D12_DRAW_INDIRECT are gone (with the material command signatures). Linux: clang Debug + Release and GCC Debug 0 warnings, clang-tidy 0 (Linux databases, and the Windows databases on the D3D12 files), UnitTests 239/241, GraphicsTests 22 (validation + sync validation clean; the 1,100-object case goes through the batches). VM: four configurations, 0 C++ warnings; UnitTests Debug 238 + Release 240; the renderer test with PRIMAL_TEST_EXTRA_SPHERES=1200 (batched) on D3D12 (WARP) and Vulkan (lavapipe, validation on): exit 0, no errors, matching pictures. Not run: TSan (CI's tsan job runs it on push). On the desktop (user): the renderer test on D3D12 and Vulkan with PRIMAL_TEST_EXTRA_SPHERES=6000 (more than 512 items per surface, so the batches run; the picture as before, resizing a window), PIX or RenderDoc on D3D12 and RenderDoc on Vulkan for one frame (the depth prepass and gpass batches between the light culling and the post process), and x64\Release\GraphicsTests.exe -tc="benchmark*" --no-skip on the real GPU.

  46. #3 step 5, surfaces collected, prepared and recorded together (2026-11-23; Linux + built and run with MSVC in the VM the same day; Docs/Renderer.md section 12). Collection in jobs under shared content locks, preparation only allocates, one job pass for every surface's data and batches. Linux: clang Debug + Release and GCC Debug 0 warnings, clang-tidy 0 (Linux databases, and the Windows databases on the D3D12 files), UnitTests 239/241, GraphicsTests 22 (validation + sync validation clean), ThreadSanitizer clean (unit tests, graphics tests, the test game). ci.sh tsan now builds the test game it runs (it ran a stale or missing one). VM: four configurations, 0 C++ warnings; UnitTests Debug 238 + Release 240; the renderer test with PRIMAL_TEST_EXTRA_SPHERES=1200 on D3D12 (WARP) and Vulkan (lavapipe, validation on): exit 0, no errors, the same pictures as step 4. On the desktop (user): the editor with several viewports (all render; adding a mesh while it runs: content is written under the exclusive lock while the render thread reads), the renderer test with PRIMAL_TEST_EXTRA_SPHERES=6000 on both backends (four windows; resize one), PIX/RenderDoc on one frame, and the benchmarks on the real GPU.

  47. #3 step 6, cleanup (2026-11-23; Linux + built and run with MSVC in the VM the same day; Docs/Renderer.md section 13). Object names through vkx::set_name()/d3dx::set_name() (the macros are gone), per-pass debug markers, std::span at the content reads. Linux: clang Debug + Release and GCC Debug 0 warnings, clang-tidy 0 (Linux databases, Windows databases on the D3D12 files), UnitTests 239, GraphicsTests 22 (validation + sync validation clean). VM: four configurations, 0 C++ warnings; UnitTests Debug 238 + Release 240; the renderer test with PRIMAL_TEST_EXTRA_SPHERES=1200 on D3D12 (WARP; 353 named objects logged) and Vulkan (lavapipe, validation on): exit 0, no errors, the same pictures.

    The desktop checks for all of #3, in one session (user; replaces the lists of A48-A53):

    1. Build the four configurations; run the renderer test (x64\Debug\EngineTest.exe) on D3D12 and on Vulkan (PRIMAL_GRAPHICS=vulkan): four windows, each from its own camera; lights, IBL and LOD switching as before; resize, minimize and close one window while the others render; Space toggles vsync.
    2. The same with PRIMAL_TEST_EXTRA_SPHERES=6000 (the batched path): the picture as before, no stutter.
    3. One frame in PIX (D3D12) and RenderDoc (Vulkan): the markers "Depth prepass", "Light culling", "GPass", "Post-process" per window (D3D12 with many items: "... batch" markers), named objects.
    4. The editor: a project with mesh actors and light parts, two or more viewports (all render; a light set selected; resizing keeps the aspect), add a mesh while it renders, Edit Prefab, Run, a clean exit.
    5. x64\Release\GraphicsTests.exe -tc="benchmark*" --no-skip (Vulkan) with and without vsync; compare with Docs/Renderer.md sections 10-12.
  48. #28, GraphicsTests on Windows with both backends (2026-11-23; Linux + the VM the same day). GraphicsTests.vcxproj (in Primal.slnx; console program, same sources as CMake); the tests run on the backend PRIMAL_GRAPHICS names (graphics_test::platform(); Windows default D3D12) and check graphics::validation_stats(), now backend-neutral (D3D12 counts the debug layer's errors and warnings). SetBreakOnSeverity() is set only under a debugger (without one the break ended the program). Fixed on the way: a D3D12 restart hung in upload::shutdown() (B17). Coverage: ci.sh coverage + a coverage job in linux.yml (needs image tag 2026-11-09-d with llvm). VM: four configurations, 0 warnings; no-Vulkan build; UnitTests; GraphicsTests 22/22 on D3D12 (WARP) and Vulkan (lavapipe), Debug and Release, validation required (in a desktop session; over SSH swapchains fail, so Windows CI runs them only with PRIMAL_CI_GRAPHICS=true). Linux: clang

    • GCC, tidy (both databases), ci.sh checks, ci.sh coverage (lines 85.8%). #28's items 3, 5-7 are split off: #74-#77. Desktop and user (in this order):
    1. GraphicsTests.exe on the real GPU, Debug, both backends (PRIMAL_GRAPHICS=d3d12, =vulkan, with PRIMAL_TEST_REQUIRE_VALIDATION=1): 22 passed.
    2. Under the Visual Studio debugger, a D3D12 debug layer message still breaks (the break is only skipped without a debugger).
    3. Publish the CI image: Tools/CI/publish-image.sh (tag 2026-11-09-d, adds llvm) before pushing, then check the coverage job's artifact.
    4. The Windows runner: desktop session, Graphics Tools, lavapipe (Tools/CI/WindowsRunner.md, "Graphics"); then set the repository variable PRIMAL_CI_GRAPHICS to true and check the Windows run.
  49. #61, the editor's C# tests (2026-11-23; written on Linux, built and run in the VM the same day). PrimalEditor.Tests/ (xUnit v3, in Primal.slnx, output x64\<Config>\EditorTests\): 31 view-model tests against an engine in memory (FakeEngine.cs) and 5 against EngineDll.dll. The seams they need: EngineAPI.EntityAPI / ActorAPI are interfaces now (DllWrappers/EngineInterfaces.cs), EditorServices (UI thread, dialogs; the WPF side in Common/WpfServices.cs, set in App), ReflectedTypes.Load(json), Project(name, path) makes an in-memory project and Load() starts the first game code build (was OnDeserialized). No WPF types in Actor/ActorPart any more: the outliner and the part tree bind Depth/PartDepth through DepthToIndentConverter and IsTreeVisible through BooleanToVisibilityConverter; the log's filtered view is LoggerView.FilteredMessages. Fixed (found by a test): removing a behavior left a duplicate behavior in the engine actor (Actor.RebuildBehaviors() counted the editor's list after the removal). VM: DebugEditor and ReleaseEditor build, 36/36 in both; the editor opens ScriptTest, logs, builds and loads its game code. Desktop and user:

    1. The outliner: actors attached to another are indented under it, collapsing hides them; the actor panel's part tree is indented by depth (the bindings changed; nothing in the VM's project has actors).
    2. Add a behavior, remove it, undo, redo: the actor runs with each behavior once (Run, then the log).
    3. Windows CI: the new "Run the editor tests" step passes in the DebugEditor and ReleaseEditor jobs.
  50. #63, everything black in the editor's viewports (2026-11-23; written on Linux, checked in the VM). Reproduced in the VM: a Mesh actor's default cube is a black square in every viewport. Cause: no lights. Editor scenes had no light unless the user added one, and the ambient light has no editor yet (#64). The material shader adds lights + IBL + emissive, so it renders 0. Decided (user): new scenes and the project templates get a directional light (not a viewport-only fallback). Scene.AddsDefaultLight (set by Project.AddScene() and in the four templates' project.primal) adds a "Directional Light" actor, rotation (50, -30, 0), once the scene is active and the engine's classes are known (activation, or BuildEngineActors() after the game code loads). It is not an undo step and is added only once. Every light an actor brings into a scene now goes into the scene's light set (Scene.AddToLightSet(), was the view's code for menu lights only). 5 new editor tests (41 in all). VM: a project with the flag shows the light in the outliner and the renderer makes its light buffers; the cube lit by it wasn't seen (UI Automation couldn't add the mesh). Desktop and user:

    1. Create a project from a template: the scene has a Directional Light; add a Mesh: the cube is lit (shape and shading visible), on D3D12 and on Vulkan.
    2. New Scene, activate it: a Directional Light there too; Undo doesn't remove it on its own.
    3. Existing projects keep their scenes as they are (no light added): add one from the scene menu (Light > Directional Light) and check the cube lights up. Then the rest of #63's list: an FBX mesh, material textures, undo/redo of a texture input, a clean exit.
  51. #38, FBX import with ufbx instead of the FBX SDK (2026-11-23; written on Linux, checked on Linux and in the VM). ContentTools/FbxImporter.cpp reads FBX with ufbx 0.23.1 (downloaded and hash-pinned like doctest: cmake/PrimalDependencies.cmake and ContentTools/ThirdParty.targets, change both). load_fbx() returns std::expected<Scene, FbxImportError>; MikkTSpace is downloaded the same way (pinned to commit 3e895b4, the copy in ContentTools/MikkTSpace/ is gone; output byte-identical on both OSes); ImportFbx (the editor's export) is unchanged. No mutex: ufbx loads files on several threads at once (a test with 8 threads passes under TSan, ufbx itself instrumented). The FBX SDK is gone from ContentTools.vcxproj (PrimalFbxSdkDir, its libraries, CheckFbxSdk), the README, Tools/CI/WindowsRunner.md and Tools/WinVM/. Geometry processing and FBX import also build on Linux now (CMake target ContentTools, a static library; ToolsCommon.h's Windows parts are behind PRIMAL_PLATFORM_WINDOWS, pack_data() uses malloc off Windows, the unused old calculate_tangents() is gone): the first piece of #12. Compared with the SDK importer (the SDK's DLL saved in the VM before the change, both run on the SDK's 8 sample files and UnitTests/Data/ImportTest.fbx, packed output parsed and compared): same scenes, LOD groups, LOD thresholds, mesh names, submeshes per material, vertex and index counts, positions, UVs and imported normals. The only differences come from n-gon triangulation (ufbx's ear clipping vs. the SDK's): other triangles for faces with more than 3 corners, so MikkTSpace tangents and process_normals()' averaging (order dependent) differ slightly on those meshes. Imports are 10-20x faster (humanoid.fbx: 161 ms → 7.7 ms, Release). Deliberate differences: files without tangents fall back to MikkTSpace when tangents are imported (the SDK made its own); missing normals come from ufbx (generate_missing_normals). Tests: UnitTests/FbxImportTests.cpp (4, expected numbers from the SDK) and PrimalEditor.Tests/ContentToolsTests.cs (the editor's import through ContentTools.dll, passing in the VM in both editor configurations). Desktop:

    1. Build DebugEditor and ReleaseEditor: they build without the FBX SDK (it can be uninstalled afterwards).
    2. In the editor, import an FBX (one of the meshes behind x64/*.model, if the files are still around): the meshes, LODs and materials look as before, on D3D12 and Vulkan.
  52. #12, ContentTools on Linux (2026-11-23; written on Linux, checked on Linux and in the VM). The whole of ContentTools builds on both OSes (Docs/ContentTools.md section 6): DirectXTex is downloaded and compiled from source in both build systems (vcpkg is gone), stb_image loads PNG/JPEG/BMP/GIF on Linux, there's no D3D11 left (BC6H/BC7 use DirectXTex's CPU encoders), and image based lighting runs on ContentTools' own Vulkan compute device from ContentTools.shaderpack. The Vulkan SDK is needed for ContentTools now. In the editor configurations, InitializeEngine() compiles the pack (a warning if it fails). Import() initializes COM on its thread. Checked in the VM: four configurations, UnitTests Debug + Release, GraphicsTests on both backends (IBL on lavapipe), the editor tests, and the editor's start compiling the pack. Not seen yet: imports in the editor, and IBL on a real GPU on Windows. Desktop:

    1. Build DebugEditor and ReleaseEditor. x64\DebugEditor\shaders\ContentTools.shaderpack appears at the editor's first start, with no "Failed to compile ContentTools' shaders" warning in the log.
    2. In the editor, import a PNG/JPEG texture (with and without compression), a cube map from six images, and an HDR environment map with prefiltering (diffuse and specular) and the BRDF LUT. They look as before; the log names the GPU ("IBL on Vulkan: ...").
    3. Note how long the HDR import and a BC7 import take (BC7 in DirectXTex's quick mode until #81: about 3 s for 2048x2048 on 24 threads on Linux; BC6H about 17 s).
    4. GraphicsTests on the desktop GPU, both backends: the "image based lighting" suite passes.
  53. #13 step 1, Dear ImGui in the engine (2026-11-24; written on Linux, checked on Linux and in the VM; Docs/Editor.md section 9). The renderer's UI pass (graphics::UiDrawData on SurfaceFrame::ui, both backends), the new window events (pointer, wheel, text, focus), cursor shapes, clipboard and display scale in the Win32 and SDL platform layers, and the ImGui backend in Editor/UI/ (EditorUI). The Win32 half was written blind and checked in the VM: four configurations, GraphicsTests 40/40 + the "ui pass" suite on D3D12 (WARP) and Vulkan (lavapipe), the window input suite, the EDITOR_UI EngineTest on both backends (exit 0, no validation messages, the picture right on WARP). Checked by the user on the Linux desktop 2026-11-24 (all of it, "works great"). Windows desktop:

    1. Build EngineTest with /p:PrimalEngineTest=EDITOR_UI and run it on D3D12 and on Vulkan (PRIMAL_GRAPHICS): the demo window, the "Primal" window (backend, frame time); text is sharp at the desktop's scale.
    2. Type in the demo's text fields (an accented letter and an emoji through the IME), drag a window into the dock space, resize the main window, drag outside it while holding a button. The cursor changes over borders and text fields. Copy and paste between a demo text field and another program.
    3. GraphicsTests on the real GPU, both backends: "ui pass" and "platform::Window input" pass.
  54. #13 step 2, offscreen views and theme v1 (2026-11-24; written on Linux, checked on Linux and in the VM; Docs/Editor.md section 9). Offscreen surfaces (graphics::create_offscreen_surface(), both backends), the UI pass sampling them (UiDrawCommand::surface_id, imgui_backend::surface_image()), readback (graphics::request_readback()), and the editor theme (Inter + Lucide icons, downloaded and copied to x64/<Config>/fonts/; Editor/UI/Theme.*). The D3D12 half was written blind and checked in the VM: four configurations with 0 warnings, GraphicsTests "offscreen surface" + "ui pass" 16/16 on D3D12 (WARP) and Vulkan (lavapipe), the EDITOR_UI EngineTest on both (exit 0, clean logs; a VM screenshot showed the docked viewport with its moving quad). Linux desktop and Windows desktop:

    1. Run the EDITOR_UI test (Linux: preset linux-debug-editor-ui; Windows: /p:PrimalEngineTest=EDITOR_UI, both backends). The "Viewport" tab is docked in the middle, and a blue square moves across it. Resize the main window and drag the dock splitters: the viewport follows without stretching or flicker. Undock the viewport into its own floating window, then dock it again.
    2. The look: Inter (not ProggyClean), icons before "Backend" and the frame times, and a clapperboard icon on the "Viewport" tab (in the VM it looked like a "й": check it); the theme's grays and blue accent; sharp text at the desktop's scale.
    3. GraphicsTests on the real GPU, both backends: "offscreen surface" passes (it includes a pixel check of a readback).
    4. Watch for LNK1235 (a corrupt EditorUI.lib): it happened once in the VM on the first Debug build after Theme.cpp was added, and not on the rebuild.

B. Known bugs / fixes to make (either OS)

  1. D3D12Shaders.cpp reads misaligned compiled_shader records from shaders.bin (records are packed; a u64 size is misaligned when an earlier byte code size isn't a multiple of 8 — UB, harmless on x86). Port the aligned-copy loader from VulkanShaders.cpp. Windows-only file → fix and test on Windows. Fixed 2026-11-08: D3D12Shaders.cpp now uses the same loader (sizes read with memcpy, records copied to 8-byte aligned offsets; missing/corrupt file → OutputDebugStringA + return false instead of only asserting). The existing shaders/d3d12/shaders.bin had 3 of 4 records misaligned (Debug) and 2 of 4 (Release), so the new path is exercised. Debug + Release build clean; D3D12 renderer test picture normal in both, F11 OK, exit 0.

  2. compile_shaders() throws an uncaught std::filesystem_error when the shader source folder doesn't exist (executable copied elsewhere, next to an existing shaders.bin). Fixed 2026-11-08: ShaderCompilation.cpp uses the error_code overloads (up-to-date check, save, exists), logs the missing file and returns false. That exposed a crash behind it: Main.cpp calls shutdown() after a failed initialize() and test_shutdown() removed entities that were never created → TestRenderer.cpp now skips the teardown until graphics::initialize() succeeded, and run_test() returns 1 when initialize() fails. Tested on Linux with the executable + shaders/ copied to a folder without sources → "Engine shader source not found", exit 1.

  3. compile_shaders() up-to-date check ignores compiler changes. Fixed 2026-11-08: shaders.bin.key next to shaders.bin holds a hash of a format version (compiled_shaders_format_version), the DXC version (IDxcVersionInfo/IDxcVersionInfo2) and every engine shader's full argument list; a missing or different key recompiles. The key is written after shaders.bin (and deleted before writing it), so it only exists next to a complete file. shaders.bin itself is unchanged (no loader changes; T09 may still change the record layout — bump the format version then). Tested: no key → recompile, next run → none, edited key → recompile; Debug and Release get different keys.

  4. RenderItem.cpp loads ../../x64/ibl/... but the folder is IBL. Fixed 2026-11-08 (Phase 7 step 4: IBL/Set4, works on both OSes).

  5. EngineTest.vcxproj always compiles the renderer test files. Fixed 2026-11-08 (blind, check on Windows — see A12): MSBuild property PrimalEngineTest (default RENDERER; /p:PrimalEngineTest=WINDOW etc., invalid values → build error) sets the TEST_* defines and compiles Lights/RenderItem/Scripts/TestRenderer.cpp only for RENDERER and ..\EngineDLL\ShaderCompilation.cpp for RENDERER/SURFACES, like EngineTest/CMakeLists.txt. TestRenderer.cpp no longer #includes ShaderCompilation.cpp. Switching tests by editing Test.h no longer works with the .vcxproj (the defines win) — use the property. Checked on Windows 2026-11-09: the first version passed all four defines as one /D (MSBuild escapes ; from .Replace()); fixed with plain conditional properties, all variants verified.

  6. d3dx::blend_state.premultiplied has BlendEnable = 0. Fixed 2026-11-08: BlendEnable = 1 in d3dx and vkx (factors ONE / INV_SRC_ALPHA only make sense blended; alpha_blend/additive have it on). Neither preset is used anywhere yet, so nothing renders differently.

  7. Warnings (pre-existing). Fixed 2026-11-08: FreeList.h debug fill casts to void*; create_resource() got default: assert(false) like destroy_resource(); counter in TestRenderer.cpp marked [[maybe_unused]]. Linux Debug + Release now build with 0 warnings.

  8. HiDPI on Wayland — moved to T15 (2026-11-08, user's choice): windows aren't created with high pixel density, so a 125 %-scaled output gets a 2752×1152 fullscreen swapchain instead of 3440×1440; Win32 isn't DPI-aware either. Both OSes together, so window sizes mean the same thing on both.

  9. Every test_initialize() creates each swapchain twice. Fixed 2026-11-08: Vulkan resize_surface() returns early when needs_resize() is false (no flush, no recreate). D3D12's resize() still always calls ResizeBuffers (Windows-only, left as is). Checked by hand: one swapchain per window at startup and after F11, drag-resize, Alt+Enter in/out, Space → still recreated, validation clean, exit 0.

  10. Unexplained 0x80000003 exit of the D3D12 renderer test (now issue #22) (Windows Debug, 2026-11-09, first run after the rebuild). STATUS_BREAKPOINT = a __debugbreak/debug-layer break or Retry in a CRT assert dialog without a debugger. stderr ended normally after the TestShader compiles; not reproduced in two more runs. If it comes back: note any assert dialog text, or run under a debugger (D3D12 debug-layer messages only go to OutputDebugString).

  11. Existing game projects used v143 + stdcpp17/stdcpp20 (the editor idea is now issue #23) (made from the old templates; fixed in the templates 2026-11-09). Retargeted 2026-11-09: all 13 in Documents\PrimalProject\ + Documents\PrimalProjects\ → v145 + stdcpp23 (backups *.vcxproj.pre23.bak), PrimalProjects\NewProject also SDK 10.0.19041.0 → 10.0. Build check (copies in the session scratchpad, DebugEditor + Debug): the 9 without sources + a generated TestScript all build clean. Still broken, by hand: PrimalProject\NewProject and PrimalProjects\NewProject5 have scripts in an older API (Primal::Script::EntityScript, BeginPlay/Update) → port them to primal::script::EntityScript / begin_play/update or delete. The 3 that hardcode ...\RiderProjects\PRIMAL\ in Primal_IncludePath (AwesomeProject, Test, PrimalProjects\NewProject) still build against the old repo (Test OK, AwesomeProject DebugEditor fails to link that repo's Engine.lib: debug CRT symbols). A future editor version could retarget old projects on load. Editor does it now (2026-11-11, issue #23): PrimalEditor/GameProject/GameProjectUpgrade.cs, called from Project.Load() before the first game-code build. It checks GameCode\<Name>.vcxproj for the toolset, the language standard (also when none is set), a pinned Windows SDK, Primal_IncludePath/Primal_LibraryPath that don't start with $(PRIMAL_ENGINE), and the Engine\Vulkan.props import; a Yes/No box lists the changes, the old file is kept as <Name>.vcxproj.<date-time>.bak. Old-API scripts (Primal::Script::, BeginPlay() get one warning each in the editor log. The target values are constants in that file: change them together with the four MSVCProject templates. Checked: run on all 40 project files and backups on the Windows machine, the result of every old backup equals the hand-retargeted file and a second pass changes nothing; the oldest one (v143, C++17, pinned SDK, hardcoded paths, no Vulkan import) builds after the upgrade with a generated script (DebugEditor + Release). In the editor (user): AwesomeProject shows the box, No logs the warning, Yes updates the file and writes the backup, the old-API script warnings appear, a current project loads without a box. Issue #23 closed.

  12. Lock-order inversion between a descriptor heap and the deferred releases (found 2026-11-12 by ThreadSanitizer, issue #1 step 3; fixed in both backends). DescriptorHeap::free() held the heap mutex while core::set_deferred_releases_flag() took the deferred-release mutex, and process_deferred_releases() holds the deferred-release mutex while process_deferred_free() takes the heap mutex. One thread did both, so it never deadlocked; a job freeing a texture during render() could have. The flag is now set after the heap mutex is released. Vulkan: VulkanResources.cpp; D3D12 (Arash's original, blind): D3D12Resources.cpp, A19.8. The rule for later: never call into core:: while holding a resource's own mutex.

  13. The distro DXC on Linux (Arch directx-shader-compiler 1.10.2605) can't make DXIL, nor NonSemantic SPIR-V debug info (found 2026-11-15, #17). Every real shader, even a three-line vertex shader, stops in an LLVM assertion ("Error in initializing hung off uses for User"), so shader packs built on Linux hold SPIR-V only (default_shader_pack_platforms()); a pack with both is built on Windows. -fspv-debug=vulkan and vulkan-with-source assert on PostProcess.hlsl, CullLights.hlsl and TestShader.hlsl, so Debug SPIR-V uses -Zi only (OpSource with the full text + OpLine, which RenderDoc shows). Possible fix, the user's call (a new download): fetch the official DXC Linux release like doctest. Slang is no way around it (#45, 2026-11-15): Slang makes DXIL by passing generated HLSL to libdxcompiler.so, and stops in the same assertion.

  14. Now issue #68 (2026-11-21). Found on the desktop 2026-11-19 (#52 comment; the full text is in the desktop's uncommitted copy of this file): the game API has no quat_from_euler(), and a fresh Empty project logs a misleading "Failed to load game code DLL" (its game code isn't built yet). Since #59 step 1, LoadGameCodeDll logs the path and the Windows error code when LoadLibrary fails.

  15. MSVC 14.52's link-time code generation crashes on UnitTests/JobTests.cpp (C1001 in IMAGE::BuildImage, LNK1000; found 2026-11-19 with #59 step 1). Release only (/GL + /LTCG), only since the engine is a DLL that the file imports primal.jobs from, and not caused by the export marks (it stays without any dllexport in the module interface; bisected in the VM to that one file). EngineTest, EngineDLL and ShaderCompilerTool import the module too and link. Worked around: JobTests.cpp is compiled without whole-program optimization (UnitTests.vcxproj). Retry without it on a newer MSVC; report it to Microsoft if it stays. Seen again 2026-11-21 in the VM on vectortests.cpp (same C1001/LNK1000, Release, /LTCG:incremental): this time a stale incremental database; deleting x64\Release\UnitTests.iobj and .ipdb fixed it. Try that first when the crash names another file.

  16. Fixed 2026-11-23 (#28): D3D12 hung when the renderer was shut down after a restart that uploaded nothing. upload::shutdown() waited for each upload frame's fence_value, which was kept from the previous session while the new fence started at 0, so SetEventOnCompletion(value, nullptr) never returned. Seen as GraphicsTests hanging in "the renderer starts and stops without a surface" after any scene test. UploadFrame::release() resets the value now (Vulkan already did).

C. Still to verify on Linux

  • Milestone e and f visual checks — done by the user 2026-11-08 ("looks right").

  • Phase 7 renderer test visual check — done 2026-11-08 ("picture looks right", user); covers milestone g too.

  • Milestone g visual check (by the user): the 6g driver in --interactive mode — IBL ambient lighting on all surfaces (no more black unlit sides), metal/rough spheres reflect the environment, the sky (specular cube map) behind the scene, consistent orientation (sky not upside down/mirrored). Then the full renderer test in Phase 7, and RenderDoc vs D3D12 on Windows.

  • Interactive keys — done 2026-11-08 in the renderer test (Esc, F11, Alt+Enter, drag-resize on Wayland and X11). Space (vsync toggle) done 2026-11-08: FIFO (3 images) ↔ MAILBOX (4 images) on Wayland, all 4 swapchains recreated, Debug + validation ~145 fps capped → ~190–275 fps uncapped, validation clean, exit 0.

  • HDR output with HDR enabled in KDE (FP16 scRGB swapchain). Now issue #24.

  • gen_windb.py on /std:c++latest — done 2026-11-09: it passes /std:c++23preview (clang-cl 23 accepts it and selects C++23); the 10 Windows databases were regenerated and clang-tidy is at 0 warnings in all 15.

  • #59 step 6 (written on the Windows desktop): done 2026-11-21 on Linux, with step 7 (next item). The Linux checks of its C++ (EngineDLL exports, engine changes): clang + GCC Debug/Release, ci.sh tidy (0 findings, by tidy's own exit code), ci.sh sanitizers, ci.sh checks (layers, log usage), UnitTests and GraphicsTests. CI's Linux job covers most of it on push.

  • #59 step 7 (Windows desktop, 2026-11-21): entity scripts removed. Done 2026-11-21 on Linux (HEAD 8f333d9 plus fixes): ci.sh checks, clang + GCC Debug/Release (0 warnings; UnitTests 239 Debug / 241 Release, GraphicsTests 22, the test game), ci.sh sanitizers, ci.sh tidy 0. Fixes: clang-format in 11 files (the desktop has none), one modernize-use-emplace (ContentLoaderTests.cpp), and the test game's generated game.bin was still version 3 (UnitTests/CMakeLists.txt, now 5). What it checked: the same checks, and in particular, as none of it was compiled by clang or GCC: GraphicsTests/SceneTests.cpp + TestSession.* (no compiler saw them: CMake only; the spinning entities are written between frames now, and the file has no reflection markers any more), UnitTests/GameLibrary/GameLibrary.cpp + GameLibraryTests.cpp (Linux only: dlopen), the renamed UnitTests/TypeRegistry* and new GameSystemTests.cpp (CMake lists), EntityTests.cpp dropped from primal_reflect(), and GCC's view of EngineTest/Scripts.cpp (behaviors; CameraScript keeps its math::vecs on the heap for MSVC's C4324).

D. Remaining work

  • Phase 7 — done 2026-11-08 (Linux steps 2–5, Windows step 6, RenderDoc A7).
  • Exact MSVC C++23 setting. Done 2026-11-09: MSBuild LanguageStandard stdcpp23 = /std:c++23preview (v145). All .vcxproj files (Engine, EngineDLL, EngineTest, ContentTools, ShaderCompilerTool) and the game project templates switched from stdcpplatest (which lets C++26 features through); all 4 configs rebuild clean.
  • Mesh/hull/geometry shader stages in vkx::graphics_pipeline_desc (only when a material needs them).
  • Everything beyond the port (multithreading, code style, backend unification, modern C++, math library, GCC, shared shader folder, shader build robustness, pipeline caches, indirect gpass, ContentTools/editor on Linux, CI, HiDPI) is in Forgejo issues.

Current state (summary of review)

Snapshot from the start of the port (2026-11-04); the phase sections below say what changed.

  • Build: MSBuild .vcxproj only (toolset v145) + NuGet (D3D12 Agility SDK, DXC).
  • Graphics is already abstracted: Renderer.cpp dispatches through the platform_interface function table and graphics_platform enum. A Vulkan backend plugs in alongside D3D12 without changing the engine API.
  • Windows coupling outside the D3D12 backend:
    • PlatformTypes.h (window_proc is a WNDPROC), PlatformWin32.cpp, InputWin32.*
    • Core/EngineWin32.cpp, Core/MainWin32.cpp, Content/ContentLoaderWin32.cpp
    • Utilities/Math.h (_BitScan*64, DirectXMath include gated on _WIN64), MathTypes.h
    • Utilities/Threading.h (has a non-Windows fallback already)
    • Components/Script.cpp (ATL SAFEARRAY export, editor-only)
    • EngineTest: Main.cpp (WinMain, _CrtSetDbgFlag, #pragma comment(lib)), Test.h (OutputDebugStringA), TestWindow.h / TestRenderer.cpp (Win32 window procedures, MessageBox), RenderItem.cpp (backslash paths, "enginetest" casing)
    • EngineTest compiles shaders by #include-ing EngineDLL/ShaderCompilation.cpp (wrl.h ComPtr + DXC → DXIL only).
  • Backslash #include paths in Renderer.cpp, D3D12CommonHeaders.h, D3D12Interface.cpp, D3D12Shaders.cpp, TestWindow.h, TestEntityComponents.h.

Editor (AvaloniaUI) compatibility constraints

The editor talks to the engine through EngineDLL (C ABI, P/Invoke). Today that ABI contains HWND (CreateRenderSurface(HWND host, …), GetWindowHandle), LPSAFEARRAY/BSTR (get_script_names), and LoadLibrary/GetProcAddress for game code. Avalonia on Linux runs on X11 (XWayland on Wayland desktops); NativeControlHost hands us a parent X11 window (XID) and expects a child native window handle back.

Rules every phase must respect so an Avalonia editor can be added later:

  1. Native handles are opaque, not SDL objects. The platform layer exposes a native_window_handle { kind (win32/x11/wayland), display, window }. The Vulkan backend creates VkSurfaceKHR from that struct (xlib/xcb/wayland surface extensions enabled explicitly), never from an SDL_Window*. SDL3 is used for standalone windows (EngineTest, game) and its native handles are extracted via SDL window properties.
  2. Parented windows must be supported. window_init_info::parent becomes an opaque native parent handle. On Linux an editor render surface is an X11 child window created under the Avalonia host XID (native X11 path, not SDL).
  3. Input must be injectable. The input module must accept events pushed from outside (editor forwards Avalonia input), not only events pumped by SDL.
  4. C ABI only, UTF-8 strings. No wchar_t across the editor boundary (4 bytes on Linux, 2 in C#), no SAFEARRAY/BSTR, no HWND in signatures (u64/void* instead). Window captions move to UTF-8.
  5. Engine is built position-independent (-fPIC) so it can be linked into libEngineDLL.so. EDITOR_INTERFACE gets a visibility("default") variant; LoadLibrary/GetProcAddress → dlopen/dlsym.
  6. Shader compilation stays a reusable library (DXC on Linux, Phase 5) so EngineDLL can use it, not just EngineTest.
  7. View models without UI framework types (2026-11-20, issue #61): the editor's models (Actor, Scene, GameEntity, ...) don't use WPF types (System.Windows.Thickness, Visibility); views and converters do. Then the C# tests of #61 run against both editors and check that the port keeps behaviour. Some models still use them.

Out of scope for now (needed for a full Linux editor later): EngineDLL Linux build, ContentTools (DirectXTex/asset import) on Linux, the Avalonia editor itself.

Phase 0 – Prerequisites

Install (repo packages): cmake ninja vulkan-headers vulkan-validation-layers directx-shader-compiler (optional: vulkan-memory-allocator renderdoc). Already present: clang, gcc, glslc, spirv-val, SDL3, GLFW, vulkaninfo, shaderc. (Note: ninja in the zsh profile is an alias; the binary itself is not installed.)

DirectXMath is not packaged; CMake fetches it (pinned tarball). Its required sal.h is provided by a tiny stub in Engine/ThirdParty/sal/ (non-Windows only).

Status 2026-11-05: installed vulkan-headers / vulkan-icd-loader / vulkan-validation-layers / vulkan-tools 1.4.363 and vulkan-memory-allocator 3.5.0 (for milestone b). RenderDoc is not installed yet (needed for the D3D12 reference-frame comparisons from milestone c on). Driver: Mesa 26.2.6 RADV.

Phase 1 – CMake build alongside the .vcxproj files

  • Root CMakeLists.txt + CMakePresets.json (linux-debug, linux-release; Ninja + clang).
  • Engine static library (PIC), EngineTest executable. Linux source lists exclude Win32 and D3D12 files.
  • Flags matching the vcxproj intent: C++23 (CMAKE_CXX_STANDARD 23, strict, no extensions; vcxproj uses stdcpp23 since 2026-11-09, stdcpplatest before), AVX2/FMA/F16C/SSE4.2, fast-ish FP (-ffp-contract=fast -fno-math-errno, not -ffast-math).
  • EngineTest output goes to x64/<Config>/ so the existing ../../x64/... asset paths and ../../Engine/... shader source path resolve the same as on Windows.
  • Test selection via CMake cache var PRIMAL_ENGINE_TEST (ENTITY_COMPONENTS / WINDOW / RENDERER); Test.h defaults are kept for Visual Studio.
  • Fix backslash #includes; guard #pragma comment(lib, …) with _MSC_VER.
  • Phase 1 goal: the project configures and the build reaches compile errors that are Phase 2 items (no build-system errors).

Phase 2 – Core portability (TEST_ENTITY_COMPONENTS)

  • Add a platform-detection header (PRIMAL_PLATFORM_WINDOWS / PRIMAL_PLATFORM_LINUX) and use it instead of scattered _WIN64 checks.
  • DirectXMath on all platforms (Math.h, MathTypes.h, Transform.cpp, content loader).
  • _BitScanReverse64/Forward64 → std::countl_zero/countr_zero; _countof → std::size; <immintrin.h> for _mm_pause/_mm_crc32_u64.
  • Ensure the non-Windows ticket_mutex uses std::atomic members.
  • Renderer: gate the D3D12 backend behind a build define so Renderer.cpp links on Linux.
  • EngineTest/Main.cpp non-Windows path: drop _CrtSetDbgFlag, use ASan/LSan (CMake option). Port set_current_directory_to_executable_path (/proc/self/exe) into a shared utility.
  • Test.h time_it: portable logging (stderr).

Phase 2 – done (2026-11-04)

  • Engine/Common/PlatformDetection.h (new, included by CommonHeaders.h): PRIMAL_PLATFORM_WINDOWS / PRIMAL_PLATFORM_LINUX (always 0/1, use #if), plus overridable PRIMAL_GRAPHICS_D3D12 (defaults to Windows) and PRIMAL_GRAPHICS_VULKAN (0 then; defaults to Linux since Phase 6a). Added to Engine.vcxproj + filters.
  • Math.h / MathTypes.h: DirectXMath on all platforms; <immintrin.h>; log2 now constexpr, implemented as std::bit_width(value - 1) (same results as the _BitScan* version).
  • Threading.h: <atomic> / <immintrin.h> includes; Windows path unchanged.
  • Renderer.cpp: D3D12 include and switch case gated on PRIMAL_GRAPHICS_D3D12.
  • ContentToEngine.cpp: explicit cast fixes a narrowing error clang rejects.
  • EngineTest/Main.cpp: Linux main() + /proc/self/exe working-directory helper; leak checking via -DPRIMAL_ENABLE_SANITIZERS=ON instead of _CrtSetDbgFlag.
  • EngineTest/Test.h: time_it portable (stderr on Linux).
  • Bugs found and fixed (they affect Windows too):
    • utl::vector::erase used memcpy on overlapping ranges (UB; caught by ASan) → memmove.
    • time_it mixed high_resolution_clock and steady_clock (same type on MSVC only) → steady_clock.
  • Deferred:
    • The shared "set cwd to executable path" utility → done in Phase 4 (platform::set_current_directory_to_executable_path()).
    • _countof → std::size in TestWindow.h / TestRenderer.cpp / RenderItem.cpp: done with those files in Phases 3 and 7 (they aren't compiled yet on Linux).
    • GCC is not supported yet; clang is the Linux compiler. GCC 16 rejects (a) a member named like its type, e.g. camera_id camera_id; (-Wchanges-meaning, ill-formed NDR in the standard) in Renderer.h, GraphicsPlatformInterface.h, Input.h; (b) members with constructors in an anonymous struct inside a union (MSVC extension) in Transform.cpp. Fixing (a) means renaming public API types/members, so it's a separate decision.
    • Existing clang warnings left as-is: -Wnontrivial-memcall in Vector.h/FreeList.h (intentional relocation via memcpy/memset), -Wswitch in ContentToEngine.cpp.

Phase 3 – Platform layer (TEST_WINDOW)

  • SDL3 for standalone windows, input, event pump. Native X11 path reserved for parented (editor) windows — see editor constraints 1–3.
  • Replace the Win32 window_proc in window_init_info with an engine event callback (close, resize, fullscreen toggle, key/mouse). UTF-8 captions.
  • PlatformLinux.cpp mirroring PlatformWin32.cpp (free list of windows, resize, fullscreen, is_closed); window::handle() returns the opaque native handle.
  • InputSDL.cpp: SDL scancodes/mouse → input_code (like vk_mapping in InputWin32.cpp).
  • Platform pump_events() replaces PeekMessage loops in MainWin32.cpp and EngineTest/Main.cpp; port window procedure logic in TestWindow.h, TestRenderer.cpp, EngineWin32.cpp (quit when all windows closed, Alt+Enter fullscreen).

Phase 3 – done (2026-11-04)

One platform API for both platforms (Platform/PlatformTypes.h, Platform/Window.h):

  • native_window_handle { kind (win32/x11/wayland), display, window }. window::handle() returns const native_window_handle* (editor constraint 1). It points into the window list: copy it if it's needed after the next create_window/remove_window. D3D12 takes the HWND from it.
  • window_init_info: window_event_callback (no more WNDPROC), UTF-8 caption, parent is a native_window_handle* (editor host window).
  • window_event { closed, resized, key_down, key_up } with input_code and modifier flags. Key repeats update input state but aren't sent as events. resized is sent once a drag-resize finishes (Win32: left mouse button released), the same rule as before. Callbacks may remove windows, including the one the event is for (events are sent last).
  • window::close() (same as the user closing it), window::set_caption(const char*) (UTF-8).
  • Closing a window hides it and sends closed; the native handle stays valid until remove_window(). (Win32 previously destroyed the HWND on close.)
  • platform::pump_events() (false once a quit was requested) and platform::post_quit(). Closing the last window doesn't quit by itself. On Linux SIGINT/SIGTERM quit cleanly.

Windows (PlatformWin32.cpp, InputWin32.*): internal window procedure translates messages to events, handles WM_CLOSE (hide + event), Alt+Enter beep suppression and SC_KEYMENU; UTF-8 → UTF-16 for captions (CreateWindowExW/SetWindowTextW); map_virtual_key() / modifier_keys(). Mouse tracking (TrackMouseEvent for WM_MOUSEHOVER/WM_MOUSELEAVE, used by the editor's RenderSurfaceControl) moved from EngineDLL's WinProc into PlatformWin32.cpp, per child window. Consumers moved to the shared API: EngineDLL/EngineAPI.cpp (CreateRenderSurface wraps the host HWND as the parent; the C ABI and C# side are unchanged), D3D12Surface.cpp, Core/EngineWin32.cpp, Core/MainWin32.cpp, EngineTest/Main.cpp (one run_test() loop for both platforms), TestWindow.h (one version), TestRenderer.cpp (event callback; Esc closes a window, Space toggles vsync, F11 restarts, Alt+Enter fullscreen). Test window positions are now on-screen (were offset for a multi-monitor setup). The Windows side has not been compiled yet (no MSVC/MinGW on the Linux machine).

Linux (PlatformLinux.cpp, InputSDL.*, SDL3):

  • SDL picks Wayland on KDE; SDL_VIDEO_DRIVER=x11 forces X11. Both tested.
  • Until a graphics surface exists, windows are filled with the Win32 class background color RGB(26, 48, 76) through SDL's window surface. Needed on Wayland, where a window that never presents a buffer doesn't appear. Done in Phase 6a: the Vulkan surface calls window::set_has_graphics_surface(true), which stops the painting and calls SDL_DestroyWindowSurface before the swapchain is created. The window surface must be SDL's software framebuffer (SDL_HINT_FRAMEBUFFER_ACCELERATION=0): the default GPU-backed one recreates the X11 window (new XID).
  • Scancodes → input_code (physical key positions; Win32 maps layout-dependent virtual keys, so letters differ on non-QWERTY layouts). Generic key_shift/key_control/key_alt stay down while either side is held. Wheel scaled to 120 per notch like Win32.
  • SDL video shutdown is deferred to the end of pump_events() so callbacks can remove all windows and create new ones (F11 restart).
  • Parented windows assert "not supported yet" (editor constraint 2: X11 child windows).
  • Sanitizers: X11 clean. Wayland reports a 256-byte leak from a library SDL dlcloses (no engine frames); not ours.

Deferred: Linux game executable and the shared working-directory helper → done in Phase 4.

Phase 4 – Content and paths

  • ContentLoaderWin32.cpp → ContentLoader.cpp (already std::filesystem); same for EngineWin32.cpp. Remove _WIN64 gates / <Windows.h>.
  • Forward slashes / std::filesystem::path for Renderer.cpp shader path table and the 18 asset paths in RenderItem.cpp; fix "enginetest" casing.
  • Assets (.model, .texture, IBL) are generated on Windows with ContentTools and copied over. Textures store DXGI_FORMAT; Vulkan backend needs a DXGI → VkFormat table (BC formats OK on RADV).

Phase 4 – done (2026-11-04)

  • Content/ContentLoaderWin32.cpp → Content/ContentLoader.cpp and Core/EngineWin32.cpp → Core/Engine.cpp: platform-neutral, only gated on !SHIPPING. Renamed with plain mv (stage the renames yourself). Engine.vcxproj + filters updated.
  • Core/MainLinux.cpp: Linux game main() (counterpart of MainWin32.cpp's WinMain). Executables with their own main() (EngineTest) don't pull it from libengine.a.
  • platform::set_current_directory_to_executable_path() (Platform.h, implemented per platform) replaces the copies in MainWin32.cpp and EngineTest/Main.cpp.
  • Paths: Renderer.cpp engine shader paths and the 17 asset paths + test shader folder in RenderItem.cpp use forward slashes; "enginetest" → "EngineTest" (Linux is case-sensitive).
  • Bugs found and fixed (they affect Windows too):
    • load_game() read the u32 entity/component counts, component types and script name length as a single byte (*at), so values > 255 were wrong. The editor writes them as 4-byte ints (Project.cs, Script.cs); now read with read_u32().
    • engine_shutdown() removed the game window even when engine_initialize() failed before creating it (assert / bad free-list access when game.bin is missing).
  • Tested on Linux: a game executable linked from libengine.a alone loads a hand-made game.bin (one transform entity) when started from another directory, runs, and quits cleanly on SIGTERM; a missing game.bin now exits cleanly.
  • Still to do by hand: copy the renderer test assets generated on Windows (x64/*.model, x64/*.texture, x64/ibl/...) to x64/ on Linux before Phase 7.
  • Deferred to Phase 6: DXGI → VkFormat table for textures.

Phase 5 – Shader pipeline (HLSL → SPIR-V)

  • Keep HLSL; DXC -spirv -fspv-target-env=vulkan1.3.
  • Port the compiler from ShaderCompilation.cpp to DXC's Linux WinAdapter (CComPtr, libdxcompiler.so); make it backend-aware instead of hardcoding direct3d12.
  • Bindings: -fvk-{b,t,u,s}-shift for register(xN, space0); -fvk-bind-resource-heap / -fvk-bind-sampler-heap for SM6.6 ResourceDescriptorHeap[...] (requires VK_EXT_mutable_descriptor_type, supported by RADV).
  • Drop -Qstrip_reflect/-Qstrip_debug for SPIR-V; DXC gives no shader hash for SPIR-V, so compute our own for pack_compiled_shader.
  • Add graphics_platform::vulkan + shaders/vulkan/shaders.bin.
  • Validate all modules with spirv-val.
  • Consider moving Direct3D12/Shaders/ → Graphics/Shaders/ (shared) and checking SharedTypes.h layouts under SPIR-V rules.

Phase 5 – done (2026-11-04)

  • EngineDLL/ShaderCompilation.cpp/.h builds on both platforms and is backend-aware: compile_shaders(platform), compile_shader(..., platform); default default_shader_platform (D3D12 on Windows, Vulkan on Linux), so existing callers (EngineDLL, EngineTest) are unchanged.

    • Linux: DXC's libdxcompiler.so + <dxc/dxcapi.h> (WinAdapter.h COM shim); com_ptr<T> wraps CComPtr (Windows: WRL ComPtr). Logging → stderr; __debugbreak → __builtin_debugtrap.
    • CMake: ShaderCompiler static library (PIC, links dxcompiler). On Windows the .vcxproj files keep compiling the .cpp directly. TestRenderer.cpp still #includes the .cpp; switch it to the library on Linux in Phase 7.
  • graphics_platform::vulkan (= 1) and ./shaders/vulkan/shaders.bin (same file format as D3D12: { u64 size, u8 hash[16], byte code } per engine shader).

  • SPIR-V flags (add_spirv_args): -spirv -fspv-target-env=vulkan1.3 -fvk-use-dx-layout, -fvk-{b,t,u,s}-shift {0,100,200,300} 0, -fvk-bind-resource-heap 0 1, -fvk-bind-sampler-heap 0 2. No -Qstrip_* for SPIR-V. Resulting layout for Phase 6:

    HLSL Vulkan
    register(bN, space0) set 0, binding N
    register(tN, space0) set 0, binding 100 + N
    register(uN, space0) set 0, binding 200 + N
    register(sN, space0) set 0, binding 300 + N
    ResourceDescriptorHeap[] set 1, binding 0 (mutable descriptors; several typed views alias it)
    SamplerDescriptorHeap[] set 2, binding 0 (not used by current shaders)
    • -fvk-use-dx-layout: buffers use D3D layout rules, so SharedTypes.h structs match on both backends. Vulkan device needs scalarBlockLayout.
    • -enable-16bit-types: device needs shaderFloat16/shaderInt16 and 16-bit storage features.
    • Root constants (b1 ShaderParams etc. where D3D12 uses root constants) are plain uniform buffers in SPIR-V for now; push constants are a Phase 6 decision ([[vk::push_constant]]).
  • SPIR-V shader hash: DXC only hashes DXIL, so SPIR-V byte code gets a 128-bit FNV-1a.

  • DXC can't disassemble SPIR-V; disassembly (editor-only) is skipped for SPIR-V (use spirv-dis).

  • Bugs found and fixed (they affect Windows too):

    • utl::vector relocated items with realloc/memmove/memcpy. That breaks types that point into themselves, which in libstdc++ includes std::string/std::wstring and std::unordered_map (DXC got garbage arguments → "Internal Compiler error" + heap corruption). vector<T, true> now move-constructs items that aren't trivially copyable but are movable; everything else (and vector<T, false>/free_list) keeps bitwise relocation.
    • free_list<noexcept_map> (ContentToEngine shader groups): the std::unordered_map is now heap-allocated (unique_ptr), because free_list must relocate bitwise.
    • The compiled-shader blobs were never freed (a ComPtr built from Detach() adds a reference); now Attach()ed.
  • Tested on Linux with a scratch driver linked to ShaderCompiler: compile_shaders(vulkan) writes shaders.bin (4 modules), compile_shader() builds the 5 TestShader variants; all 9 modules pass spirv-val --target-env vulkan1.3 --scalar-block-layout.

  • Not done: moving Direct3D12/Shaders/ to a shared Graphics/Shaders/ (touches Windows project files; the path is one constant, shaders_source_path).

Phase 5 – review (2026-11-05)

Re-verified at commit 367babd before starting Phase 6:

  • Clean Debug, Debug + ASan/UBSan and Release builds (clang 23).
  • Shader compiler driver (Steps doc V4): compile_shaders(vulkan) + the 5 TestShader variants succeed in Debug (sanitizers clean, no leaks) and Release (-O3 SPIR-V); all 9 modules pass spirv-val --target-env vulkan1.3 --scalar-block-layout. Bindings match the table above.
  • 128-bit FNV-1a multiply checked by hand: (hi·2⁶⁴ + lo)·(2⁸⁸ + 0x13b) mod 2¹²⁸ is what the code computes.
  • Fix: noexcept_map's copy operations were = default but implicitly deleted (unique_ptr member; clang -Wdefaulted-function-deleted) → now = delete.

Tooling: .clang-format / .clang-tidy (2026-11-05)

  • .clang-format encodes Arash's style: Allman braces (union/namespace stay inline), return type on its own line for top-level definitions, { 1, 2 } braced lists with spaces, 4 spaces, no namespace indent, T* p (also T* const p; clang-format can't keep Arash's T *const p mix), ColumnLimit: 0 (keeps existing line breaks), no include sorting, no declaration alignment (clang-format can only align tightly, and would also align locals). Not applied to existing files.
  • .clang-tidy: bugprone / clang-analyzer / performance / modernize (minus noisy ones) and readability-identifier-naming for the current snake_case convention (_member for private / protected, UPPER_CASE macros, PascalCase Win32/COM/C-ABI names allowed). run-clang-tidy -p build/linux-debug → ~120 findings, mostly modernize/performance (see the "Future: modern C++ rework" list). Linux compile DB only: D3D12/Win32 files aren't analyzed.

Phase 6 – Vulkan backend (Engine/Graphics/Vulkan/, one module per D3D12 module)

Milestone Modules Result
a Core, Surface, Interface instance/device, queues, frames in flight, deferred release, swapchain per window, resize; 4 windows clear
b Resources, Helpers buffers/images (VMA), bindless descriptor heap, samplers, pipeline layout (root constants → push constants)
c PostProcess, Shaders fullscreen triangle + post-process to swapchain
d Upload, Content staging uploads, meshes (single buffer), textures, materials, render items, pipeline cache
e Camera, GPass depth prepass + main pass, vkCmdDrawIndexedIndirect; negative viewport height for D3D Y convention
f LightCulling, Light grid frustums + cull-lights compute, light sets, compute↔graphics barriers
g — IBL/ambient, parity with D3D12

Surface creation follows editor constraint 1 (opaque native handles).

Phase 6a – done (2026-11-05)

New: Engine/Graphics/Vulkan/ — VulkanCommonHeaders.h, VulkanCore.h/.cpp, VulkanSurface.h/.cpp, VulkanInterface.h/.cpp (same split and names as the D3D12 modules; primal::graphics::vulkan). Linked from CMake (find_package(Vulkan 1.3)), PRIMAL_GRAPHICS_VULKAN now defaults to 1 on Linux, Renderer.cpp dispatches graphics_platform::vulkan. Not in the .vcxproj files.

  • Instance: Vulkan 1.3, VK_KHR_surface + whichever of VK_KHR_xlib_surface / VK_KHR_wayland_surface exist. Debug: VK_LAYER_KHRONOS_validation with synchronization validation (VK_EXT_layer_settings), debug-utils messenger (warnings/errors → stderr, error count printed at shutdown), object names (NAME_VK_OBJECT). PRIMAL_VULKAN_VALIDATION=0 turns validation off.
  • Device: best ranked GPU (discrete > integrated) with Vulkan 1.3, VK_KHR_swapchain, VK_EXT_mutable_descriptor_type, one graphics+compute queue, and every feature later milestones need (checked up front, missing ones are listed): 16-bit types, scalar block layout, descriptor indexing + update-after-bind, mutable descriptors, timeline semaphores, dynamic rendering, synchronization2, maintenance4, multi-draw/draw-indirect-count, buffer device address.
  • Frames: vulkan_command (counterpart of d3d12_command): frame_buffer_count (3) command pools/buffers, one timeline semaphore used like the D3D12 fence (fence_value per frame), a binary "image acquired" semaphore per frame. flush() waits for all frames and vkQueueWaitIdle (see lessons). Each render_surface() is one frame, like D3D12.
  • Deferred release: core::deferred_release(handle) (typed, detail::object_type<T>()), same frame counting as D3D12.
  • Surfaces: vulkan_surface creates the VkSurfaceKHR from native_window_handle (xlib / wayland; editor constraint 1), swapchain with B8G8R8A8_SRGB (fallback R8G8B8A8_SRGB, else first), 3 images, FIFO with vsync, mailbox → immediate → FIFO without. Per-image present semaphores. Recreated when the window size, the vsync option or VK_ERROR_OUT_OF_DATE/SUBOPTIMAL say so; skipped while minimized (extent 0). Wayland's 0xFFFFFFFF extent → window size. Back buffer differs from D3D12 (FP16 scRGB there): revisit with post-process in milestone c (done: 6c prefers FP16 scRGB).
  • Milestone a rendering: render_surface() ignores frame_info and clears with dynamic rendering (pulsing color per surface), sync2 barriers UNDEFINED → COLOR_ATTACHMENT → PRESENT_SRC. Lights/cameras/resources entries of the platform_interface stay null until milestones d–f.
  • Platform: window::set_has_graphics_surface(bool) (Linux: stop painting + SDL_DestroyWindowSurface; Win32: no-op — Windows edit, not compiled). SDL_HINT_FRAMEBUFFER_ACCELERATION=0 (fixes X11, see lessons in the Steps doc).
  • Test: -DPRIMAL_ENGINE_TEST=SURFACES → EngineTest/TestSurfaces.h: 4 windows, Esc / Space (vsync) / F11 (restart) / Alt+Enter like the renderer test. Test.h / Main.cpp know TEST_SURFACES (default 0).
  • Verified (Debug, Debug + ASan/UBSan, Release build): X11 and Wayland; screenshots show the expected sRGB colors; a scripted driver (resize, vsync off/on, remove + recreate a surface on the same window, fullscreen, deferred releases, full restart) has no validation errors, no sanitizer reports (with the dlclose shim), exit 0. Wayland vsync: ~145 fps (144 Hz) for 4 windows; XWayland: ~76.
  • Not verified: interactive keys (no xdotool here) — run the SURFACES test and try Esc / Space / F11 / Alt+Enter / drag-resize by hand.

Phase 6b – done (2026-11-06)

New: VulkanHelpers.h/.cpp (vkx, counterpart of d3dx), VulkanResources.h/.cpp (counterpart of D3D12Resources), VulkanMemoryAllocator.cpp (compiles VMA once, warnings off), Engine/ThirdParty/vma/vk_mem_alloc.h (VMA 3.5.0, MIT, vendored so both OSes use the same version; the Arch package has the same file). Added to CMake, Engine.vcxproj (+ filters, PrimalVulkan condition) and Vulkan.props (VMA include path).

How the D3D12 binding model maps (the decision this milestone had to make):

D3D12 Vulkan
Root CBV / SRV / UAV (SetGraphicsRoot*View(gpu_address)) Set 0 is a push descriptor set (VK_KHR_push_descriptor, now a required device extension; core in 1.4). vkx::root_descriptors collects cbv/srv/uav(register, vkx::buffer_range) and records one vkCmdPushDescriptorSetKHR. buffer_range (buffer + offset + size) replaces D3D12_GPU_VIRTUAL_ADDRESS.
Root constants (b1 in post-process) Uniform buffer: the shaders already declare them as ConstantBuffer<T>, so the values go into the frame's constant buffer and bind as a root CBV. No shader changes. Push constants stay possible later ([[vk::push_constant]]).
Static samplers Immutable samplers in set 0 (binding 300 + N). Core creates the 3 D3D12 samplers once (core::static_sampler(), vkx::sampler_info(), anisotropy clamped to the device limit).
Root signature vkx::root_signature = pipeline layout [set 0 push layout, set 1 heap layout], built from vkx::root_parameter::cbv/srv/uav/sampler(register, visibility); vkx::release() defers both.
Shader-visible CBV/SRV/UAV heap descriptor_heap (core::srv_heap(), 4096 like D3D12): set 1 binding 0, one array of VK_DESCRIPTOR_TYPE_MUTABLE_EXT (sampled image, storage image, uniform buffer, storage buffer), partially bound + update-after-bind + update-unused-while-pending. Same free list and deferred free as D3D12; write_sampled_image/storage_image/storage_buffer/uniform_buffer(handle, ...). vkx::bind_resource_heap() = SetDescriptorHeaps.
RTV / DSV / non-visible UAV heaps None: render targets and depth buffers use image views; UAV clears use vkCmdFillBuffer.
Resource states / barriers vkx::resource_state {stage, access, layout} with D3D12-named presets (vkx::resource_states.render_target, .pixel_shader_resource, .copy_dest, ...); vkx::vulkan_barrier batches sync2 barriers, vkx::transition_image() for one. Shader reads use VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL (color and depth alike).
  • Resources: vulkan_buffer (VMA; CPU-accessible = host-visible sequential-write, persistently mapped; initial data for GPU-only buffers asserts until the upload module, milestone d), constant_buffer (per frame, 1 MB, 256-byte alignment = the spec's maximum offset alignment; range(T*) = gpu_address(T*); usage UBO|SSBO|indirect because D3D12 uses the same init info for light buffers and indirect args), uav_clearable_buffer (clear_uav() = vkCmdFillBuffer of values[0], like an R32 UAV clear), vulkan_texture (VMA image + SRV view + heap slot; render targets/depth get dedicated memory), vulkan_render_texture (+ one color attachment view per mip), vulkan_depth_buffer (one depth view is both DSV and SRV).
  • Core: VMA allocator, static samplers, resource heap, 3 constant buffers (cleared at the start of each frame). Deferred releases carry an optional VmaAllocation (core::deferred_release(buffer_or_image, allocation)); heap slots are freed in process_deferred_releases(). Shutdown order: modules → constant buffers → deferred releases → heap → deferred releases → samplers → allocator → device.
  • Milestone b scaffolding (core::scratch in VulkanCore.cpp, replaced in milestones c/e): each surface renders into an R16G16B16A16_SFLOAT target + D32 depth (same formats as the D3D12 gpass, grown to the largest surface like gpass::set_size()), cleared with dynamic rendering, then blitted to the swapchain. Each frame it also writes the constant buffer, clears a UAV buffer, pushes root descriptors and binds the heap, so the validation layer checks them. The SURFACES test looks the same as in milestone a.
  • For milestone e: the D3D12 gpass uses ExecuteIndirect with a command signature that changes root CBVs/SRVs per draw. Push descriptors can't change inside vkCmdDrawIndexedIndirect. Options: record a CPU loop of push descriptors + vkCmdDrawIndexed (the commands are built on the CPU anyway), or VK_EXT_device_generated_commands (RADV has it; check the Windows drivers). Decide in e.
  • Verified (Linux): Debug, Release, Debug + ASan/UBSan build with no new warnings; clang-tidy clean apart from {} member initializers kept for D3D12 parity; -Wshadow-all clean (MSVC C4458 at /W4). A scripted driver (3 rounds: frames, grow/shrink windows → offscreen buffers recreated, vsync off/on, remove + re-add a surface, full renderer restart) exits 0 with no validation or sync-validation messages and no ASan/UBSan reports, in Debug + ASan and Release. LSan without the dlclose shim reports 256 bytes per VkInstance in an unloaded module (a layer or ICD, no engine frames); with the shim, nothing.
  • Environment note: during this session the display session was throttling (21 fps for 4 windows on Wayland, and XWayland gave no frames and ignored SIGTERM) — the committed milestone a build behaved the same, so it isn't 6b. Re-check the frame rate (~145 fps on Wayland in 6a) at the desk.
  • Not verified: Windows (MSVC) build and run — new files, Vulkan.props include path, and VK_KHR_push_descriptor on the Windows AMD driver. Visual check of the SURFACES test at the desk.
  • Re-checked in 6c (2026-11-07): Wayland back to ~145 fps, X11 ~76 fps — the 6b slowdown was the session.

Phase 6c – done (2026-11-07)

New: VulkanShaders.h/.cpp, VulkanGPass.h/.cpp, VulkanPostProcess.h/.cpp (same names and structure as the D3D12 modules), VulkanSharedTypes.h (vulkan::hlsl, includes Direct3D12/Shaders/CommonTypes.hlsli; D3D12's SharedTypes.h pulls in the D3D12 headers). Added to CMake and Engine.vcxproj (+ filters). The 6b scaffolding (core::scratch) is gone.

  • Shaders: shaders::get_engine_shader(id) → vkx::shader_bytecode {SPIR-V words, size, entry point}. DXC keeps the HLSL function names as SPIR-V entry points (FullScreenTriangleVS, PostProcessPS, ...), so the module has a name table in engine_shader order. A missing shaders/vulkan/shaders.bin is logged instead of asserting.
  • Pipeline helpers (vkx): rasterizer_state / depth_state / blend_state presets with the d3dx names and values; graphics_pipeline_desc (counterpart of the PSO stream: layout, vs/ps, topology, states, render target + depth formats; no vertex input — vertex pulling; viewport/scissor dynamic) → create_graphics_pipeline(); create_compute_pipeline() (for f). Shader modules live only while a pipeline is created. No pipeline cache yet (milestone d).
  • D3D12 conventions: vkx::set_viewport() uses a negative viewport height (origin top-left, clip-space y up), so the HLSL and the D3D12 projection matrices work unchanged. The D3D12 presets have FrontCounterClockwise = 1, so the Vulkan presets use VK_FRONT_FACE_COUNTER_CLOCKWISE (the negative height makes the framebuffer winding match). d3dx::blend_state.premultiplied has BlendEnable = 0 (probably an upstream bug); copied as is, with a note.
  • GPass (milestone c part): main buffer R16G16B16A16_SFLOAT + depth D32_SFLOAT, grown to the largest surface (set_size()), add_transitions_for_depth_prepass/gpass/post_process(), depth_prepass() / render() = dynamic rendering that only clears (depth to 0 = reversed Z; main buffer to the per-surface pulsing color as a placeholder for the draws in milestone e). Both buffers start every frame from UNDEFINED (they're fully overwritten), but the barrier waits for the previous frame's readers (fragment/compute, no access mask: write-after-read). The depth buffer stays in depth_read = READ_ONLY_OPTIMAL (changed from DEPTH_READ_ONLY_OPTIMAL) through post-processing: it's valid for a read-only depth attachment and matches the layout in the SRV descriptor.
  • Post-process: root signature like D3D12's (b0 GlobalData, b1 ShaderConstants, t0/t1 for the light-culling visualizations — not bound until f; DXC drops them from the active path —, static point/linear samplers). The two root constants go into the constant buffer (milestone b decision). One pipeline per back buffer format (small cache: the format depends on the window system). Swapchain image: acquired → render_target → fullscreen triangle → present.
  • Frame info: vulkan_frame_info (counterpart of d3d12_frame_info) + get_vulkan_frame_info() writes GlobalShaderData to the constant buffer: view size and delta time are real; matrices are identity and the ambient light is off until the camera (e) and lights (f/g) exist, so post-processing shows the gpass main buffer. render_surface() now follows the D3D12 order: depth prepass → gpass → post-process.
  • Back buffer (decided): prefer FP16 + VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT (scRGB, same as the D3D12 back buffer; VK_EXT_swapchain_colorspace is enabled when the loader has it), else B8G8R8A8_SRGB / R8G8B8A8_SRGB. KDE Wayland offers FP16 scRGB; XWayland gives B8G8R8A8_SRGB. Post-processing writes linear values, so SDR output looks the same either way. The swapchain log line now prints the color space.
  • Test: TestSurfaces.h calls compile_shaders(graphics_platform::vulkan) before graphics::initialize() (only recompiles when sources changed). CMake links ShaderCompiler for the SURFACES test; on Windows the definitions come from TestRenderer.cpp, which EngineTest.vcxproj always compiles.
  • Verified (Linux): Debug / Release / Debug+ASan build clean; -Wall -Wextra -Wshadow-all and clang-tidy clean on the Vulkan files (apart from missing-field-initializers on the { VK_STRUCTURE_TYPE_... } idiom and the PascalCase HLSL structs). SURFACES: Wayland (FP16 scRGB) 145 fps, X11 (BGRA8 sRGB) 76 fps, no validation / sync-validation messages; the four windows show their colors through post-processing (checked on screen). Scripted driver (3 rounds of resize, vsync, surface re-create, full restart; shaders compiled fresh by DXC) exits 0 with no validation, ASan or UBSan reports in Debug+ASan and Release.
  • Found, not fixed (pre-existing, Phase 5 code): compile_shaders() throws an uncaught std::filesystem_error when the shader source folder (../../Engine/Graphics/Direct3D12/Shaders/) doesn't exist, e.g. when the executable runs from another directory → std::terminate. Should use the error_code overloads and return false.
  • Not verified: Windows build/run (deferred to the end of Phase 6); HDR output with HDR enabled in the compositor.

Phase 6d – done (2026-11-08)

New: VulkanUpload.h/.cpp, VulkanContent.h/.cpp (same structure as the D3D12 modules). Wired into core::initialize() / shutdown() and the platform_interface resources entries (meshes, textures, materials, render items). Added to CMake and Engine.vcxproj (+ filters).

  • Upload: upload::vulkan_upload_context like d3d12_upload_context (4 upload frames, each with a command pool + command buffer; a timeline semaphore as the fence; a VMA host-visible staging buffer per upload, destroyed right after the wait). D3D12 uses a copy queue; here uploads go to the graphics queue (no queue family ownership transfers), through core::submit_to_graphics_queue(). The queue is now behind a mutex (render submits, presents, vkQueueWaitIdle and uploads), because content loads on several threads. end_upload() records a memory barrier (transfer writes → all later commands on the queue), submits and waits, like D3D12.
  • Resources: GPU-only vulkan_buffers with initial data are filled through an upload context (the milestone b TODO); TRANSFER_DST is added automatically. descriptor_heap::write_*() now lock the heap mutex (host updates of one descriptor set must be externally synchronized; textures are created on several threads).
  • Content (port of D3D12Content.cpp):
    • Meshes: one vulkan_buffer per mesh (storage + index usage), submesh views = vkx::buffer_ranges for positions / elements (root SRVs t0/t1) + submesh::index_buffer_view {buffer, offset, size, VkIndexType}. Corrected in 6e: the asset packs the parts at 4-byte offsets (D3D12_STANDARD_MAXIMUM_ELEMENT_ALIGNMENT_BYTE_MULTIPLE is 4, not 16 as first assumed), so 6d's offsets were wrong after the first part and the "≤ 16" device requirement didn't help; 6e repacks instead.
    • Textures: vkx::dxgi_format_info() (DXGI → VkFormat table + block size; the test assets use R32G32B32A32_FLOAT, R16G16_FLOAT, BC4, BC5, BC7_SRGB). One VkBufferImageCopy per subresource, the blob's row/slice pitch become bufferRowLength/bufferImageHeight, offsets aligned to lcm(block size, 4). Cube maps get CUBE_COMPATIBLE (the default SRV view is then a cube). Image goes UNDEFINED → TRANSFER_DST → READ_ONLY_OPTIMAL inside the upload.
    • Materials: same stream layout as D3D12. Root signature per (material type, shader flags) with the D3D12 opaque root parameters (b0, b1, t0–t6, s0–s2) and stage visibility translated from D3D12's. No command signatures (indirect drawing is milestone e's decision).
    • Render items: gpass pipeline (main buffer + depth, backface_cull, reversed_readonly) and depth-prepass pipeline (position-only vertex shader, reversed, no color attachment — dynamic rendering needs the pipeline's formats to match the pass). Pipelines are cached by a CRC of the zeroed graphics_pipeline_desc (D3D12: CRC of the PSO stream). No VkPipelineCache on disk yet (the driver's shader cache covers repeated runs).
    • _mm_popcnt_u32 / _BitScanForward → std::popcount / std::countr_zero; alloca → utl::vector.
  • SPIR-V entry points: ShaderCompilation.cpp now passes -fspv-entrypoint-name=main: compiled content shaders don't store the HLSL function name, and Vulkan pipelines need it. vkx::spirv_entry_point; the engine-shader name table is gone. Delete x64/<config>/shaders/vulkan/shaders.bin once (also on Windows): compile_shaders() only checks source timestamps, so an old file with the HLSL names would be kept and pipeline creation would fail.
  • Bugs found and fixed:
    • utl::free_list::already_removed() (debug builds, both backends) read p[sizeof(T)] before checking the bound — one byte past the item, past the array for the last one. ASan caught it when all submeshes were removed and re-added.
    • shaders.bin packs records back to back, so a record's u64 size is misaligned whenever an earlier byte code size isn't a multiple of 8 (UBSan). The Vulkan loader now copies the records to 8-byte aligned offsets. D3D12Shaders.cpp has the same latent bug (reads the file in place; harmless on x86, not fixed).
    • Brace-init narrowing (sizeof is 64-bit) in the code taken from D3D12Content.cpp — clang rejects it; casts added.
  • Verified (Linux): a scripted driver loads the renderer test content like RenderItem.cpp (8 textures + 5 models on 13 threads, TestShader compiled to SPIR-V in 5 variants, 14 materials, 16 render items → gpass + depth pipelines), renders frames, removes everything and restarts the renderer, twice: exit 0, no validation / sync-validation messages, no ASan/UBSan reports (Debug+ASan), Release exit 0; LSan without the shim only shows the known 256 bytes per VkInstance. SURFACES unchanged (145 fps). -Wshadow-all and clang-tidy clean on the new files.
  • Not verified: that texture/mesh data arrives correctly on the GPU (visible once milestone e draws); Windows.
  • For Phase 7: RenderItem.cpp loads ../../x64/ibl/... but the folder is IBL — fails on case-sensitive Linux.

Phase 6e – done (2026-11-08)

New: VulkanCamera.h/.cpp (port of D3D12Camera, API-independent: DirectXMath only; _countof → std::size). pi.camera entries wired. Added to CMake and Engine.vcxproj (+ filters).

  • Frame info: vulkan_frame_info::camera; get_vulkan_frame_info() fills GlobalShaderData from the camera like D3D12 (view, projection, inverses, position, direction). Without a camera (SURFACES test) the matrices stay identity and nothing is drawn.
  • Indirect drawing — decided: direct draws. D3D12 has two gpass paths: direct (depth_prepass() / render()) and ExecuteIndirect (*_indirect(), DRAW_INDIRECT 1), whose command signature changes root CBVs/SRVs per draw. Vulkan can't change push descriptors inside vkCmdDrawIndexedIndirect (only VK_EXT_device_generated_commands can), so the Vulkan gpass ports the direct path: per render item, vkx::root_descriptors pushes b1/t0/t1/t2 (b0 and t3–t6 once per root signature), binds the pipeline when it changes, vkCmdBindIndexBuffer + vkCmdDrawIndexed. The indirect path is only worth it if profiling says so (Open items D).
  • GPass: prepare_render_frame() / fill_per_object_data() ported (render items → items/views/materials caches, per-object data and material data in the frame's constant buffer); the frame cache uses separate utl::vectors instead of D3D12's one packed buffer. Depth prepass: depth-only pipelines, clear to 0 (reversed Z). Main pass: clear to D3D12's clear_value (0.5 gray in Debug, black in Release), depth test read-only against the prepass. The milestone c per-surface pulsing placeholder color is gone (SURFACES now shows the clear color).
  • Placeholders until f: a zeroed 256 KB storage buffer is bound to t3–t6 (lights, light grid, index list — big enough for a 4K light grid) with NumDirectionalLights = 0 and the ambient light off, so the shaders find no lights. It's also bound to t1 for position-only meshes (no element buffer; a null buffer would need nullDescriptor).
  • Storage buffer offset alignment (fixes 6d): validation showed every index range ending a few bytes past its mesh buffer: D3D12_STANDARD_MAXIMUM_ELEMENT_ALIGNMENT_BYTE_MULTIPLE is 4, so the asset packs positions / elements / indices at 4-byte offsets — fine for D3D12 root SRVs, but Vulkan storage buffer ranges need minStorageBufferOffsetAlignment (16 on NVIDIA). Now submesh::add repacks while uploading: the asset goes into the staging buffer as is, one VkBufferCopy per part to offsets aligned to core::storage_buffer_offset_alignment() (= max(16, the device limit)), and asserts that the 4-byte-aligned part sizes add up to mesh_data_size (they do for all test models). The 6d device requirement (≤ 16) is removed. Per-item material data (t2) in the constant buffer uses the same alignment (D3D12 packs it at 4 bytes).
  • Core: upload::initialize() now runs first (gpass uploads its placeholder buffer while initializing) and upload::shutdown() last.
  • Verified (Linux): a scripted driver builds the renderer test scene without lights/scripts (4 windows with the test's camera; lab, fan, interior, fembot and 12 spheres as game entities with geometry components; frame_info like TestRenderer.cpp), renders 2 × 150 frames with a resize and a full restart: exit 0, no validation / sync-validation messages, no ASan/UBSan reports (Debug+ASan), Debug exit 0. ~105 fps for 4 windows with ASan and validation. -Wshadow-all and clang-tidy clean (the camera's findings are the D3D12 original's, kept as is).
  • Not verified: the picture (see Open items C) — no lights yet, so the driver gives the untextured materials a flat emissive color to show their shapes; the fembot uses its emissive texture. Windows.

Phase 6f – done (2026-11-08)

New: VulkanLight.h/.cpp (port of D3D12Light: light sets, parameters and dirty tracking are API-independent and copied as is; only vulkan_light_buffer differs: persistently mapped vulkan_buffers instead of Map(), and vkx::buffer_ranges instead of GPU addresses) and VulkanLightCulling.h/.cpp (delight, port of D3D12LightCulling). pi.light entries wired. Added to CMake and Engine.vcxproj (+ filters).

  • Light culling: one root signature for both compute pipelines (b0, b1, u0, t0–t2, u1, u3; vkx::root_parameter::uav), grid frustums dispatched when the view size or FOV changes, light culling every frame with lights (once more to clear when they're gone, like D3D12). Per-frame culler buffers as in D3D12. The light index list shares a buffer with the light grid; its offset is aligned to core::storage_buffer_offset_alignment() (D3D12: 16 bytes), and the ranges are sized to the current view (root views have no size, Vulkan ranges do). The culling shader reads the depth buffer through the resource heap (bound for the compute bind point).
  • Barriers (D3D12 state transitions → sync2 buffer barriers): frustums shader read → compute write → compute+fragment read; light grid/index list fragment read → compute write → fragment read; index counter compute → transfer (vkCmdFillBuffer clear) → compute — the transfer step has no D3D12 counterpart (ClearUnorderedAccessViewUint). cull_lights() applies the barriers collected so far, including the gpass transitions (depth → depth_read, which the culling pass samples), and leaves the grid → fragment-read barrier for the caller, exactly like D3D12.
  • Surfaces own a light culler (vulkan_surface::light_culling_id(), added in create(), removed in release()).
  • Frame: GlobalShaderData gets NumDirectionalLights and the ambient light from the light set; render_surface() calls light::update_light_buffers() + delight::cull_lights() between the gpass transitions and the main pass (D3D12 order). Only for frames with a camera: D3D12 does this unconditionally and requires a light set; the SURFACES test has neither, so without a camera there are no lights and no culling.
  • Core zero buffer: the gpass placeholder from 6e moved to core (core::zero_buffer(), 256 KB of zeros): bound where D3D12 binds address 0 — light buffers before a set has lights of that kind, culler buffers before a surface's first culling, element buffers of position-only meshes.
  • Gpass / post-process: t3–t6 = real light buffers + light grid/index list; post-process binds t0/t1 (frustums, light grid) like D3D12 (used only by its debug visualizations).
  • EngineTest/Lights.cpp fix (Linux): its random(f32 min = 0.f) helper clashed with POSIX long random(void) from <stdlib.h> ("call to 'random' is ambiguous"). Renamed to random_float().
  • Brace-init narrowing (sizeof, 1UL <<) in the copied light buffer code, as in 6d — casts added.
  • Verified (Linux): the compiled CullLights/GridFrustums SPIR-V bindings match the root signature (no hidden counter buffers). A scripted driver (the 6e scene + EngineTest/Lights.cpp unchanged: 2 light sets with 3 directional lights each and RANDOM_LIGHTS ≈ 16,000 point/spot lights; windows alternate between the sets; test_lights() disables and removes lights every frame) renders 2 × 150 frames with a resize and a full restart: exit 0, no validation / sync-validation messages, no ASan/UBSan reports (Debug+ASan); Release 129 fps for 4 windows.
  • Not verified: the picture (Open items C); Windows.

Phase 6g – done (2026-11-08)

The ambient light already worked end to end after 6f: the light module port carries the ambient light's texture indices (content::texture::get_descriptor_indices()), GlobalShaderData.AmbientLight is filled from the light set, the gpass pixel shader samples the IBL cube maps / BRDF LUT through the resource heap, and post-processing draws the specular cube map where the depth is 0 (sky). The platform_interface tables of both backends now match exactly (MSAA / ray tracing options are stored but unused in D3D12 too). Milestone g is the Vulkan-specific guarantees and verification:

  • BC textures: textureCompressionBC is now a required device feature. D3D12 always has BC formats; in Vulkan it's a feature (RADV reports the formats either way, so validation was quiet, but a driver may not). All PBR test textures are BC4/BC5/BC7.
  • Texture format checks: texture creation checks the format's optimal-tiling features — fails clearly without sampled + transfer-dst, and warns without linear filtering. D3D12 (FL 11+) guarantees filtering of R32G32B32A32_FLOAT, which the IBL cube maps use with a linear sampler; in Vulkan it's optional (RADV has it).
  • GPU-assisted validation (new in the verification routine, see Verification): bindless reads (descriptor type, initialized slot, index range) are invisible to the normal layer. With GPU-AV the whole scene — PBR textures, IBL cube maps, BRDF LUT, depth sampled by light culling and post-processing — is clean.
  • Shader fix (both backends): data race in CullLights.hlsl. GPU-AV reported a race on the groupshared _lightFlagsOpaque: every thread of a tile that sees light i stored the same flag to _lightFlagsOpaque[i]. The value is the same, so it worked, but concurrent plain stores are a data race (undefined in HLSL/SPIR-V). Now InterlockedOr() (slots start at 0, so the result is identical). D3D12's shaders.bin recompiles from the changed source on its own.
  • Stale "TODO: light + delight" removed from core::initialize().
  • Verified (Linux): a scripted driver (6f scene + RenderItem.cpp's IBL ambient light — BRDF LUT, Set4 diffuse and specular cube maps — in both light sets) renders 2 × 150 frames with a resize and a full restart: exit 0, no validation / sync-validation messages, and no GPU-AV messages after the shader fix; no ASan/UBSan reports; Release 129 fps for 4 windows. SURFACES clean under GPU-AV.
  • Not verified: the picture (Open items C); parity with D3D12 in RenderDoc (Windows, Open items A7).

Phase 6 is complete on Linux. Remaining for Phase 6: the Windows build and run of b–g (Open items A).

Windows session 2026-11-08 (b–g on Windows; Open items A1–6, A9)

AMD RX 6800 XT, driver Vulkan 1.4.315, SDK 1.3.290 layers, Windows HDR off.

  • A1: no shaders/vulkan/ existed on Windows → nothing to delete.
  • A2 build: Primal.slnx /t:Rebuild Debug, Release, DebugEditor, ReleaseEditor → 0 C++ warnings, 0 errors (only the pre-existing C# CS0649 ×2 in PrimalEditor/Content/Material.cs). No MSVC fixes were needed for b–g. /p:PrimalVulkan=false (Engine + EngineTest, separate OutDir/IntDir): clean, 0 Vulkan*.obj, the exe has no vulkan-1.dll reference.
  • A3 driver: VK_KHR_push_descriptor, VK_EXT_mutable_descriptor_type, VK_EXT_swapchain_colorspace all present. Surface formats with HDR off: R8G8B8A8/B8G8R8A8 UNORM + SRGB, A2B10G10R10 — all SRGB_NONLINEAR, no FP16 scRGB → swapchain format 50, color space 0 (8-bit sRGB fallback, by design). With HDR on: FP16 scRGB (A11, done).
  • A4 SURFACES on Vulkan: links; by hand (user): clear color, Esc, Space (IMMEDIATE ↔ FIFO), F11, Alt+Enter, drag-resize, close all → exit 0. Bug found + fixed (both OSes): vkCreateDebugUtilsMessengerEXT(): pCreateInfo->pNext must be NULL — messenger_info is reused from the vkCreateInstance chain where its pNext points at settings_info; VulkanCore.cpp now clears pNext before creating the messenger. After the fix: zero validation messages (incl. F11 restart).
  • A5 + A9 renderer test on Vulkan: Phase 7 step 1 done here (PRIMAL_GRAPHICS). Bug found + fixed: RenderItem.cpp compiled the TestShader variants for the OS default (DXIL on Windows) → VUID-VkShaderModuleCreateInfo-pCode-07912 and a debug break in vkCreateGraphicsPipelines; it now passes the selected platform. After the fix: PRIMAL_GRAPHICS=vulkan → validation + sync validation clean, F11 restart and resize OK, exit 0, picture matches D3D12 (user).
  • A6 D3D12 regression: TEST_RENDERER picture correct (meshes, lights, IBL, sky), F11 OK; TEST_WINDOW Alt+Enter + drag-resize OK; TEST_ENTITY_COMPONENTS 21 rounds (~2M entities), no asserts. All exit 0.
  • How-to: building EngineTest\EngineTest.vcxproj alone needs /p:SolutionDir=<repo>\ (the Vulkan.props import uses $(SolutionDir)); its AdditionalLibraryDirectories is $(OutDir), so a custom OutDir needs Engine built there first. Test variants: CL/LINK env vars + /p:IntDir=x64\Debug\TestWindow\ /p:TargetName=EngineTest_Window /p:BuildProjectReferences=false; MSBuild exits 1 from /FORCE:UNRESOLVED but the exe is written. Tests are GUI-subsystem: run with Start-Process -Wait -NoNewWindow -RedirectStandardError <file> to get the Vulkan log; TEST_ENTITY_COMPONENTS reads getchar() → -RedirectStandardInput <file of newlines + q>.

Windows session 2026-11-09 (Open items A12: MSVC check of the Linux-only work)

AMD RX 6800 XT, MSVC 14.50 (VS 18 BuildTools, v145), Vulkan SDK 1.3.290, Windows HDR off. Branch primal_plus_plus at ea76147 (T08/T09/B-list, 7837688, 53f3c85, 4d31ec3).

  • Restore: no nuget.exe on the machine; msbuild Primal.slnx /t:Restore /p:RestorePackagesConfig=true restores the packages.config projects (DXC, D3D12).
  • A12.1 build: Debug + Release clean first time. DebugEditor + ReleaseEditor failed in the one file Linux never parsed: FbxImporter.cpp C2662. The clang-tidy pass made the local FbxContext fbx_context const, but get_scene() is non-const, so the const is removed. After that all 4 configs /t:Rebuild: 0 C++ warnings, 0 errors (only C# CS0649 ×2 in Material.cs). No MSVC trouble with EDITOR_INTERFACE auto f() -> T, PRIMAL_NOINLINE, the structured bindings or std::scoped_lock.
  • A12.2 test variants: the B5 fix was broken (fixed now). MSBuild escapes ; in a property function's result, so $(PrimalTestDefines.Replace(...)) reached cl as one /D "TEST_ENTITY_COMPONENTS=0;TEST_WINDOW=0;..." (C4067 in Main.cpp). The other three macros fell back to Test.h's defaults, so every variant silently built the renderer test. Now four plain conditional properties (PrimalTestEntityComponents etc.) give four separate /Ds. All 4 variants build + link in Debug and Release with the right defines; BOGUS → "PrimalEngineTest must be ENTITY_COMPONENTS, WINDOW, RENDERER or SURFACES (got 'BOGUS')". Also: EngineTest was the only project at /W3, now Level4 (all 8 config × variant builds clean). WINDOW gave LNK4199 /DELAYLOAD:vulkan-1.dll ignored (no graphics in that test), so Engine\Vulkan.props adds /IGNORE:4199 to the link.
  • A12.3 shaders (T09): a syntax error in PostProcess.hlsl fails the build: PostProcess.hlsl(131,1): error …: expected unqualified-id → PrimalShaderCompiler : error : failed to compile the engine shaders for d3d12 → MSB3073. Undo → recompiles; a no-change build leaves shaders.bin/.key untouched. (Editing a non-engine .hlsl such as FillColor.hlsl also triggers a recompile, because the timestamp check looks at the whole folder. Harmless.)
  • A12.4 runs (Debug): D3D12 renderer test: picture right (user), F11 restart OK, debug layer silent, ~146 fps vsync, exit 0. Vulkan (PRIMAL_GRAPHICS=vulkan): validation + sync validation 0 messages, 13 swapchains (startup, F11, fullscreen 2752×1152 = T15 DPI, resizes), picture matches D3D12 (user), exit 0. ENTITY_COMPONENTS 50 rounds (~9.6M entities), no asserts, exit 0. WINDOW fullscreen/windowed/resize, exit 0. Not reproduced: the very first D3D12 run exited 0x80000003 (STATUS_BREAKPOINT: a debug break, or Retry in the CRT assert dialog with no debugger attached). The next two runs (one under a debugger capturing OutputDebugString, one plain) were clean. Cause unknown; see B10.
  • A12.5 editor (partial): PRIMAL_ENGINE (user env var) switched to C:\USERS\SMITT\RIDERPROJECTS\PRIMAL_PLUS\ for good (user's choice; it was the old Primal repo). DebugEditor: new project created + loaded, engine view renders (user). FBX import, texture import and primitive mesh work (user; first run of the edited FbxImporter.cpp).
  • A12.5 script template (no VS, BuildTools only): a copy of the new project with a script generated exactly like NewScriptDialog (TestScript), built with MSBuild. The game project templates were stale: PlatformToolset v143 (VS 2022 → MSB8020 here; the engine libs are v145) and LanguageStandard stdcpp17 (engine API headers are C++23). All 4 templates (PrimalEditor/Resources/ProjectTemplates/*/MSVCProject) now use v145 + stdcpp23 (/std:c++23preview, user's choice: C++23, not latest). The script template's update(float dt) gave C4100 at /W4 → [[maybe_unused]] float dt. After that DebugEditor/ReleaseEditor (DLL) and Debug/Release (exe, links engine.lib) build with 0 warnings. Game projects created before this keep v143 + C++17 and won't build until retargeted by hand (B11). Loading the script DLL in the editor still needs VS (the editor builds through it).
  • C++23 instead of latest (user's choice): every .vcxproj LanguageStandard stdcpplatest → stdcpp23 (/std:c++23preview). All 4 configs /t:Rebuild: 0 C++ warnings, 0 errors (C# CS0649 ×2 only).
  • A12.6 / T02 /WX: TreatWarningAsError in all 5 C++ projects (opt out: /p:PrimalWarningsAsErrors=false). All 4 configs + 8 EngineTest variant builds clean; a probe warning fails the build. Details in T02 "Done, part 3".
  • How-to: no debugger is installed on this machine (no cdb/WinDbg). A tiny Win32-debug-API runner (prints OutputDebugString + a dbghelp stack on breaks) was used from the session scratchpad; worth keeping in Tools/ if this comes up again. Test variants no longer need CL/LINK env vars: msbuild EngineTest\EngineTest.vcxproj /p:SolutionDir=<repo>\ /p:PrimalEngineTest=WINDOW /p:IntDir=x64\Debug\WINDOW\ /p:TargetName=EngineTest_WINDOW.

Windows session 2026-11-11 (Open items A13, A14, A16, A17.1)

Same machine and toolchain as 2026-11-09. Branch automated_testing at e3b428b.

  • Build (A13.1, A14.1, A16.1, A17.1): Primal.slnx /t:Rebuild failed once, in Debug: ContentToEngine.cpp C3615, constexpr auto gpu_id_from_fake_pointer() "cannot result in a constant expression". The cast pass turned its C-style casts into reinterpret_cast, which MSVC rejects in a constexpr function (clang and GCC only complain when it is evaluated at compile time). constexpr removed; both callers are runtime. After that Debug, Release, DebugEditor, ReleaseEditor: 0 C++ warnings, 0 errors at /W4 /WX (C# CS0649 ×2 only). The 4 EngineTest variants rebuild clean in Debug and Release. Nothing from the include reordering (T20), the hand-edited FbxImporter.cpp/.h, EngineAPI.cpp, D3D12Upload.cpp, PlatformWin32.cpp or Vector.h.
  • A14.2: Common\CommonDefinitions.h is in Engine.vcxproj and .filters.
  • A16.1 UnitTests.vcxproj: builds in Debug and Release first time. DownloadDoctest put doctest.h (362 930 bytes) in packages\doctest.2.5.3\; doctest doesn't trip /W4 /WX; engine.lib links into the console program.
  • A16.2 run: x64\Debug\UnitTests.exe and x64\Release\UnitTests.exe: 83 of 83 test cases pass, exit 0 (incl. content::load_game and content::get_engine_shaders).
  • A13.2 / A17.1 runs (Debug): Vulkan renderer test (PRIMAL_GRAPHICS=vulkan): validation + sync validation on, no validation message and no "validation error(s) were reported" line, 7 swapchains (startup, a resize, fullscreen 2752×1152 and back), exit 0. D3D12 renderer test: exit 0. Picture right on both backends (user).
  • A13.2 editor (DebugEditor, user): new project created and loaded, engine view renders; FBX import, texture import and primitive mesh work; a mesh with a material and the imported texture renders textured; after closing and reopening the editor the project comes back the same. All OK, no asserts. This is the first run of FbxImporter.cpp's casts, patch_material_data() and the std::memcpy versions of utl::free_list and BlobStreamReader/Writer in the editor.
  • A14.3 script project (MSBuild, no Visual Studio): a copy of the game project the editor created today, plus a TestScript generated from the NewScriptDialog template, builds in DebugEditor, ReleaseEditor (DLL), Debug and Release (exe): 0 compiler warnings at /W4. The project force-includes GameEntity.h (now through CommonHeaders.h), so the T20 header changes are seen by MSVC on the script path too.
  • Issues closed 2026-11-11: #2 (T02), #20 (T20) and #21 (T21; CI was green on e3b428b, all seven jobs, so the image 2026-11-09-b is published).
  • Not done: A16.4 (a scene naming a script the game DLL doesn't have; no such project was tried) and the editor building and loading a script DLL itself, which needs Visual Studio (A12.5).
  • Not re-run on Linux: clang-tidy on ContentToEngine.cpp after the constexpr removal.

Windows session 2026-11-12 (Open items A18–A24)

Same machine and toolchain (VS 18 BuildTools, MSVC 14.50.35717). Branch job_system at 4aa2e1c.

  • Build, first try (Debug): three failures, all in the engine:
    1. C4459 MathSimd.h:212 (near_equal4()'s epsilon parameter hides math::epsilon), as A18.7 predicted. Parameter renamed tolerance.
    2. C3615 ContentToEngine.cpp again: the 2026-11-11 removal of constexpr from gpu_id_from_fake_pointer() was never committed and got lost. Removed again.
    3. C4530 in Log.cpp ("C++ exception handler used, but unwind semantics are not enabled"): Engine.vcxproj builds the engine without exceptions (Arash's setting; CMake leaves them on), and both MSVC's <chrono> (a try in the time zone database, get_tzdb_list(), in every TU that includes <chrono>) and format_text()'s own try/catch need them. Fix: <chrono> is included with C4530 off (#pragma warning, _MSC_VER only), and the try is compiled only when exceptions are on (PRIMAL_LOG_HAS_EXCEPTIONS, from __cpp_exceptions / _CPPUNWIND). Without exceptions, a format error at run time (only a bad runtime width/precision can still cause one, the string itself is checked at compile time) ends the program. _HAS_EXCEPTIONS=0 for the engine was not chosen: it would change the standard library's classes between engine.lib and its users.
  • Build, second try: the engine and both modules (primal.jobs, primal.frame) build; every file that imports one fails with C5050 ("possible incompatible environment while importing module": _CPPRTTI, _CPPUNWIND, _GUARDOVERFLOW_CRT_ALLOCATORS are defined in the importer, not in the engine), an error under /WX. The engine is built with /GR- /EHs- and without /sdl, its users with them. That mismatch is not new (every engine header is already compiled both ways), so Engine\Modules.props turns C5050 off in every project but the engine. Modules.props works otherwise as written: UnitTests, EngineTest (also alone, with /p:SolutionDir) and EngineDLL get the .ifc files through the ProjectReference.
  • After the fixes: Debug, Release, DebugEditor, ReleaseEditor: 0 C++ warnings, 0 errors (C# CS0649 ×2 only; the editor's DrainLog C# compiles). The 4 EngineTest variants build in Debug and Release. Threading.h is gone from the projects without trouble (A23.4), MathSimd.h is listed (A18.2). The vec operators (A18.1) and XM_CALLCONV needed nothing.
  • UnitTests: 125 test cases pass (1 skipped benchmark), Debug and Release, run 6 times each.
  • Shader build (A19.3): a syntax error in PostProcess.hlsl fails the build with PostProcess.hlsl(131,1): error …: expected unqualified-id in plain text. (Breaking FillColor.hlsl does nothing: no engine shader uses it.)
  • Renderer tests (A18.4, A19.4, A21.1, A21.4, A23.2): D3D12 Debug and Release, Vulkan Debug (validation + sync validation): exit 0, no warning or error line, picture right (user), F11 / resize OK. Log lines in the new format in stderr and EngineTest.log, the previous run kept as EngineTest.1.log. Test content loads in 162 ms with 23 workers and ~350 ms with PRIMAL_JOBS=0 (Release D3D12); frame time is vsync-bound (6.9 ms) either way.
  • Editor (DebugEditor, user, A18.5, A19.5, A21.2, A22.2–3, A23.3 not tried with Vulkan): a project opened, entities moved, added and removed while rendering, FBX import, an HDR environment map, engine messages in the log panel, closing the editor: all fine, no assert, exit 0, no hang.
  • Script template (A24.2): a copy of a v145 game project plus a script made from the new template (begin_play/update/end_play) builds in DebugEditor, ReleaseEditor, Debug and Release with 0 warnings.
  • Not done: a built game running a script (A21.3, A22.4, A24.3) needs the editor to build the game, which needs Visual Studio (A12.5); the engine side is covered by UnitTests/FrameTests.cpp. The old test game projects (A24.1) were not rebuilt: they are leftovers, and the ones with scripts use the old API (B11). The D3D12 debug layer output and the CRT leak check at exit (A19.4) only go to a debugger, which this machine doesn't have (the debug layer part is solved below).

Later the same session: game code without Visual Studio, and the rest of #19.

  • Editor builds game code with MSBuild (A12.5). PrimalEditor/GameDev/VisualStudio.CommandLine.cs (new; the VisualStudio class is partial now): when Visual Studio's automation server (VisualStudio.DTE.18.0) isn't registered, or PRIMAL_EDITOR_BUILD=msbuild, the editor
    • adds new scripts by editing the game project's .vcxproj (and .filters if there is one) and opens the .cpp in VS Code (code.cmd on the PATH; otherwise the program Windows associates with .cpp);
    • builds the .sln with MSBuild (found with vswhere, works with the BuildTools), with the output in the log panel (errors and warnings typed) and PRIMAL_ENGINE passed explicitly;
    • runs the built game as a process (no debugger; "Debug" warns about that), shows its stderr in the log panel as [game] ..., and stops it by closing its window (end_play() runs), killing it only after 5 s. PRIMAL_EDITOR_BUILD=vs forces Visual Studio. Checked by the user: new script → .vcxproj, build, DLL loaded, script on an entity, game run. A built game running a script works now (A21.3, A22.4, A24.3).
  • Running a built game needed the engine shaders (since T09, with Visual Studio too): Project.RunGame() now copies <engine>\x64\<config>\shaders\ next to the game executable (CopyEngineShaders()).
  • Editor crash on a game code reload (fixed 2026-11-13, Arash's code): Project.RemoveScriptComponents() queued its work with Dispatcher.BeginInvoke and always returned an empty list, so the game DLL was freed before the scripts were destroyed (access violation in their destructors, 0xC0000005), and the scripts were never put back after a reload. Now synchronous (Dispatcher.Invoke), returning the list.
  • Running a game whose scene has a mesh crashed the editor: Geometry.WriteToBinary() was never written (nor is the engine's read_geometry()). Stopgap: SaveToBinary() leaves geometry out and logs a warning; the real work is issue #33 (a built game also has no way to get its assets).
  • Checked 2026-11-13 (NewProjectTest, a script TestScr with log lines): in the editor, the script's constructor log reaches the log panel through the forwarding (also confirmed by a harness that loads EngineDLL and reads DrainLog); a DLL reload with a script on an entity no longer crashes; the built game (Ctrl+F5) logs begin_play once, log_debug every 120 frames, and after Shift+F5 end_play after 663 frames (TestScr.cpp:21) in its primal.log.
  • D3D12 parallel recording and draw path (2026-11-13, the D3D12 half of #1 step 7):
    • Stress option for the renderer test: PRIMAL_TEST_EXTRA_SPHERES=<n> adds n spheres in a grid above the scene, PRIMAL_TEST_VSYNC=0 starts without vsync (EngineTest/RenderItem.cpp, TestRenderer.cpp, test_env_u32() in Test.h).

    • Found with it: (1) D3D12's ExecuteIndirect path, the default until now, is 2.5-4x slower on the GPU than direct draws on the RX 6800 XT; (2) both backends crashed above ~4,000 objects: the per-frame constant buffer was a fixed 1 MB, and allocate() returning nullptr wasn't handled.

    • Constant buffer (both backends): gpass collect_render_items() gathers the frame's items before anything is allocated and returns the bytes the gpass needs; core calls ConstantBuffer::reserve() (256 KB for the rest of the frame plus that), which recreates the buffer at the next power of two when needed (old one through deferred release). allocate() is lock-free (atomic offset, compare-and-swap) and gpu_address()/range() take no lock.

    • D3D12 draws: direct by default (user's choice), PRIMAL_D3D12_DRAW_INDIRECT=1 for ExecuteIndirect (replaces the DRAW_INDIRECT define). Logged at start-up ("Draws: ...").

    • D3D12 parallel recording (PRIMAL_D3D12_PARALLEL_RECORDING=0 turns it off): above 512 items, jobs record batches into command lists of their own (an allocator per thread and frame, ThreadCommandLists in D3D12Core.cpp); D3D12Command::queue_and_continue() closes the frame's list, queues it and the batches, and continues in another list from a small pool. Every list starts with heap, viewport and scissor (set_frame_state()); batches set their render targets without clearing.

    • Measured (Release, vsync off, 4 windows, frame time in ms; parallel/serial per backend):

      Extra spheres D3D12 direct par./ser. D3D12 indirect Vulkan par./ser.
      0 2.26 / 2.26 2.28 2.32 / 2.30
      1,000 4.46 / 4.40 10.91 4.27 / 4.27
      6,400 14.87 / 14.81 61.33 15.08 / 14.87

      At 6,400, D3D12 recording per window fell from 477 + 418 us (depth + gpass, serial) to 225 + 108 us, but the scene is GPU-bound, so the frame time doesn't change (Vulkan the same).

    • Checked: all 4 configurations + 8 variants clean, UnitTests 128/128 Debug and Release, Debug runs of every path (D3D12 direct at 6,400, indirect at 1,000, Vulkan at 6,400 with validation): no debug layer or validation message, exit 0. Editor (D3D12, direct): 4 viewports at 144 Hz, clean exit. Picture right with direct draws and 1,000 extra spheres (user).

  • A23.3 (editor on Vulkan), 2026-11-13: fails, issue #35. Material shaders are compiled once for the platform default (DXIL on Windows) and stored in the assets; on Vulkan vkCreateShaderModule() gets DXIL, validation reports VUID-VkShaderModuleCreateInfo-pCode-07912, pipeline creation fails and VkCall breaks (no debugger: the editor exits). The editor on Windows stays D3D12-only until #35.
  • A16.4 (missing script), 2026-11-13: passes. NewProjectTest with its script renamed to MissingScript in the project file (restored afterwards): the editor logs "Unable to find script with name MissingScript. Game entity will be created without script component!", no crash, exit 0. Driven with EditorUi.psm1.
  • Old test game projects (AwesomeProject, Test, NewProject5, ... with old-API scripts): left as they are (user, 2026-11-13).
  • Tools/EditorAutomation/EditorUi.psm1 (new): drives the editor through Windows UI Automation from Windows PowerShell 5.1 (open a project by name, click by name or automation id, wait for and read log panel lines, close cleanly). No screenshots. Used for the reload check; the main menu items show as disabled to it, the scene menu works.
  • #19, script logging. EntityScript has log_debug/info/warning/error("fmt", args...) (GameEntity.h): Category::script, the text prefixed with the script's class name ("TestScript: ..."), the location of the call. REGISTER_SCRIPT stores the name (detail::set_script_type_name<T>(), an index into a table in Script.cpp, so EntityScript stays 16 bytes: a pointer made math::vec members in scripts padded, MSVC C4324 in EngineTest/Scripts.cpp). GameEntity.h includes Log.h, so log::info(...) works in scripts too.
  • #19, a game DLL's log reaches the editor. The game DLL has its own copy of the engine library and its log. New log::detail::set_forward() / write_forwarded() (Log.h): the DLL exports set_log_forward (Script.cpp, USE_WITH_EDITOR), LoadGameCodeDll() passes it EngineDLL's write_forwarded, and the DLL's copy then formats and hands each message over. File names are copied into the receiving log's State (the DLL can be unloaded while the ring buffer points at them). 3 new unit tests (128 in all).
  • #19, D3D12 debug layer into the log (D3D12Core.cpp, Debug only): ID3D12InfoQueue1::RegisterMessageCallback → log::error (corruption, error), log::warning, log::debug (info, message), category d3d12, text "Debug layer: ... (message )". error() flushes before SetBreakOnSeverity() breaks. Unregistered before ReportLiveDeviceObjects(), whose report stays in the debugger. Found while testing:
    • SetMuteDebugOutput(TRUE) also stops the callback, so the layer keeps writing to the debugger as well (each message twice in a debugger);
    • the layer's default storage filter denies INFO, and the callback only gets what passes the filter, so the self-check line at start-up ("Debug layer: messages go to the log") has severity MESSAGE;
    • a real error (an upload-heap buffer created in COPY_DEST) came through as an error line (message 741).
  • Tooling note: building EngineTest.vcxproj alone (a variant) did not rebuild a changed engine once; build Primal.slnx first. GUI tests can be closed without the user: post WM_CLOSE to each top-level window of the process (a kill loses the log's queued lines).

Windows checkpoint (done 2026-11-06, before milestone b)

Results (MSBuild 18 / VS Build Tools, branch new_primal_plus):

  • Builds: Debug, Release, DebugEditor, ReleaseEditor x64 all build with 0 errors and no new warnings (PrimalEditor CS0649 on NodeMaterial/CodeMaterial._inputs is pre-existing).
  • Fixes (Windows-only, the Linux build can't catch them):
    • Engine/Input/InputWin32.cpp tested #ifdef PRIMAL_PLATFORM_WINDOWS before any include, so the macro (from PlatformDetection.h) wasn't defined and the whole file compiled empty → LNK2019 for process_input_message, map_virtual_key, modifier_keys. Now includes CommonHeaders.h first. (Pre-port it used the compiler's _WIN64.) Rule: any file guarded by a PRIMAL_* macro must include CommonHeaders.h/PlatformDetection.h before the guard.
    • Engine/Utilities/Vector.h reserve(): if constexpr (relocate_with_move) { ...; return; } left the realloc path unreachable → C4702 (MSVC only). Now if constexpr ... else.
    • ContentTools.vcxproj: <Exec Command="CompileShaders"> relied on cmd finding the script in the current directory, which fails (9009) when NoDefaultCurrentDirectoryInExePath is set. Now call "$(ProjectDir)CompileShaders.cmd".
  • Tests (scripted): TEST_ENTITY_COMPONENTS (stdin q after 4 rounds) exits 0. TEST_WINDOW: 4 windows, resize event, quits after the last WM_CLOSE, exit 0. TEST_RENDERER Debug + Release: 4 render windows, 20 s/15 s without asserts, clean close, exit 0. Note: EngineTest.vcxproj always compiles the renderer test files, so the non-renderer tests only link with /FORCE:UNRESOLVED (pre-existing, not a port issue).
  • DXC: NuGet Microsoft.Direct3D.DXC 1.9.2602.24 has SPIR-V codegen (-spirv output passes spirv-val), so Vulkan on Windows step 4 needs no other DXC. LunarG SDK 1.3.290.0 is installed (VULKAN_SDK set; its DXC is 1.8).
  • Assets: the renderer test assets are already in x64/ (git-ignored; from the 7z linked in x64/dropbox.txt). For Linux, copy x64/*.model, x64/*.texture, x64/IBL/ or download the same archive.
  • Still manual: look at the renderer test (meshes, lights, IBL, F11 restart), Alt+Enter / drag-resize in TEST_WINDOW, and capture the D3D12 reference frame in RenderDoc (step 4).

Original checklist:

Phases 2–6a changed Windows-side code that has never been compiled with MSVC: PlatformWin32.cpp, Window.cpp/.h, Renderer.cpp, ContentToEngine.cpp, PlatformDetection.h, EngineTest/Main.cpp / Test.h, the .vcxproj files, and the Phase 5 ShaderCompilation changes. Every later milestone (and Phase 7, which edits TestRenderer.cpp and EngineDLL/EngineAPI.cpp) adds more, so check now while the list of suspects is short. The Vulkan backend stays Linux-only here (PRIMAL_GRAPHICS_VULKAN is 0 on Windows), so this is the D3D12 build only.

  1. Open Primal.slnx, build Debug and Release x64 (Engine, EngineTest, EngineDLL, ContentTools, the game). Fix errors and new warnings; note each fix here (they're Windows-only edits the Linux build can't catch).
  2. Run TEST_ENTITY_COMPONENTS and TEST_WINDOW (Test.h): close / resize / Alt+Enter / quit when all windows are closed.
  3. Run TEST_RENDERER on D3D12 and check it looks the same as before the port (meshes, lights, IBL, F11 restart).
  4. Capture a D3D12 reference frame of the renderer test in RenderDoc (kept for milestones c–g, see Verification).
  5. While on Windows: generate the renderer test assets with ContentTools and copy them for Linux (Phase 4 leftover), and check whether the NuGet Microsoft.Direct3D.DXC has SPIR-V codegen (Vulkan on Windows, step 4).

Vulkan on Windows (steps 1–4, 6–7 done 2026-11-06; 5 and the RenderDoc part of 8 after milestone c)

Done (pulled ahead of milestone b so b–g can be built and validated on both OSes):

  • Engine/Vulkan.props (new), imported by Engine, EngineTest, EngineDLL and the editor's 4 game project templates (PrimalEditor/Resources/ProjectTemplates/*/MSVCProject, via $(PRIMAL_ENGINE), guarded by Exists). It sets PrimalVulkan=true when VULKAN_SDK points at an SDK (opt out: /p:PrimalVulkan=false), and then adds $(VULKAN_SDK)\Include, PRIMAL_GRAPHICS_VULKAN=1, links vulkan-1.lib + delayimp.lib and delay-loads vulkan-1.dll (instead of volk): a D3D12 run never loads it (checked), so machines without a loader still start. create_instance() calls LoadLibraryW(L"vulkan-1.dll") first and fails cleanly if it's missing. Since 2026-11-14 (#18): no linking at all; the engine loads vulkan-1.dll and every function itself (Graphics/Vulkan/VulkanLoader.h), and Vulkan.props only adds the include path and the defines. Must be imported after the project's ItemDefinitionGroups (they set include dirs without %(...)). Existing game projects made before this need the same <Import> line by hand.
  • Engine.vcxproj (+ filters): the 4 Vulkan headers, and the 3 .cpp files with Condition="'$(PrimalVulkan)' == 'true'" (they aren't guarded in code). TestSurfaces.h in EngineTest.vcxproj.
  • VulkanSurface.cpp: native_window_handle::win32 case (vkCreateWin32SurfaceKHR, <vulkan/vulkan_win32.h>).
  • VulkanCommonHeaders.h now includes <Windows.h> (lean, NOMINMAX) first on Windows: Platform/PlatformTypes.h includes it without NOMINMAX, and the min/max macros broke std::min/max in VulkanSurface.cpp.
  • Bug fix (both OSes): VK_EXT_layer_settings is implemented by the validation layer, so it can be missing from the loader's extension list (Windows loader) → sync validation was silently off. Now also queried with vkEnumerateInstanceExtensionProperties(validation_layer_name, ...).
  • Verified: all 4 configurations build clean; /p:PrimalVulkan=false builds an Engine without Vulkan objects; SURFACES (Debug, AMD RX 6800 XT, driver 26.8.1, Vulkan 1.4.315, SDK 1.3.290 layers, sync validation on): 4 swapchains, resize incl. to 0×0 and back, vsync off (IMMEDIATE — no mailbox on this driver) / on (FIFO), F11 restart, close one / all → exit 0, no validation messages. D3D12 renderer test still runs. Not verified by hand: Alt+Enter, drag-resize.
  • Running a non-renderer test on Windows: $env:CL="/DTEST_SURFACES=1 /DTEST_RENDERER=0", $env:LINK="/FORCE:UNRESOLVED" (see the checkpoint note), or set the macros in Test.h.

Original plan:

The backend is written against the Vulkan API, not Linux, so it can sit next to D3D12 in the Windows build: platform_interface already lets one engine contain both and pick one in graphics::initialize(). What's needed:

  1. SDK / build. Install the LunarG Vulkan SDK (headers, vulkan-1.lib, validation layer, and a DXC with SPIR-V support; it sets VULKAN_SDK). Engine.vcxproj (+ filters): add the 7 Graphics/Vulkan/ files, $(VULKAN_SDK)\Include to the include path, link vulkan-1.lib for the executables (EngineTest, the game, EngineDLL), and define PRIMAL_GRAPHICS_VULKAN=1 (PlatformDetection.h defaults it to Linux only). Option: use volk (load the loader at run time) so machines without the loader can still start with D3D12.
  2. Win32 surface. VulkanSurface.cpp create_platform_surface(): add the native_window_handle::win32 case (VkWin32SurfaceCreateInfoKHR { hinstance = (HINSTANCE)native.display, hwnd = (HWND)native.window }, vkCreateWin32SurfaceKHR). PlatformWin32.cpp already fills both fields. Include <vulkan/vulkan_win32.h> after <Windows.h> (WIN32_LEAN_AND_MEAN, NOMINMAX) in that file only. VulkanCore.cpp already enables VK_KHR_win32_surface on Windows.
  3. MSVC portability in the backend — done (2026-11-06, from Linux; not compiled with MSVC yet). VulkanCommonHeaders.h: PRIMAL_VK_DEBUG_BREAK() (__debugbreak on MSVC, __builtin_debugtrap on clang, raise(SIGTRAP) on gcc) and vulkan::log_message(format, ...) (printf-style, format-checked on clang/gcc; defined in VulkanCore.cpp), which writes to stderr and, on Windows, also to OutputDebugStringA because a WinMain process has no console. All backend output goes through it — use it (not fprintf) in new Vulkan code. use_validation() uses _dupenv_s on MSVC (std::getenv raises C4996). VulkanCore.cpp includes <Windows.h> (lean, NOMINMAX) on Windows for OutputDebugStringA.
  4. Shaders. compile_shaders(graphics_platform::vulkan) already writes shaders/vulkan/shaders.bin on any OS, and the NuGet Microsoft.Direct3D.DXC 1.9.2602.24 has SPIR-V codegen (checked 2026-11-06). The SPIR-V hash path doesn't depend on DXC.
  5. Choosing the backend. TestRenderer.cpp and EngineDLL/EngineAPI.cpp hardcode graphics_platform::direct3d12. Make it a choice (command line / env var / editor setting); the shader paths per backend are already in Renderer.cpp.
  6. Window behavior. Nothing to do for the background (set_has_graphics_surface is a no-op; the class brush covers it). Alt+Enter is borderless fullscreen in the platform layer, which works with any swapchain; exclusive fullscreen would need VK_EXT_full_screen_exclusive (optional). Editor child windows (HWND) work with the Win32 surface as-is.
  7. Drivers. The required features (VK_EXT_mutable_descriptor_type, descriptor indexing, 16-bit types, scalar layout, Vulkan 1.3) are supported by current AMD and NVIDIA Windows drivers; check Intel on gpuinfo.org. is_device_suitable() lists anything missing.
  8. Verify. Run the SURFACES test (add TestSurfaces.h to EngineTest.vcxproj, set TEST_SURFACES 1 in Test.h) with the SDK's validation layer, then the renderer test against D3D12 in RenderDoc (same machine, same frame, both backends).

Effort: steps 1, 2 and 5 are small (an afternoon, mostly project-file work, but it has to be done on Windows). Planned right after Phase 6 milestone c, when there's a post-processed frame to compare with D3D12 (the D3D12 build itself is compiled earlier, at the "Windows checkpoint" above).

Phase 7 – EngineTest renderer on Vulkan

Goal: the real renderer test (TEST_RENDERER: TestRenderer.cpp, RenderItem.cpp, Lights.cpp, Scripts.cpp) builds and runs on Linux with the Vulkan backend, and on Windows with either backend, with the same picture as D3D12. Phase 6 already proved every piece with scripted drivers (Docs/VulkanPortDrivers/, see its README); Phase 7 is mostly making the test itself portable.

State at the start (2026-11-08): Phase 6 a–g done on Linux. Lights.cpp already builds on Linux (its random() was renamed in 6f). Windows session (Open items A) is planned before Phase 7 — check this doc's Open items for anything it found. A probe build with -DPRIMAL_ENGINE_TEST=RENDERER stops at (first error per file):

  • EngineTest/TestRenderer.cpp:248 — MessageBox(..., MB_RETRYCANCEL) != IDRETRY (Win32) in the shader-compile retry loop.
  • EngineTest/RenderItem.cpp:10 — #include "../ContentTools/Geometry.h" → ContentTools/ToolsCommon.h includes <wrl.h> (Windows). It's only needed for tools::elements::elements_type (position_only = 0, static_normal = 1, static_normal_texture = 3).

Found by reading (will fail after those): _countof ×8 in RenderItem.cpp; RenderItem.cpp:222-225 loads ../../x64/ibl/brdf_lut.texture and ../../x64/ibl/set4/... but the folders are IBL/ and Set4/ (case-sensitive on Linux; fixing the case works on both OSes); TestRenderer.cpp:14 #includes ShaderCompilation.cpp.

Steps

  1. Backend selection ("Vulkan on Windows" step 5): TestRenderer.cpp:252 and EngineDLL/EngineAPI.cpp:172 hardcode graphics_platform::direct3d12. Default per OS (default_shader_platform in ShaderCompilation.h already does this: D3D12 on Windows, Vulkan on Linux) with an override, e.g. env var PRIMAL_GRAPHICS=vulkan|d3d12 (and/or a command line flag). compile_shaders() must be called for the chosen platform (compile_shaders(platform)). Done 2026-11-08 (on Windows): selected_graphics_platform() in EngineDLL/ShaderCompilation.h/.cpp reads PRIMAL_GRAPHICS (vulkan / d3d12; unknown values → stderr + default; _dupenv_s on MSVC), else default_shader_platform. Used by TestRenderer.cpp and EngineAPI.cpp (compile_shaders(platform) + graphics::initialize(platform)) and by RenderItem.cpp for the TestShader material variants (those were compiled for the OS default → DXIL handed to Vulkan on Windows). On Linux it lives in the ShaderCompiler library with the rest of ShaderCompilation.cpp (step 3). Not yet built on Linux.
  2. Shader-compile retry: keep the MessageBox retry on Windows (#if PRIMAL_PLATFORM_WINDOWS), stderr + fail on Linux.
  3. Shader compiler linkage: on Linux link the ShaderCompiler library for TEST_RENDERER (EngineTest/CMakeLists.txt already links it for SURFACES; extend the condition) and only #include "ShaderCompilation.cpp" on Windows (EngineTest.vcxproj doesn't compile it separately). Keep TestSurfaces.h working on both (Windows gets the definitions from TestRenderer.cpp).
  4. RenderItem.cpp: replace the ContentTools/Geometry.h include (move elements_type somewhere engine-side both can include, or use the values directly like the drivers do); _countof → std::size; fix the IBL/Set4 path case.
  5. Build + run on Linux: -DPRIMAL_ENGINE_TEST=RENDERER. The scene: 4 windows with the scripted camera (camera_script), lab/fan/interior/fembot + 12 spheres, scripts (fan_script, wibbly_wobbly_script, rotator_script in Scripts.cpp, input from SDL — Phase 3), lights (Lights.cpp, set 0 for all windows), IBL light. Expect the same picture as the 6g driver plus moving objects. Check: validation + sync validation, GPU-AV (VK_KHRONOS_VALIDATION_GPUAV_ENABLE=1), ASan/UBSan (build/linux-debug-asan, dlclose shim), Release fps, F11 restart, resize, Alt+Enter, close windows → exit 0, X11 and Wayland.
  6. Windows: same test with PRIMAL_GRAPHICS=vulkan and d3d12; RenderDoc capture of both (same frame) and compare (Open items A7). Done 2026-11-08 (user).
  7. EngineDLL (editor path): EngineAPI.cpp backend selection (step 1). The editor itself stays on Windows/D3D12 until the Avalonia work (issue #13 (T13)).

Phase 7 – Linux (2026-11-08)

  • Step 2: TestRenderer.cpp keeps the MessageBox retry under #if PRIMAL_PLATFORM_WINDOWS; elsewhere stderr + return false.
  • Step 3: EngineTest/CMakeLists.txt links ShaderCompiler for RENDERER as well as SURFACES; TestRenderer.cpp only #includes ShaderCompilation.cpp on Windows (EngineTest.vcxproj doesn't compile it).
  • Step 4: RenderItem.cpp no longer includes ContentTools/Geometry.h (element type keys 0/1/3 written directly, with a comment, like the drivers); _countof → std::size (+ <iterator>); x64/IBL/Set4/ path case.
  • Step 5 results (clang Debug unless noted, RX 6800 XT / RADV, KDE):
    • Wayland: 4 FP16 scRGB swapchains, ~145 fps (vsync, 144 Hz) with validation on; validation + sync validation 0 errors; GPU-AV (40 s) clean apart from its setup notices.
    • ASan/LSan/UBSan (build/linux-debug-asan, dlclose shim): by hand F11 restart, drag-resize (~30 swapchain recreations), close all → exit 0, no sanitizer or validation output.
    • Visual check (user): picture right. Alt+Enter (left and right Alt): enters/leaves borderless fullscreen (2752×1152 on the 125 %-scaled output — see B8), validation clean.
    • X11 (SDL_VIDEO_DRIVER=x11): 8-bit sRGB swapchains (format 50, color space 0, no HDR on X11 — expected), resize, fullscreen (3440×1440), close → exit 0, validation clean.
    • Release: builds, runs, exit 0; vsync-limited 145 fps (uncapped fps not measured — Space toggles vsync).
    • Only build warning in the test: upstream counter set-but-unused in engine_test::run() (its use is commented out).
  • Build dirs: the ASan and plain Debug builds both write x64/Debug/EngineTest — rebuild the one you want to run.

Expected differences from D3D12 (by design, see Phase 6 sections)

  • Vulkan draws the gpass directly (push descriptors per render item); D3D12's default path is ExecuteIndirect.
  • Lights/culling only run for frames with a camera (D3D12 requires a light set in every frame).
  • Swapchain: FP16 scRGB when the window system offers it, else 8-bit sRGB (D3D12: always FP16). The Windows AMD driver offers only 8-bit formats (+ A2B10G10R10) in SRGB_NONLINEAR while Windows HDR is off, so Vulkan on Windows gets B8G8R8A8_SRGB there (looks the same in SDR). With Windows HDR on it gets FP16 scRGB like D3D12 (A11).

Verification (every step)

  • VK_LAYER_KHRONOS_validation + sync validation clean (on automatically in Debug; the error count is printed at shutdown; PRIMAL_VULKAN_VALIDATION=0 turns it off).
  • GPU-assisted validation (since 6g) for anything that uses the resource heap — the normal layer can't see which heap slots shaders read: VK_KHRONOS_VALIDATION_GPUAV_ENABLE=1 (setting gpuav_enable; the older VK_LAYER_VALIDATE_GPU_BASED is silently ignored by this layer version). It's slow and prints a few setup notices.
  • RenderDoc captures vs. D3D12 reference frames.
  • ASan/LSan in Debug (-DPRIMAL_ENABLE_SANITIZERS=ON, build/linux-debug-asan). For leaks inside the Vulkan driver/layers, LD_PRELOAD a shim whose dlclose() returns 0 so LSan can symbolize them (see the Steps doc). Tools/CI/ci.sh sanitizers does this for the graphics tests (Tools/CI/noclose.c, Tools/CI/lsan.supp).
  • GraphicsTests (since 2026-11-10): x64/<Config>/GraphicsTests runs the window, surface and scene test cases on the session's display and GPU; xvfb-run -a runs them without showing windows where lavapipe is installed. A Debug run fails on any validation error or warning (vulkan::validation_stats()), also the ones reported while the device is destroyed. CI runs it in all five Linux configurations on Xvfb + lavapipe. It replaces the scripted drivers for regression checks; it does not replace looking at the picture.
  • Both window systems: Wayland (default on KDE) and X11 (SDL_VIDEO_DRIVER=x11).
  • Windows .vcxproj build still compiles.

Decisions

  • Windowing: SDL3 (standalone) + native X11 for editor-parented surfaces.
  • Descriptors: mutable descriptors + DXC resource heaps.
  • Vulkan baseline: 1.3 core (dynamic rendering, synchronization2, maintenance4) + VK_EXT_mutable_descriptor_type. Frame fences: timeline semaphore (same model as the D3D12 fence). Back buffer (milestone c): FP16 scRGB (R16G16B16A16_SFLOAT + EXTENDED_SRGB_LINEAR, like D3D12) when offered, else 8-bit *_SRGB.
  • D3D12 conventions kept in Vulkan: negative viewport height (y up in clip space, top-left origin), counter-clockwise front faces (as in the d3dx presets), reversed Z.
  • Root parameters (milestone b): root CBV/SRV/UAV → push descriptors (set 0); root constants → uniform buffers in the frame's constant buffer (no shader changes); static samplers → immutable samplers. Memory: VMA (vendored, Engine/ThirdParty/vma).
  • Assets: generated on Windows for now; ContentTools on Linux out of scope.
  • Language: C++23 — production-ready, not bleeding edge. No C++26 features. Linux/CMake enforces C++23 strictly (clang 23 / GCC 16 — both build clean since T07, 2026-11-09) and is the gate for portable code. The .vcxproj files use stdcpp23 (= /std:c++23preview, v145; confirmed 2026-11-09 in the toolset's cl.xml).
  • Commits: the user commits manually; never commit on their behalf.
  • Licensing: this is Charles Smith's fork, still MIT. LICENSE keeps Arash Khatami's notice and adds Copyright (c) 2026 Charles Smith. New files get the Charles Smith header; original files keep Arash's header even when modified.

Future work

Moved to Forgejo issues (2026-11-08): the modern C++ candidates that were listed here are in T04 / T05.

Pages 19

View all

Clone this repository