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
.vcxprojfiles (configures; remaining errors are Phase 2) - Phase 2 – Core portability →
TEST_ENTITY_COMPONENTSruns (clang; ASan/LSan/UBSan clean; Windows build not yet re-verified) - Phase 3 – Platform layer →
TEST_WINDOWruns; 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
SURFACEStest 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=falsebuild clean (0 C++ warnings at/W4);SURFACESand 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:
-
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 withPRIMAL_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 capturedidn't inject (no overlay, no log) — launch from qrenderdoc's "Launch Application" tab (working dirx64\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). -
FixDone 2026-11-08 (see B1).D3D12Shaders.cpp(see B1) and test it there. -
Existing game projects (made before 2026-11-06) need theDone 2026-11-08: added the guarded import (same line as the templates, before<Import>ofEngine\Vulkan.propsby hand.Microsoft.Cpp.targets) to all 12 projects inDocuments\PrimalProject\andDocuments\PrimalProjects\(.vcxproj.bakbackups next to them). Note: the user env varPRIMAL_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. WithPRIMAL_ENGINE→ Primal_Plus the import activates (checked withmsbuild /pp:vulkan-1.dlldelay-load present). 3 old projects (AwesomeProject,Test,PrimalProjects\NewProject) hardcode thePRIMALpath inPrimal_IncludePathand would keep using Primal's headers/libs even then. -
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 addsR16G16B16A16_SFLOAT/EXTENDED_SRGB_LINEAR, A2B10G10R10HDR10_ST2084andBT2020_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). -
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_INTERFACEper compiler,Progressiontypo). 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, andFbxImporter.cppnot 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.- 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 inPrimalEditor/Content/Material.cs).ShaderCompilerToolbuilds before EngineTest (Debug/Release only) and itsCompileEngineShadersstep writesx64\<Config>\shaders\d3d12\shaders.bin(+vulkan\with the Vulkan SDK) and ashaders.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 /constadded by clang-tidy where MSVC disagrees,std::scoped_lock,/W4warnings clang and GCC don't give. - Test variants (B5). Build
EngineTest\EngineTest.vcxprojwith each/p:PrimalEngineTest=value (ENTITY_COMPONENTS,WINDOW,SURFACES,RENDERER; no/FORCE:UNRESOLVEDneeded any more) — all link./p:PrimalEngineTest=BOGUSmust fail with a clear error. Needs/p:SolutionDir=<repo>\when built alone. - 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.keymatches). - 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 readsshaders.binthroughcontent::get_engine_shaders(),PSHBv2 layout; shaders moved toEngine\Graphics\Shaders\,graphics::hlslinstead ofd3d12::hlsl). AlsoTEST_ENTITY_COMPONENTS(no asserts) andTEST_WINDOW. - Editor. Create + load a project, add a script (the new template generates
EntityScript,game_entity::Entityand 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. - When all of that is clean: tell the user; the next items are T02's remaining steps (
/WXfor MSVC in the.vcxprojfiles, then C-style casts → C++ casts, see issue #2 (T02) "Remaining").
- Restore + build. NuGet restore (new project
-
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:- Rebuild
Primal.slnxin 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 *>fromFbxNodeAttribute *,static_cast<f32>/<u32>on FBX values);EngineAPI.cpp(reinterpret_cast<u64>(host),reinterpret_cast<HWND>(...),static_cast<u8 *>ofCoTaskMemAlloc,const_castinpatch_material_data());D3D12Upload.cpp(reinterpret_cast<ID3D12Resource *>(uintptr_t{1}));D3D12Content.cpp(create_pso_if_needed());PlatformWin32.cpp(HWND↔u64); MSVC warnings onreinterpret_cast/static_castthat clang doesn't give (C4311/C4312 pointer truncation, C4838). - 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_listandBlobStreamReader/Writernow usestd::memcpy, andpatch_material_data()changed.
- Rebuild
-
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:- 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 needWIN32_LEAN_AND_MEAN/NOMINMAXdefine them before it),EngineTest/Test.h(now leanWindows.h), the D3D12 files that includeD3D12Helpers.h/D3D12Resources.hthemselves now, andFbxImporter.h/.cpp(reordered without a compiler). Engine.vcxproj+.filterslist the newCommon\CommonDefinitions.h(edited blind) — check it shows up.- Game projects' scripts include engine headers through
EngineAPI/*.h: build one in-editor script project if Visual Studio is available (GameEntity.hincludesCommonHeaders.hinstead ofComponentsCommon.h).
- Rebuild
-
Windows CI workflowDone 2026-11-17 (#14 closed)..forgejo/workflows/windows.ymlon the user's Windows runner VM (Forgejo Runner, host mode, labelwindows;Tools/CI/WindowsRunner.md), green on the first commit that had both fixes: all four configurations, the EngineTest variants,UnitTests.exeand the entity-components test in Debug and Release, the build without Vulkan (2-8 min per job). What the first runs needed: theciaccount's script policy (RemoteSigned),GITHUB_ENVwritten without a byte order mark, and on the Linux runnerALLOW_ARCHIVE=1in its socket proxy (the server's config, not this repo). -
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:- Build
Primal.slnxDebug + Release: the new projectUnitTests\UnitTests.vcxproj(written blind; it is in the solution for Debug and Release, not the editor configurations). Things to look at: theDownloadDoctesttarget (MSBuildDownloadFile+VerifyFileHashtasks; it should putdoctest.hinpackages\doctest.2.5.3\once and check its SHA-256 on every build), theExternalIncludePathfor that folder withExternalWarningLeveloff (doctest must not trip/W4 /WX), linkingengine.libinto a console program, theEngine\Vulkan.propsimport. - Run
x64\Debug\UnitTests.exeandx64\Release\UnitTests.exe: 83 test cases, exit code 0. A console program, so noStart-Processis needed. Two suites were added later the same day and deserve a look on Windows:content::load_game(ContentLoaderTests.cpp) writesgame.bininto a folder understd::filesystem::temp_directory_path()and makes it the working directory (then restores it), andcontent::get_engine_shaders(ShaderBlobTests.cpp). Engine\Utilities\Vector.h:erase()anderase_unordered()gotvoid *casts on theirmemmove/memcpy(clang-Wnontrivial-memcall). No behavior change, but every project compiles it.- Two engine fixes the new tests needed (2026-11-10), both in code Windows also runs:
script::detail::get_script_creator()returnsnullptrfor a name that isn't registered (it asserted in Debug and dereferencedend()in Release) — the editor'sEngineAPI.cppandload_game()already check fornullptr; andcontent::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.
- Build
-
Graphics tests and the Vulkan validation counter on WindowsClosed 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.- Build all four configurations:
VulkanCore.cppnow counts validation errors and warnings instd::atomic<u32>s and resets them incore::initialize()instead ofcore::shutdown();VulkanInterface.hincludesPrimitiveTypes.hand declaresvulkan::validation_stats()(defined inVulkanInterface.cpp, so only in builds withPrimalVulkan). Run the Vulkan renderer test once: the "N validation error(s) were reported" line at shutdown must still appear only when there were errors. 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_sbranch 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.- CI image:
Tools/CI/Dockerfilegainedvulkan-swrast,vulkan-validation-layersandxorg-server-xvfb, andlinux.ymlnames the tag2026-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.
- Build all four configurations:
-
MSVC check of theDone 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 inmath::layerEngine/Utilities/MathTypes.hand the newMathSimd.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 (exceptFbxImporter.cpp, which has no math), MSVC hasn't built it:- Rebuild
Primal.slnx(4 configurations) + the 4 EngineTest variants. Two things only MSVC can show:vecoperators. With MSVCmath::vec(__m128) is a class in the global namespace and its+ - * /are functions in namespaceDirectX.MathSimd.hbrings them intoprimal::math::vec_operatorsand addsusing namespace math::vec_operators;to namespaceprimal, in place of the oldusing namespace DirectX;at each use. If that fails, the errors are C2676/C2677 (binary '-': ... does not define this operator) inD3D12Light.cpp,VulkanLight.cpp,Transform.cpp,EngineAPI.cpp,EngineTest/Scripts.cpporContentTools/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 inMathSimd.h, written asinline auto XM_CALLCONV f(...) noexcept -> T.
Engine.vcxproj+.filterslistUtilities\MathSimd.h(edited blind).UnitTests.exe: 90 test cases now (7 new in themathsuite pin down the conventions: row vectors, quaternion order, right-handed, reversed Z).- D3D12 renderer test and Vulkan renderer test: picture as before (cameras, light culling spheres and the per-object matrices all went through the conversion).
- 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)becamemath::is_equal(a, b, eps), which tests<where the old one tested<=. - Old game projects' scripts that write
DirectX::XM…still compile (the header is still included, andtransform::Component::calculate_*()return the same type under its new namemath::vec). New scripts should usemath::. - Likely C4459 (added 2026-11-12).
MathSimd.h:212near_equal4(..., FXMVECTOR epsilon): the parameter hidesmath::epsilon(MathTypes.h). clang's-Wshadow-allreports it; MSVC's C4459 ("declaration hides global declaration",/W4) is the same warning, and with/WXit fails every project that includesCommonHeaders.h. If it does: rename the parameter (tolerance) and re-runUnitTests.
- Rebuild
-
MSVC check of the logging workDone 2026-11-12/13 (one fix: C4530 inLog.cpp). Step 4's leak check done 2026-11-13 withTools/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 inDocs/Multithreading.md). Everything now logs throughprimal::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:- 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: theconstevalconstructor oflog::detail::Format(a format string plusstd::source_location);Log.cpp:std::vformat_tointo a custom output iterator,_wfopen_s, designated initializers under/W4 /WX.D3D12CommonHeaders.h:DXCalllogs withlog::errorbefore__debugbreak();NAME_D3D12_OBJECTcalls the newd3d12::detail::log_object_created()(WideCharToMultiByteto UTF-8,log::debug).D3D12Core.cpp,D3D12Helpers.cpp,D3D12Shaders.cpp,D3D12Surface.cpp:OutputDebugString→log::.EngineDLL/EngineAPI.cpp:log::initialize()inInitializeEngine,log::shutdown()inShutdownEngine, and the new exportDrainLog(buffer, size, cursor).ShaderCompilerTool.vcxprojlinksengine.lib, whereLog.cppnow lives: check that it still links.
UnitTests.exe: 100 test cases (10 in thelogsuite: two with threads, one writes a file under the temp folder).- Shader build step:
PrimalShaderCompilerprints plain lines (log::ConsoleStyle::plain). Repeat the A12.3 check: a syntax error in an engine shader must still fail the build with thefile(line,col): errorline in the build output. "Shader hash" lines appear in Debug builds only now. - 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 inx64\Debug\EngineTest.log(the previous run is kept asEngineTest.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). - Editor (
PrimalEditor/DllWrappers/EngineAPI.csDrainEngineLog(), a 250 msDispatcherTimerinMainWindow.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: theLibraryImportofDrainLogwith abyte*and aref ulong, the 40-byte header layout (LogMessageHeaderinEngineAPI.cpp), and closing the editor (the timer stops, thenShutdownEnginestops the logger thread). 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 onScanSourceForModuleDependencies, setsAllProjectBMIsArePublic, and gives the four other projects aProjectReferencetoEngine.vcxprojwithLinkLibraryDependencies=false(until now they only had a build dependency inPrimal.slnx). Check that everything still builds with it, alsoEngineTest.vcxprojalone (/p:SolutionDir=...), which now builds the engine through the reference. If it causes trouble before a module exists, remove the fiveImportlines.- A rule, not a check: the logger thread must be stopped with
log::shutdown()beforeEngineDLLis unloaded (ShutdownEnginedoes 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. D3D12Resources.cppDescriptorHeap::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.
- Build all four configurations + the 4 EngineTest variants +
-
MSVC check of the job system, the first C++ named moduleDone 2026-11-12 (Modules.propsworks; C5050 turned off in the importers). (issue #1 step 4; written on Linux 2026-11-12, design inDocs/Multithreading.mdsection 5). clang-cl parses it with 0 clang-tidy warnings (the Windows databases precompileprimal.jobs); MSVC hasn't seen a module of this repo yet.- Build
Primal.slnx, all 4 configurations. New:Engine\Core\Jobs.ixx(interface) andJobs.cpp(implementation unit) inEngine.vcxproj+.filters, andUnitTests\JobTests.cpp(import primal.jobs;after its#includes) inUnitTests.vcxproj. This is the first real test ofEngine\Modules.props(A19.7): UnitTests must getprimal.jobs.ifcfrom the engine through theProjectReference. Errors to expect if it doesn't: C2230 / "could not find module 'primal.jobs'". Also buildEngineTest.vcxprojalone. - Things only MSVC can show:
std::launder+ placement new into the job'sstd::array<std::byte, 48>;thread_localvariables in an implementation unit; the exportedrequiresclauses;_dupenv_sforPRIMAL_JOBS(same code asuse_validation()); notry/catchis used (exceptions are off). Also new: the*_invalid_idconstants inPrimitiveTypes.hareinline constexpr(so the module'sinitialize(u32 worker_count = u32_invalid_id)may name them); nothing else should notice. UnitTests.exe: 112 test cases, 12 in thejobssuite. Run it a few times (they start threads), in Debug and Release.- Worker threads are named
primal-job-Non Linux only; Windows (SetThreadDescription) is not done.
- Build
-
MSVC check of the job system's first usersDone 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. Newimport primal.jobs;lines (each after the file's last#include) in engine files (Transform.cpp,Script.cpp,D3D12Gpass.cpp,VulkanGPass.cpp,MainWin32.cpp), inEngineDLL/EngineAPI.cpp,EngineTest/Main.cpp+RenderItem.cppandUnitTests/EntityTests.cpp: these need A20 (Modules.props) to work.- Blind:
D3D12Gpass.cppfill_per_object_data()(per-object data listed per entity, one constant buffer block, filled withjobs::parallel_for) andMainWin32.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. - EngineDLL:
InitializeEngine()starts the pool,ShutdownEngine()stops it before the log (and on both failure paths ofInitializeEngine()). 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 calledInitializeEngine()(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: itsparallel_forjobs run on the workers and it waits without helping. Expected to work; watch for a hang while rendering. - Game scripts in a game DLL call
EntityScript::set_position()etc., which now usejobs::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. UnitTests.exe(113 test cases, 1 skipped benchmark) and both renderer tests. The renderer test logs "Test content loaded in ... ms (N threads)": compare withPRIMAL_JOBS=0set.
- Blind:
-
MSVC check of the frame phasesDone 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.- Build: the second module,
Engine\Core\Frame.ixx+Frame.cpp(inEngine.vcxproj+.filters).Entity.cppandCore\Engine.cppimport it,UnitTests\FrameTests.cpp(new, inUnitTests.vcxproj) andEngineTest\TestRenderer.cpptoo. - EngineDLL (blind): the editor lock is a
std::mutexnow (EntityAPI.cpp,externinEngineAPI.cpp), andUtilities\Threading.his no longer included anywhere. In the editor: rendering while entities are moved, added and removed in the UI; no stutter or hang. - Debug asserts that may fire in the editor:
game_entity::create/remove/update_componentassertframe::structural_changes_allowed(). The editor never runsframe::run(), so the phase staysbetween_framesand they shouldn't; if one does, note the call stack. - A game project: a script that changes its transform still moves its entity in the built game
(
engine_update()usesframe::run()now). UnitTests.exe(119 test cases, 1 skipped benchmark) and both renderer tests.
- Build: the second module,
-
Vulkan parallel recording on WindowsDone 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.cppandVulkanGPass.cppare part of the Windows build too (with the Vulkan SDK); clang-cl parses them with 0 clang-tidy warnings, MSVC hasn't built them.- Build all 4 configurations:
VulkanCore.cppnow importsprimal.jobsand readsPRIMAL_VULKAN_PARALLEL_RECORDINGwith_dupenv_s. - 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.GraphicsTestswould cover it (its "1100 objects" case), but it has no.vcxprojyet (#28). - 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. Engine\Utilities\Threading.hwas deleted (2026-11-12,TicketMutexunused since step 6), and itsClIncludelines removed fromEngine.vcxproj+.filters, blind: check that the projects load and build.
- Build all 4 configurations:
-
Script lifetime hooksDone 2026-11-12/13 (step 3,begin_playonce 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 virtualend_play(), andbegin_play()is now called (at the sync point offrame::run()).- 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.
- Editor (blind): the new-script template (
PrimalEditor\GameDev\NewScriptDialog.xaml.cs) now also generatesend_play(). Create a script in a project and build it. - A built game with a script whose
begin_play()logs: the line appears once, before the first update. UnitTests.exe(125 test cases, 1 skipped benchmark).
-
Linux re-check of the fixes from the Windows session 2026-11-12Done 2026-11-13 (Linux), together with A26.ci.sh checks,buildfor all four presets (clang/GCC, Debug/Release: 0 warnings,UnitTests128/128,GraphicsTests16/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.cppandD3D12Gpass.cpp(whitespace only). - clang-tidy (Linux):
UnitTests/LogTests.cppaLogTestthat can beconst(andLogTest::collectoris nowmutable: the sink writes to it through a pointer, which is undefined behavior for a member of a const object; four tests were alreadyconst);EngineTest/RenderItem.cppbugprone-integer-divisionin the sphere grid (row/column named first, same result). - clang-tidy (Windows databases):
D3D12Gpass.cppprepare_render_frame()const GpassCache &. Blind: check with MSVC next Windows session (A27). - Nothing else:
PRIMAL_LOG_HAS_EXCEPTIONSdoesn't tripcppcoreguidelines-macro-usage, and Linux takes thetrypath (__cpp_exceptionsis defined). GCC 16 acceptsscript_type_index<T>. (FbxImporter.*reports in thecontenttoolsdatabase are expected: no FBX SDK, seeTools/WindowsCompileDb/README.md.)
The original checklist:
Engine/Core/Log.cpp:<chrono>moved out of the sorted std group into its own#pragma warningblock (_MSC_VERonly), and the newPRIMAL_LOG_HAS_EXCEPTIONSmacro around thetryinformat_text(). Check clang-format (the include order), clang-tidy (Linux and Windows databases; a macro may tripcppcoreguidelines-macro-usage) and that Linux still takes thetrypath (exceptions are on in CMake).Engine/Utilities/MathSimd.h:near_equal4()parametertolerance.Engine/Content/ContentToEngine.cpp:gpu_id_from_fake_pointer()withoutconstexpr(also still open from 2026-11-11). Committed in2260632.Engine/Modules.props: C5050 off outside the engine (Windows only;gen_windb.pydoesn't read it).- Rule for later: any engine
.cppthat includes<chrono>itself needs the same#pragma(C4530 underEngine.vcxproj's no-exceptions setting);<thread>/<mutex>alone are fine. - #19 work done on Windows (written with MSVC only):
Log.h/Log.cpp(set_forward(),write_forwarded(),submit()split out ofwrite(),forwarded_filesinState),GameEntity.h(script log helpers,script_name(),set_script_type_name<T>(),REGISTER_SCRIPTchange,<format>etc. included),Script.cpp(name table,log_message(),set_log_forwardexport underUSE_WITH_EDITOR),D3D12Core.cpp(Windows only),UnitTests/LogTests.cppandFrameTests.cpp(3 new tests). Build with clang and GCC, Debug and Release; runUnitTests(128) andGraphicsTests; clang-format; clang-tidy (both databases; theNOLINTondebug_layer_message, thereinterpret_castofGetProcAddressinEngineAPI.cpp); TSan (write_forwarded()takesforwarded_files_mutexwithout the queue lock). GCC 16:script_type_index<T>is aninlinevariable template used in a header (no module involved).
- clang-format:
-
Linux check of the constant buffer and stress-test workDone 2026-11-13 (Linux): builds, tidy and TSan as in A25 (TSan runs the "1100 objects" graphics test, so the lock-freeallocate()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 byGraphicsTests.)The original checklist (2026-11-13, written and run on Windows only):
- Vulkan code edited with MSVC only:
VulkanResources.h/.cpp(ConstantBuffer::reserve(), atomic offset, lock-freeallocate()/range()),VulkanGPass.h/.cpp(collect_render_items(),material_data_size(),surface_cache(SurfaceId)),VulkanCore.cpp(reserve()inrender_surface()). Build with clang and GCC, clang-tidy, and runGraphicsTests(Debug, validation) andci.sh tsan:allocate()is now lock-free. EngineTest/Test.htest_env_u32()(_dupenv_son Windows,std::getenvon Linux) and the stress options: run the renderer test withPRIMAL_TEST_EXTRA_SPHERES=6400 PRIMAL_TEST_VSYNC=0on RADV and compare with the Windows table ("Windows session 2026-11-12", second half).- clang-tidy with the Windows databases on
D3D12Core.cpp,D3D12Gpass.cpp,D3D12Resources.*(new code:env_flag(),ThreadCommandLists,record_pass(),queue_and_continue()).
- Vulkan code edited with MSVC only:
-
MSVC check of the A25/A26 fixesDone 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.exe128/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 afterWM_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):
- Blind:
Engine/Graphics/Direct3D12/D3D12Gpass.cppprepare_render_frame():const GpassCache &cache(only parsed by clang-cl). Build Debug + Release; run the D3D12 renderer test. - clang-format-only edits in
D3D12Core.cpp/D3D12Gpass.cpp(line breaks insideDXCall(...)andNAME_D3D12_OBJECT_INDEXED(...)): they build if 1. builds. UnitTests.exe(128):LogTests.cppnow has amutablemember inLogTest.
- Blind:
-
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,
PrimalFbxSdkDirinContentTools.vcxproj(default: 2020.3.11 in its default folder), instead of the 2020.3.7 path in the.vcxprojand six#pragma comment(lib)lines inFbxImporter.cpp; a missing SDK stops the build with "FBX SDK not found". 2020.3.11's libxml2 needsbcrypt.lib(added). Built and checked in the VM (DebugEditor, ReleaseEditor).- Install FBX SDK 2020.3.11 (VS2022) on the desktop (the installer is in the Linux machine's Downloads;
/Sinstalls 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\"). - Build DebugEditor and import an FBX in the editor (user): the SDK version changed.
- Install FBX SDK 2020.3.11 (VS2022) on the desktop (the installer is in the Linux machine's Downloads;
-
#30 script registration (2026-11-13; built and tested with MSVC in the VM). On the desktop:
- 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 oldget_script_creator(size_t), so the editor can't load them ("Failed to load game code DLL"). Scripts written withREGISTER_SCRIPTdon't compile any more (removed, no backwards compatibility): writePRIMAL_SCRIPT(Type);after the class. Editor: New Script + builddone in the VM 2026-11-13 (after #40): the dialog writesPRIMAL_SCRIPTin 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_playruns.- Optional: a game script (
PRIMAL_GAME_SCRIPT) that logs inbegin_play()/end_play(): run the built game (Ctrl+F5) and close it; both lines appear once in itsprimal.log.
- Done on the desktop 2026-11-19 (#52 comment): old projects converted; the upgrade check now also warns
about
-
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/.cppopensvulkan-1.dll/libvulkan.so.1and loads every function (VK_NO_PROTOTYPES);Engine/Vulkan.propslostvulkan-1.lib,delayimp.lib,DelayLoadDLLsand/IGNORE:4199. In the VM: all 4 configurations build,dumpbin /dependentsshows novulkan-1.dllinEngineTest.exe(Debug, Release) orEngineDLL.dll,UnitTests.exe139/139, renderer test exit 0 on D3D12 (WARP) and Vulkan (lavapipe, validation clean). On the desktop (real GPU):- Renderer test with
PRIMAL_GRAPHICS=vulkan, Debug: validation clean, picture right (user). - The editor still starts and renders on D3D12 (no source change there;
EngineDLLsimply has no Vulkan import now).
- Renderer test with
-
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++ throughSharedTypes.h) replacesTILE_SIZEeverywhere, also in the editor'sDefaultMaterialShaders.hlsl; the engine shader table isEngine/Graphics/Shaders/EngineShaders.h, the binding valuesShaderBindings.h;PrimalShaderCompilerchecks 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.exe139/139 (Debug, Release), renderer test exit 0 on D3D12 (WARP) and Vulkan (lavapipe, validation clean). On the desktop (user):- Renderer test, D3D12 and Vulkan: picture right, light culling unchanged (lights light the right tiles).
- Editor (DebugEditor): open the material editor with the default material. It compiles
DefaultMaterialShaders.hlslat run time, which now readsLightCullingTileSizefromCommon.hlsliinstead of its own#define TILE_SIZE.
-
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()inD3D12Content.cpp);UnitTests.exe148/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: giveStart-Editor-TimeoutSeconds 240then.) Were blind: the D3D12 halves ofgraphics::reload_shaders()(D3D12Content.cppPSO cache rewrite withPsoSource/rebuild_pipelines(),D3D12Shaders.cppreload(),D3D12LightCulling.cpp/D3D12PostProcess.cpprecreate_pipelines(),D3D12Interface.cpp), the DXIL PDBs (write_pdb()inShaderCompilation.cpp,IDxcBlobWide), EngineDLL (ShaderData::platform,GetGraphicsPlatform()), the editor's C# (Shader.cs,EngineAPI.cs), and every.vcxprojedit (ShaderPack.ixx/.cppinEngine.vcxproj,ShaderHotReload.cppinEngineDLL.vcxprojandEngineTest.vcxproj,ShaderPackTests.cppinUnitTests.vcxproj, the--packstep inShaderCompilerTool.vcxproj). In the VM:- All 4 configurations + the 8 EngineTest variants build, 0 warnings;
x64\<Config>\shaders\TestShader.shaderpackis written with DXIL and SPIR-V (the first pack with both; Linux can't make DXIL, B13). UnitTests.exe(new suites "shader pack", "shader groups").- Renderer test on D3D12 (WARP) and Vulkan (lavapipe) exits 0. Then hot reload: while it runs, append a line to
EngineTest\TestShader.hlsland touchEngine\Graphics\Shaders\PostProcess.hlsl; the log shows "Shader hot reload: done" and "... pipeline states rebuilt" (D3D12) without debug-layer errors. - Debug:
x64\Debug\shaders\d3d12\pdb\*.pdbexist after the engine shaders compile. - 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 withx64\Debug\shaders\d3d12\pdbin its search path.
- All 4 configurations + the 8 EngineTest variants build, 0 warnings;
-
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 inCullLights.hlsl,PostProcess.hlslandTestShader.hlslname the type (Texture2D<float4>(...); DXC's SPIR-V is byte-identical). The Slang path itself (EngineDLL/SlangCompilation.cpp, CMake optionPRIMAL_ENABLE_SLANG) is Linux-only: no.vcxprojcompiles it. VM results: all 4 configurations build, 0 C++ warnings (the editor configurations' 4 are the old C# CS0649 inMaterial.cs);UnitTests.exe148/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. -
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.mdsection 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) intransform::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.exe159/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. -
Done on the desktop (user, confirmed 2026-11-21). #48
utl::free_listrewrite (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.exeDebug + 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). -
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; newmath::Frustum(Docs/Math.mdsection 6). Blind on Linux and fixed in the VM:EngineDLL/EntityAPI.cpp(av3from 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.exeDebug + 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). -
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.vcxprojfiles (stdcpp23) build without it, so that toolset mapsstdcpp23to the new switch. On the desktop: check whether its toolset does the same. Result: both toolsets mapstdcpp23to/std:c++23. clang-cl 23 ignores/std:c++23(unused argument, C++20 stays), sogen_windb.pykeeps/std:c++23preview; only the docs' notes changed. Once both have it, changeTools/WindowsCompileDb/gen_windb.py(clang-cl gets/std:c++23preview) and the/std:c++23previewnotes inDocs/Preferences.mdandCLAUDE.md. -
#47 C# scripting experiment on Windows (2026-11-18,Obsolete 2026-11-21: #47 was decided against (2026-11-18); the experiment is on branchPrototypes/CSharpScripting/; built and run on Linux only).core_clr. The host's Windows paths (wchar_tchar_t,LoadLibraryW,libnethost.libwithNETHOST_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, orcllikePrototypes/Reflection/build-msvc.ps1) and run it: all checks pass, timings comparable. -
#41 reflection in the editor (2026-11-18; C# written blind, the rest checked in the VM). On the desktop (user):
- 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.targetsto its.vcxprojand warns about eachPRIMAL_SCRIPT(Type);(GameProjectUpgrade.cs); convert those scripts by hand (marker before the class,PRIMAL_GENERATED_BODY()inside,#include "<file>.generated.h"last). - Create a script with the New Script dialog: the header has the markers, the project builds (MSBuild runs
PrimalReflectGenfrom the engine'sx64\<Debug|Release>\), the script shows in the script list and runs. - A new project from each of the four templates builds.
- 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
-
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. -
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. -
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.md10.7. VM results (2026-11-19, DebugEditor, ScriptTest, D3D12 on WARP): entities named, two scripts and the game'sArmorcomponent on one entity; every field editor (number, check box, enum, entity, string, vector) edits, clamps to.maxand 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. -
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 isPrimalEngine.dll(+PrimalEngine.lib), a game executable also links the newEngineMain.lib(WinMain); game projects linkPrimalEngine.lib;EngineMain.lib;in every configuration, and the editor's project upgrade rewritesEngine.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 copiesPrimalEngine.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 onPrimalEngine.dll, scripts begin play with their saved values, exit 0; the editor opens ScriptTest, builds and loads its game code. On the desktop (user):- 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.
- In the editor: the script list, scripts and the game component on entities, field edits, then Run (Ctrl+F5):
the game starts (
PrimalEngine.dllcopied next to it) and logs as before. - 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.
- Debugging in Visual Studio (if installed): breakpoints in engine code from the game work (the
.pdbis copied too).
Left in the VM from this session (2026-11-19):
C:\primal-head(a build of HEAD50087f6, 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.ps1timesLoadGameCodeDll(-EngineDll,-GameDll,-Runs). InInvoke-Interactivecommands, don't end withexit: it leaves the task script before it writes its result, and the call waits until it times out. -
#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. -
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 andCameraPart(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):- 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.
- F11 (restart) and Esc on one window (its camera actor goes, the others keep rendering): not driven in the VM.
- Frame times: Linux Release with vsync off was the same as before (1.73 ms vs 1.74-1.80 ms at HEAD).
-
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/PartReffields, making classes by name, the render components reflected. VM results: all 4 configurations + 8 EngineTest variants, 0 C++ warnings (the editor's two CS0649 inMaterial.csare 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 outrender::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 norender::...ones, and a game project still builds and runs (Ctrl+F5). Nothing else to look at. -
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). -
#59 step 6, the editorDone 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.mdsection 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.cppactor exports,EngineAPI.cpp(RenderFrame, light sets),Graphics/SceneSync.*(add_light_set()),Actors/Actor.cpp+ActorSystem.h(renames,RenderParts.h),UnitTests/ActorReflectionTests.cpp. -
#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.mdsection 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. -
#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.mdsection 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 lostgraphics::Camera/Lightand the geometry component). -
#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.mdsection 10).graphics::render_frame()replacesSurface::render(); one fence wait, submission and present per frame; render targets, barriers, gpass cache and light buffers per surface; the editor callsRenderFramesonce 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 oneRenderFramescall 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. -
#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.mdsection 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'sExecuteIndirectpath andPRIMAL_D3D12_DRAW_INDIRECTare 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 withPRIMAL_TEST_EXTRA_SPHERES=1200(batched) on D3D12 (WARP) and Vulkan (lavapipe, validation on): exit 0, no errors, matching pictures. Not run: TSan (CI'stsanjob runs it on push). On the desktop (user): the renderer test on D3D12 and Vulkan withPRIMAL_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), andx64\Release\GraphicsTests.exe -tc="benchmark*" --no-skipon the real GPU. -
#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.mdsection 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 tsannow 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 withPRIMAL_TEST_EXTRA_SPHERES=1200on 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 withPRIMAL_TEST_EXTRA_SPHERES=6000on both backends (four windows; resize one), PIX/RenderDoc on one frame, and the benchmarks on the real GPU. -
#3 step 6, cleanup (2026-11-23; Linux + built and run with MSVC in the VM the same day;
Docs/Renderer.mdsection 13). Object names throughvkx::set_name()/d3dx::set_name()(the macros are gone), per-pass debug markers,std::spanat 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 withPRIMAL_TEST_EXTRA_SPHERES=1200on 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):
- 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. - The same with
PRIMAL_TEST_EXTRA_SPHERES=6000(the batched path): the picture as before, no stutter. - 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.
- 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.
x64\Release\GraphicsTests.exe -tc="benchmark*" --no-skip(Vulkan) with and without vsync; compare withDocs/Renderer.mdsections 10-12.
- Build the four configurations; run the renderer test (
-
#28, GraphicsTests on Windows with both backends (2026-11-23; Linux + the VM the same day).
GraphicsTests.vcxproj(inPrimal.slnx; console program, same sources as CMake); the tests run on the backendPRIMAL_GRAPHICSnames (graphics_test::platform(); Windows default D3D12) and checkgraphics::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 inupload::shutdown()(B17). Coverage:ci.sh coverage+ acoveragejob inlinux.yml(needs image tag2026-11-09-dwithllvm). 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 withPRIMAL_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):
GraphicsTests.exeon the real GPU, Debug, both backends (PRIMAL_GRAPHICS=d3d12,=vulkan, withPRIMAL_TEST_REQUIRE_VALIDATION=1): 22 passed.- Under the Visual Studio debugger, a D3D12 debug layer message still breaks (the break is only skipped without a debugger).
- Publish the CI image:
Tools/CI/publish-image.sh(tag2026-11-09-d, addsllvm) before pushing, then check thecoveragejob's artifact. - The Windows runner: desktop session, Graphics Tools, lavapipe (
Tools/CI/WindowsRunner.md, "Graphics"); then set the repository variablePRIMAL_CI_GRAPHICStotrueand check the Windows run.
- GCC, tidy (both databases),
-
#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, inPrimal.slnx, outputx64\<Config>\EditorTests\): 31 view-model tests against an engine in memory (FakeEngine.cs) and 5 againstEngineDll.dll. The seams they need:EngineAPI.EntityAPI/ActorAPIare interfaces now (DllWrappers/EngineInterfaces.cs),EditorServices(UI thread, dialogs; the WPF side inCommon/WpfServices.cs, set inApp),ReflectedTypes.Load(json),Project(name, path)makes an in-memory project andLoad()starts the first game code build (wasOnDeserialized). No WPF types inActor/ActorPartany more: the outliner and the part tree bindDepth/PartDepththroughDepthToIndentConverterandIsTreeVisiblethroughBooleanToVisibilityConverter; the log's filtered view isLoggerView.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:- 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).
- Add a behavior, remove it, undo, redo: the actor runs with each behavior once (Run, then the log).
- Windows CI: the new "Run the editor tests" step passes in the DebugEditor and ReleaseEditor jobs.
-
#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 byProject.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, orBuildEngineActors()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:- 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.
- New Scene, activate it: a Directional Light there too; Undo doesn't remove it on its own.
- 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.
-
#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.cppreads FBX with ufbx 0.23.1 (downloaded and hash-pinned like doctest:cmake/PrimalDependencies.cmakeandContentTools/ThirdParty.targets, change both).load_fbx()returnsstd::expected<Scene, FbxImportError>; MikkTSpace is downloaded the same way (pinned to commit3e895b4, the copy inContentTools/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 fromContentTools.vcxproj(PrimalFbxSdkDir, its libraries,CheckFbxSdk), the README,Tools/CI/WindowsRunner.mdandTools/WinVM/. Geometry processing and FBX import also build on Linux now (CMake targetContentTools, a static library;ToolsCommon.h's Windows parts are behindPRIMAL_PLATFORM_WINDOWS,pack_data()usesmallocoff Windows, the unused oldcalculate_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 andUnitTests/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 andprocess_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) andPrimalEditor.Tests/ContentToolsTests.cs(the editor's import throughContentTools.dll, passing in the VM in both editor configurations). Desktop:- Build DebugEditor and ReleaseEditor: they build without the FBX SDK (it can be uninstalled afterwards).
- 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.
-
#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.mdsection 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 fromContentTools.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:- Build DebugEditor and ReleaseEditor.
x64\DebugEditor\shaders\ContentTools.shaderpackappears at the editor's first start, with no "Failed to compile ContentTools' shaders" warning in the log. - 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: ...").
- 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).
- GraphicsTests on the desktop GPU, both backends: the "image based lighting" suite passes.
- Build DebugEditor and ReleaseEditor.
-
#13 step 1, Dear ImGui in the engine (2026-11-24; written on Linux, checked on Linux and in the VM;
Docs/Editor.mdsection 9). The renderer's UI pass (graphics::UiDrawDataonSurfaceFrame::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 inEditor/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, theEDITOR_UIEngineTest 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:- Build EngineTest with
/p:PrimalEngineTest=EDITOR_UIand 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. - 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.
- GraphicsTests on the real GPU, both backends: "ui pass" and "platform::Window input" pass.
- Build EngineTest with
-
#13 step 2, offscreen views and theme v1 (2026-11-24; written on Linux, checked on Linux and in the VM;
Docs/Editor.mdsection 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 tox64/<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), theEDITOR_UIEngineTest on both (exit 0, clean logs; a VM screenshot showed the docked viewport with its moving quad). Linux desktop and Windows desktop:- Run the
EDITOR_UItest (Linux: presetlinux-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. - 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.
- GraphicsTests on the real GPU, both backends: "offscreen surface" passes (it includes a pixel check of a readback).
- Watch for
LNK1235(a corruptEditorUI.lib): it happened once in the VM on the first Debug build afterTheme.cppwas added, and not on the rebuild.
- Run the
B. Known bugs / fixes to make (either OS)
-
D3D12Shaders.cppreads misalignedcompiled_shaderrecords fromshaders.bin(records are packed; au64size is misaligned when an earlier byte code size isn't a multiple of 8 — UB, harmless on x86). Port the aligned-copy loader fromVulkanShaders.cpp. Windows-only file → fix and test on Windows. Fixed 2026-11-08:D3D12Shaders.cppnow uses the same loader (sizes read withmemcpy, records copied to 8-byte aligned offsets; missing/corrupt file →OutputDebugStringA+return falseinstead of only asserting). The existingshaders/d3d12/shaders.binhad 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. -
when the shader source folder doesn't exist (executable copied elsewhere, next to an existingcompile_shaders()throws an uncaughtstd::filesystem_errorshaders.bin). Fixed 2026-11-08:ShaderCompilation.cppuses theerror_codeoverloads (up-to-date check, save,exists), logs the missing file and returns false. That exposed a crash behind it:Main.cppcallsshutdown()after a failedinitialize()andtest_shutdown()removed entities that were never created →TestRenderer.cppnow skips the teardown untilgraphics::initialize()succeeded, andrun_test()returns 1 wheninitialize()fails. Tested on Linux with the executable +shaders/copied to a folder without sources → "Engine shader source not found", exit 1. -
. Fixed 2026-11-08:compile_shaders()up-to-date check ignores compiler changesshaders.bin.keynext toshaders.binholds 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 aftershaders.bin(and deleted before writing it), so it only exists next to a complete file.shaders.binitself 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. -
Fixed 2026-11-08 (Phase 7 step 4:RenderItem.cpploads../../x64/ibl/...but the folder isIBL.IBL/Set4, works on both OSes). -
. Fixed 2026-11-08 (blind, check on Windows — see A12): MSBuild propertyEngineTest.vcxprojalways compiles the renderer test filesPrimalEngineTest(defaultRENDERER;/p:PrimalEngineTest=WINDOWetc., invalid values → build error) sets theTEST_*defines and compilesLights/RenderItem/Scripts/TestRenderer.cpponly forRENDERERand..\EngineDLL\ShaderCompilation.cppforRENDERER/SURFACES, likeEngineTest/CMakeLists.txt.TestRenderer.cppno longer#includesShaderCompilation.cpp. Switching tests by editingTest.hno 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. -
. Fixed 2026-11-08:d3dx::blend_state.premultipliedhasBlendEnable = 0BlendEnable = 1ind3dxandvkx(factors ONE / INV_SRC_ALPHA only make sense blended;alpha_blend/additivehave it on). Neither preset is used anywhere yet, so nothing renders differently. -
Warnings (pre-existing). Fixed 2026-11-08:FreeList.hdebug fill casts tovoid*;create_resource()gotdefault: assert(false)likedestroy_resource();counterinTestRenderer.cppmarked[[maybe_unused]]. Linux Debug + Release now build with 0 warnings. -
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. -
Every. Fixed 2026-11-08: Vulkantest_initialize()creates each swapchain twiceresize_surface()returns early whenneeds_resize()is false (no flush, no recreate). D3D12'sresize()still always callsResizeBuffers(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. -
Unexplained
0x80000003exit 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 toOutputDebugString). -
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 inDocuments\PrimalProject\+Documents\PrimalProjects\→v145+stdcpp23(backups*.vcxproj.pre23.bak),PrimalProjects\NewProjectalso SDK10.0.19041.0→10.0. Build check (copies in the session scratchpad, DebugEditor + Debug): the 9 without sources + a generatedTestScriptall build clean. Still broken, by hand:PrimalProject\NewProjectandPrimalProjects\NewProject5have scripts in an older API (Primal::Script::EntityScript,BeginPlay/Update) → port them toprimal::script::EntityScript/begin_play/updateor delete. The 3 that hardcode...\RiderProjects\PRIMAL\inPrimal_IncludePath(AwesomeProject,Test,PrimalProjects\NewProject) still build against the old repo (TestOK,AwesomeProjectDebugEditor fails to link that repo'sEngine.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 fromProject.Load()before the first game-code build. It checksGameCode\<Name>.vcxprojfor the toolset, the language standard (also when none is set), a pinned Windows SDK,Primal_IncludePath/Primal_LibraryPaththat don't start with$(PRIMAL_ENGINE), and theEngine\Vulkan.propsimport; 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 fourMSVCProjecttemplates. 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):AwesomeProjectshows 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. -
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 whilecore::set_deferred_releases_flag()took the deferred-release mutex, andprocess_deferred_releases()holds the deferred-release mutex whileprocess_deferred_free()takes the heap mutex. One thread did both, so it never deadlocked; a job freeing a texture duringrender()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 intocore::while holding a resource's own mutex. -
The distro DXC on Linux (Arch
directx-shader-compiler1.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=vulkanandvulkan-with-sourceassert onPostProcess.hlsl,CullLights.hlslandTestShader.hlsl, so Debug SPIR-V uses-Zionly (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 tolibdxcompiler.so, and stops in the same assertion. -
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,LoadGameCodeDlllogs the path and the Windows error code whenLoadLibraryfails. -
MSVC 14.52's link-time code generation crashes on
UnitTests/JobTests.cpp(C1001 inIMAGE::BuildImage, LNK1000; found 2026-11-19 with #59 step 1). Release only (/GL+/LTCG), only since the engine is a DLL that the file importsprimal.jobsfrom, and not caused by the export marks (it stays without anydllexportin the module interface; bisected in the VM to that one file). EngineTest, EngineDLL and ShaderCompilerTool import the module too and link. Worked around:JobTests.cppis 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 onvectortests.cpp(same C1001/LNK1000, Release,/LTCG:incremental): this time a stale incremental database; deletingx64\Release\UnitTests.iobjand.ipdbfixed it. Try that first when the crash names another file. -
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'sfence_value, which was kept from the previous session while the new fence started at 0, soSetEventOnCompletion(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--interactivemode — 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.
-
— done 2026-11-09: it passesgen_windb.pyon/std:c++latest/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 (HEAD8f333d9plus 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 tidy0. Fixes: clang-format in 11 files (the desktop has none), onemodernize-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 renamedUnitTests/TypeRegistry*and newGameSystemTests.cpp(CMake lists),EntityTests.cppdropped fromprimal_reflect(), and GCC's view ofEngineTest/Scripts.cpp(behaviors;CameraScriptkeeps itsmath::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: MSBuildLanguageStandardstdcpp23=/std:c++23preview(v145). All.vcxprojfiles (Engine, EngineDLL, EngineTest, ContentTools, ShaderCompilerTool) and the game project templates switched fromstdcpplatest(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
.vcxprojonly (toolset v145) + NuGet (D3D12 Agility SDK, DXC). - Graphics is already abstracted:
Renderer.cppdispatches through theplatform_interfacefunction table andgraphics_platformenum. A Vulkan backend plugs in alongside D3D12 without changing the engine API. - Windows coupling outside the D3D12 backend:
PlatformTypes.h(window_procis aWNDPROC),PlatformWin32.cpp,InputWin32.*Core/EngineWin32.cpp,Core/MainWin32.cpp,Content/ContentLoaderWin32.cppUtilities/Math.h(_BitScan*64, DirectXMath include gated on_WIN64),MathTypes.hUtilities/Threading.h(has a non-Windows fallback already)Components/Script.cpp(ATLSAFEARRAYexport, 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-ingEngineDLL/ShaderCompilation.cpp(wrl.hComPtr + DXC → DXIL only).
- Backslash
#includepaths inRenderer.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:
- Native handles are opaque, not SDL objects. The platform layer exposes a
native_window_handle { kind (win32/x11/wayland), display, window }. The Vulkan backend createsVkSurfaceKHRfrom that struct (xlib/xcb/wayland surface extensions enabled explicitly), never from anSDL_Window*. SDL3 is used for standalone windows (EngineTest, game) and its native handles are extracted via SDL window properties. - Parented windows must be supported.
window_init_info::parentbecomes an opaque native parent handle. On Linux an editor render surface is an X11 child window created under the Avalonia hostXID(native X11 path, not SDL). - Input must be injectable. The input module must accept events pushed from outside (editor forwards Avalonia input), not only events pumped by SDL.
- C ABI only, UTF-8 strings. No
wchar_tacross the editor boundary (4 bytes on Linux, 2 in C#), noSAFEARRAY/BSTR, noHWNDin signatures (u64/void*instead). Window captions move to UTF-8. - Engine is built position-independent (
-fPIC) so it can be linked intolibEngineDLL.so.EDITOR_INTERFACEgets avisibility("default")variant;LoadLibrary/GetProcAddress→dlopen/dlsym. - Shader compilation stays a reusable library (DXC on Linux, Phase 5) so EngineDLL can use it, not just EngineTest.
- 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). Enginestatic library (PIC),EngineTestexecutable. Linux source lists exclude Win32 and D3D12 files.- Flags matching the vcxproj intent: C++23 (
CMAKE_CXX_STANDARD 23, strict, no extensions; vcxproj usesstdcpp23since 2026-11-09,stdcpplatestbefore), AVX2/FMA/F16C/SSE4.2, fast-ish FP (-ffp-contract=fast -fno-math-errno, not-ffast-math). EngineTestoutput goes tox64/<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.hdefaults 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_WIN64checks. - 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_mutexusesstd::atomicmembers. - Renderer: gate the D3D12 backend behind a build define so
Renderer.cpplinks on Linux. EngineTest/Main.cppnon-Windows path: drop_CrtSetDbgFlag, use ASan/LSan (CMake option). Portset_current_directory_to_executable_path(/proc/self/exe) into a shared utility.Test.htime_it: portable logging (stderr).
Phase 2 – done (2026-11-04)
Engine/Common/PlatformDetection.h(new, included byCommonHeaders.h):PRIMAL_PLATFORM_WINDOWS/PRIMAL_PLATFORM_LINUX(always 0/1, use#if), plus overridablePRIMAL_GRAPHICS_D3D12(defaults to Windows) andPRIMAL_GRAPHICS_VULKAN(0 then; defaults to Linux since Phase 6a). Added toEngine.vcxproj+ filters.Math.h/MathTypes.h: DirectXMath on all platforms;<immintrin.h>;log2nowconstexpr, implemented asstd::bit_width(value - 1)(same results as the_BitScan*version).Threading.h:<atomic>/<immintrin.h>includes; Windows path unchanged.Renderer.cpp: D3D12 include andswitchcase gated onPRIMAL_GRAPHICS_D3D12.ContentToEngine.cpp: explicit cast fixes a narrowing error clang rejects.EngineTest/Main.cpp: Linuxmain()+/proc/self/exeworking-directory helper; leak checking via-DPRIMAL_ENABLE_SANITIZERS=ONinstead of_CrtSetDbgFlag.EngineTest/Test.h:time_itportable (stderr on Linux).- Bugs found and fixed (they affect Windows too):
utl::vector::eraseusedmemcpyon overlapping ranges (UB; caught by ASan) →memmove.time_itmixedhigh_resolution_clockandsteady_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::sizeinTestWindow.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) inRenderer.h,GraphicsPlatformInterface.h,Input.h; (b) members with constructors in an anonymous struct inside a union (MSVC extension) inTransform.cpp. Fixing (a) means renaming public API types/members, so it's a separate decision. - Existing clang warnings left as-is:
-Wnontrivial-memcallinVector.h/FreeList.h(intentional relocation viamemcpy/memset),-WswitchinContentToEngine.cpp.
- The shared "set cwd to executable path" utility → done in Phase 4
(
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_procinwindow_init_infowith an engine event callback (close, resize, fullscreen toggle, key/mouse). UTF-8 captions. PlatformLinux.cppmirroringPlatformWin32.cpp(free list of windows, resize, fullscreen,is_closed);window::handle()returns the opaque native handle.InputSDL.cpp: SDL scancodes/mouse →input_code(likevk_mappinginInputWin32.cpp).- Platform
pump_events()replacesPeekMessageloops inMainWin32.cppandEngineTest/Main.cpp; port window procedure logic inTestWindow.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()returnsconst native_window_handle*(editor constraint 1). It points into the window list: copy it if it's needed after the nextcreate_window/remove_window. D3D12 takes the HWND from it.window_init_info:window_event_callback(no moreWNDPROC), UTF-8caption,parentis anative_window_handle*(editor host window).window_event { closed, resized, key_down, key_up }withinput_codeand modifier flags. Key repeats update input state but aren't sent as events.resizedis 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 untilremove_window(). (Win32 previously destroyed the HWND on close.) platform::pump_events()(false once a quit was requested) andplatform::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=x11forces 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 callsSDL_DestroyWindowSurfacebefore 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). Generickey_shift/key_control/key_altstay 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(alreadystd::filesystem); same forEngineWin32.cpp. Remove_WIN64gates /<Windows.h>.- Forward slashes /
std::filesystem::pathforRenderer.cppshader path table and the 18 asset paths inRenderItem.cpp; fix"enginetest"casing. - Assets (
.model,.texture, IBL) are generated on Windows with ContentTools and copied over. Textures storeDXGI_FORMAT; Vulkan backend needs a DXGI →VkFormattable (BC formats OK on RADV).
Phase 4 – done (2026-11-04)
Content/ContentLoaderWin32.cpp→Content/ContentLoader.cppandCore/EngineWin32.cpp→Core/Engine.cpp: platform-neutral, only gated on!SHIPPING. Renamed with plainmv(stage the renames yourself).Engine.vcxproj+ filters updated.Core/MainLinux.cpp: Linux gamemain()(counterpart ofMainWin32.cpp'sWinMain). Executables with their ownmain()(EngineTest) don't pull it fromlibengine.a.platform::set_current_directory_to_executable_path()(Platform.h, implemented per platform) replaces the copies inMainWin32.cppandEngineTest/Main.cpp.- Paths:
Renderer.cppengine shader paths and the 17 asset paths + test shader folder inRenderItem.cppuse 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-byteints (Project.cs,Script.cs); now read withread_u32().engine_shutdown()removed the game window even whenengine_initialize()failed before creating it (assert / bad free-list access whengame.binis missing).
- Tested on Linux: a game executable linked from
libengine.aalone loads a hand-madegame.bin(one transform entity) when started from another directory, runs, and quits cleanly on SIGTERM; a missinggame.binnow exits cleanly. - Still to do by hand: copy the renderer test assets generated on Windows (
x64/*.model,x64/*.texture,x64/ibl/...) tox64/on Linux before Phase 7. - Deferred to Phase 6: DXGI →
VkFormattable for textures.
Phase 5 – Shader pipeline (HLSL → SPIR-V)
- Keep HLSL; DXC
-spirv -fspv-target-env=vulkan1.3. - Port the compiler from
ShaderCompilation.cppto DXC's LinuxWinAdapter(CComPtr,libdxcompiler.so); make it backend-aware instead of hardcodingdirect3d12. - Bindings:
-fvk-{b,t,u,s}-shiftforregister(xN, space0);-fvk-bind-resource-heap/-fvk-bind-sampler-heapfor SM6.6ResourceDescriptorHeap[...](requiresVK_EXT_mutable_descriptor_type, supported by RADV). - Drop
-Qstrip_reflect/-Qstrip_debugfor SPIR-V; DXC gives no shader hash for SPIR-V, so compute our own forpack_compiled_shader. - Add
graphics_platform::vulkan+shaders/vulkan/shaders.bin. - Validate all modules with
spirv-val. - Consider moving
Direct3D12/Shaders/→Graphics/Shaders/(shared) and checkingSharedTypes.hlayouts under SPIR-V rules.
Phase 5 – done (2026-11-04)
-
EngineDLL/ShaderCompilation.cpp/.hbuilds on both platforms and is backend-aware:compile_shaders(platform),compile_shader(..., platform); defaultdefault_shader_platform(D3D12 on Windows, Vulkan on Linux), so existing callers (EngineDLL, EngineTest) are unchanged.- Linux: DXC's
libdxcompiler.so+<dxc/dxcapi.h>(WinAdapter.hCOM shim);com_ptr<T>wrapsCComPtr(Windows: WRLComPtr). Logging → stderr;__debugbreak→__builtin_debugtrap. - CMake:
ShaderCompilerstatic library (PIC, linksdxcompiler). On Windows the.vcxprojfiles keep compiling the.cppdirectly.TestRenderer.cppstill#includes the.cpp; switch it to the library on Linux in Phase 7.
- Linux: DXC's
-
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, soSharedTypes.hstructs match on both backends. Vulkan device needsscalarBlockLayout.-enable-16bit-types: device needsshaderFloat16/shaderInt16and 16-bit storage features.- Root constants (
b1ShaderParamsetc. 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::vectorrelocated items withrealloc/memmove/memcpy. That breaks types that point into themselves, which in libstdc++ includesstd::string/std::wstringandstd::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 (andvector<T, false>/free_list) keeps bitwise relocation.free_list<noexcept_map>(ContentToEngine shader groups): thestd::unordered_mapis now heap-allocated (unique_ptr), becausefree_listmust relocate bitwise.- The compiled-shader blobs were never freed (a
ComPtrbuilt fromDetach()adds a reference); nowAttach()ed.
-
Tested on Linux with a scratch driver linked to
ShaderCompiler:compile_shaders(vulkan)writesshaders.bin(4 modules),compile_shader()builds the 5 TestShader variants; all 9 modules passspirv-val --target-env vulkan1.3 --scalar-block-layout. -
Not done: moving
Direct3D12/Shaders/to a sharedGraphics/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 (-O3SPIR-V); all 9 modules passspirv-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= defaultbut implicitly deleted (unique_ptrmember; clang-Wdefaulted-function-deleted) → now= delete.
Tooling: .clang-format / .clang-tidy (2026-11-05)
.clang-formatencodes Arash's style: Allman braces (union/namespacestay inline), return type on its own line for top-level definitions,{ 1, 2 }braced lists with spaces, 4 spaces, no namespace indent,T* p(alsoT* const p; clang-format can't keep Arash'sT *const pmix),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) andreadability-identifier-namingfor the current snake_case convention (_memberfor private / protected,UPPER_CASEmacros, 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 ofVK_KHR_xlib_surface/VK_KHR_wayland_surfaceexist. Debug:VK_LAYER_KHRONOS_validationwith 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=0turns 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 ofd3d12_command):frame_buffer_count(3) command pools/buffers, one timeline semaphore used like the D3D12 fence (fence_valueper frame), a binary "image acquired" semaphore per frame.flush()waits for all frames andvkQueueWaitIdle(see lessons). Eachrender_surface()is one frame, like D3D12. - Deferred release:
core::deferred_release(handle)(typed,detail::object_type<T>()), same frame counting as D3D12. - Surfaces:
vulkan_surfacecreates theVkSurfaceKHRfromnative_window_handle(xlib / wayland; editor constraint 1), swapchain withB8G8R8A8_SRGB(fallbackR8G8B8A8_SRGB, else first), 3 images, FIFO with vsync, mailbox → immediate → FIFO without. Per-image present semaphores. Recreated when the window size, the vsync option orVK_ERROR_OUT_OF_DATE/SUBOPTIMALsay so; skipped while minimized (extent 0). Wayland's0xFFFFFFFFextent → 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()ignoresframe_infoand clears with dynamic rendering (pulsing color per surface), sync2 barriersUNDEFINED → COLOR_ATTACHMENT → PRESENT_SRC. Lights/cameras/resources entries of theplatform_interfacestay 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.cppknowTEST_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
dlcloseshim), exit 0. Wayland vsync: ~145 fps (144 Hz) for 4 windows; XWayland: ~76. - Not verified: interactive keys (no xdotool here) — run the
SURFACEStest 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()=vkCmdFillBufferofvalues[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 inprocess_deferred_releases(). Shutdown order: modules → constant buffers → deferred releases → heap → deferred releases → samplers → allocator → device. - Milestone b scaffolding (
core::scratchinVulkanCore.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 likegpass::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. TheSURFACEStest looks the same as in milestone a. - For milestone e: the D3D12 gpass uses
ExecuteIndirectwith a command signature that changes root CBVs/SRVs per draw. Push descriptors can't change insidevkCmdDrawIndexedIndirect. Options: record a CPU loop of push descriptors +vkCmdDrawIndexed(the commands are built on the CPU anyway), orVK_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-allclean (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 thedlcloseshim reports 256 bytes perVkInstancein 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.propsinclude path, andVK_KHR_push_descriptoron the Windows AMD driver. Visual check of theSURFACEStest 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 inengine_shaderorder. A missingshaders/vulkan/shaders.binis logged instead of asserting. - Pipeline helpers (
vkx):rasterizer_state/depth_state/blend_statepresets with thed3dxnames 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 haveFrontCounterClockwise = 1, so the Vulkan presets useVK_FRONT_FACE_COUNTER_CLOCKWISE(the negative height makes the framebuffer winding match).d3dx::blend_state.premultipliedhasBlendEnable = 0(probably an upstream bug); copied as is, with a note. - GPass (milestone c part): main buffer
R16G16B16A16_SFLOAT+ depthD32_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 fromUNDEFINED(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 indepth_read=READ_ONLY_OPTIMAL(changed fromDEPTH_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 ofd3d12_frame_info) +get_vulkan_frame_info()writesGlobalShaderDatato 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_colorspaceis enabled when the loader has it), elseB8G8R8A8_SRGB/R8G8B8A8_SRGB. KDE Wayland offers FP16 scRGB; XWayland givesB8G8R8A8_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.hcallscompile_shaders(graphics_platform::vulkan)beforegraphics::initialize()(only recompiles when sources changed). CMake linksShaderCompilerfor theSURFACEStest; on Windows the definitions come fromTestRenderer.cpp, whichEngineTest.vcxprojalways compiles. - Verified (Linux): Debug / Release / Debug+ASan build clean;
-Wall -Wextra -Wshadow-alland clang-tidy clean on the Vulkan files (apart frommissing-field-initializerson 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 uncaughtstd::filesystem_errorwhen the shader source folder (../../Engine/Graphics/Direct3D12/Shaders/) doesn't exist, e.g. when the executable runs from another directory →std::terminate. Should use theerror_codeoverloads 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_contextliked3d12_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), throughcore::submit_to_graphics_queue(). The queue is now behind a mutex (render submits, presents,vkQueueWaitIdleand 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_DSTis 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_bufferper 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_MULTIPLEis 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). OneVkBufferImageCopyper subresource, the blob's row/slice pitch becomebufferRowLength/bufferImageHeight, offsets aligned to lcm(block size, 4). Cube maps getCUBE_COMPATIBLE(the default SRV view is then a cube). Image goesUNDEFINED → TRANSFER_DST → READ_ONLY_OPTIMALinside 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 zeroedgraphics_pipeline_desc(D3D12: CRC of the PSO stream). NoVkPipelineCacheon disk yet (the driver's shader cache covers repeated runs). _mm_popcnt_u32/_BitScanForward→std::popcount/std::countr_zero;alloca→utl::vector.
- Meshes: one
- SPIR-V entry points:
ShaderCompilation.cppnow 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. Deletex64/<config>/shaders/vulkan/shaders.binonce (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) readp[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.binpacks records back to back, so a record'su64size 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.cpphas the same latent bug (reads the file in place; harmless on x86, not fixed).- Brace-init narrowing (
sizeofis 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 perVkInstance.SURFACESunchanged (145 fps).-Wshadow-alland 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.cpploads../../x64/ibl/...but the folder isIBL— 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()fillsGlobalShaderDatafrom 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()) andExecuteIndirect(*_indirect(),DRAW_INDIRECT 1), whose command signature changes root CBVs/SRVs per draw. Vulkan can't change push descriptors insidevkCmdDrawIndexedIndirect(onlyVK_EXT_device_generated_commandscan), so the Vulkan gpass ports the direct path: per render item,vkx::root_descriptorspushes 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 separateutl::vectors instead of D3D12's one packed buffer. Depth prepass: depth-only pipelines, clear to 0 (reversed Z). Main pass: clear to D3D12'sclear_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 neednullDescriptor). - 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_MULTIPLEis 4, so the asset packs positions / elements / indices at 4-byte offsets — fine for D3D12 root SRVs, but Vulkan storage buffer ranges needminStorageBufferOffsetAlignment(16 on NVIDIA). Nowsubmesh::addrepacks while uploading: the asset goes into the staging buffer as is, oneVkBufferCopyper part to offsets aligned tocore::storage_buffer_offset_alignment()(= max(16, the device limit)), and asserts that the 4-byte-aligned part sizes add up tomesh_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) andupload::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_infolikeTestRenderer.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-alland 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 tocore::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 listfragment read → compute write → fragment read; index countercompute → transfer(vkCmdFillBufferclear)→ 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 increate(), removed inrelease()). - Frame:
GlobalShaderDatagetsNumDirectionalLightsand the ambient light from the light set;render_surface()callslight::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.cppfix (Linux): itsrandom(f32 min = 0.f)helper clashed with POSIXlong random(void)from<stdlib.h>("call to 'random' is ambiguous"). Renamed torandom_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.cppunchanged: 2 light sets with 3 directional lights each andRANDOM_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:
textureCompressionBCis 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). NowInterlockedOr()(slots start at 0, so the result is identical). D3D12'sshaders.binrecompiles 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.SURFACESclean 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 inPrimalEditor/Content/Material.cs). No MSVC fixes were needed for b–g./p:PrimalVulkan=false(Engine + EngineTest, separateOutDir/IntDir): clean, 0Vulkan*.obj, the exe has novulkan-1.dllreference. - A3 driver:
VK_KHR_push_descriptor,VK_EXT_mutable_descriptor_type,VK_EXT_swapchain_colorspaceall present. Surface formats with HDR off: R8G8B8A8/B8G8R8A8 UNORM + SRGB, A2B10G10R10 — allSRGB_NONLINEAR, no FP16 scRGB → swapchainformat 50, color space 0(8-bit sRGB fallback, by design). With HDR on: FP16 scRGB (A11, done). - A4
SURFACESon 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_infois reused from thevkCreateInstancechain where itspNextpoints atsettings_info;VulkanCore.cppnow clearspNextbefore 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.cppcompiled the TestShader variants for the OS default (DXIL on Windows) →VUID-VkShaderModuleCreateInfo-pCode-07912and a debug break invkCreateGraphicsPipelines; 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_RENDERERpicture correct (meshes, lights, IBL, sky), F11 OK;TEST_WINDOWAlt+Enter + drag-resize OK;TEST_ENTITY_COMPONENTS21 rounds (~2M entities), no asserts. All exit 0. - How-to: building
EngineTest\EngineTest.vcxprojalone needs/p:SolutionDir=<repo>\(theVulkan.propsimport uses$(SolutionDir)); itsAdditionalLibraryDirectoriesis$(OutDir), so a customOutDirneeds Engine built there first. Test variants:CL/LINKenv vars +/p:IntDir=x64\Debug\TestWindow\ /p:TargetName=EngineTest_Window /p:BuildProjectReferences=false; MSBuild exits 1 from/FORCE:UNRESOLVEDbut the exe is written. Tests are GUI-subsystem: run withStart-Process -Wait -NoNewWindow -RedirectStandardError <file>to get the Vulkan log;TEST_ENTITY_COMPONENTSreadsgetchar()→-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.exeon the machine;msbuild Primal.slnx /t:Restore /p:RestorePackagesConfig=truerestores thepackages.configprojects (DXC, D3D12). - A12.1 build: Debug + Release clean first time. DebugEditor + ReleaseEditor failed in the one file Linux never
parsed:
FbxImporter.cppC2662. The clang-tidy pass made the localFbxContext fbx_contextconst, butget_scene()is non-const, so theconstis removed. After that all 4 configs/t:Rebuild: 0 C++ warnings, 0 errors (only C# CS0649 ×2 inMaterial.cs). No MSVC trouble withEDITOR_INTERFACE auto f() -> T,PRIMAL_NOINLINE, the structured bindings orstd::scoped_lock. - A12.2 test variants: the B5 fix was broken (fixed now). MSBuild escapes
;in a property function's result, so$(PrimalTestDefines.Replace(...))reachedclas one/D "TEST_ENTITY_COMPONENTS=0;TEST_WINDOW=0;..."(C4067 inMain.cpp). The other three macros fell back toTest.h's defaults, so every variant silently built the renderer test. Now four plain conditional properties (PrimalTestEntityComponentsetc.) 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, nowLevel4(all 8 config × variant builds clean).WINDOWgaveLNK4199 /DELAYLOAD:vulkan-1.dll ignored(no graphics in that test), soEngine\Vulkan.propsadds/IGNORE:4199to the link. - A12.3 shaders (T09): a syntax error in
PostProcess.hlslfails 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 leavesshaders.bin/.keyuntouched. (Editing a non-engine.hlslsuch asFillColor.hlslalso 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_COMPONENTS50 rounds (~9.6M entities), no asserts, exit 0.WINDOWfullscreen/windowed/resize, exit 0. Not reproduced: the very first D3D12 run exited0x80000003(STATUS_BREAKPOINT: a debug break, or Retry in the CRT assert dialog with no debugger attached). The next two runs (one under a debugger capturingOutputDebugString, one plain) were clean. Cause unknown; see B10. - A12.5 editor (partial):
PRIMAL_ENGINE(user env var) switched toC:\USERS\SMITT\RIDERPROJECTS\PRIMAL_PLUS\for good (user's choice; it was the oldPrimalrepo). DebugEditor: new project created + loaded, engine view renders (user). FBX import, texture import and primitive mesh work (user; first run of the editedFbxImporter.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) andLanguageStandard 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, notlatest). The script template'supdate(float dt)gave C4100 at/W4→[[maybe_unused]] float dt. After that DebugEditor/ReleaseEditor (DLL) and Debug/Release (exe, linksengine.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.vcxprojLanguageStandardstdcpplatest→stdcpp23(/std:c++23preview). All 4 configs/t:Rebuild: 0 C++ warnings, 0 errors (C# CS0649 ×2 only). - A12.6 / T02
/WX:TreatWarningAsErrorin 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 inTools/if this comes up again. Test variants no longer needCL/LINKenv 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.cppC3615,constexpr auto gpu_id_from_fake_pointer()"cannot result in a constant expression". The cast pass turned its C-style casts intoreinterpret_cast, which MSVC rejects in aconstexprfunction (clang and GCC only complain when it is evaluated at compile time).constexprremoved; 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-editedFbxImporter.cpp/.h,EngineAPI.cpp,D3D12Upload.cpp,PlatformWin32.cpporVector.h. - A14.2:
Common\CommonDefinitions.his inEngine.vcxprojand.filters. - A16.1
UnitTests.vcxproj: builds in Debug and Release first time.DownloadDoctestputdoctest.h(362 930 bytes) inpackages\doctest.2.5.3\; doctest doesn't trip/W4 /WX;engine.liblinks into the console program. - A16.2 run:
x64\Debug\UnitTests.exeandx64\Release\UnitTests.exe: 83 of 83 test cases pass, exit 0 (incl.content::load_gameandcontent::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 thestd::memcpyversions ofutl::free_listandBlobStreamReader/Writerin the editor. - A14.3 script project (MSBuild, no Visual Studio): a copy of the game project the editor created today, plus
a
TestScriptgenerated from theNewScriptDialogtemplate, builds in DebugEditor, ReleaseEditor (DLL), Debug and Release (exe): 0 compiler warnings at/W4. The project force-includesGameEntity.h(now throughCommonHeaders.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 image2026-11-09-bis 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.cppafter theconstexprremoval.
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:
- C4459
MathSimd.h:212(near_equal4()'sepsilonparameter hidesmath::epsilon), as A18.7 predicted. Parameter renamedtolerance. - C3615
ContentToEngine.cppagain: the 2026-11-11 removal ofconstexprfromgpu_id_from_fake_pointer()was never committed and got lost. Removed again. - C4530 in
Log.cpp("C++ exception handler used, but unwind semantics are not enabled"):Engine.vcxprojbuilds the engine without exceptions (Arash's setting; CMake leaves them on), and both MSVC's<chrono>(atryin the time zone database,get_tzdb_list(), in every TU that includes<chrono>) andformat_text()'s owntry/catchneed them. Fix:<chrono>is included with C4530 off (#pragma warning,_MSC_VERonly), and thetryis 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=0for the engine was not chosen: it would change the standard library's classes betweenengine.liband its users.
- C4459
- 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_ALLOCATORSare 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), soEngine\Modules.propsturns C5050 off in every project but the engine.Modules.propsworks otherwise as written: UnitTests, EngineTest (also alone, with/p:SolutionDir) and EngineDLL get the.ifcfiles through theProjectReference. - After the fixes: Debug, Release, DebugEditor, ReleaseEditor: 0 C++ warnings, 0 errors (C# CS0649 ×2 only; the
editor's
DrainLogC# compiles). The 4 EngineTest variants build in Debug and Release.Threading.his gone from the projects without trouble (A23.4),MathSimd.his listed (A18.2). Thevecoperators (A18.1) andXM_CALLCONVneeded 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.hlslfails the build withPostProcess.hlsl(131,1): error …: expected unqualified-idin plain text. (BreakingFillColor.hlsldoes 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 asEngineTest.1.log. Test content loads in 162 ms with 23 workers and ~350 ms withPRIMAL_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; theVisualStudioclass ispartialnow): when Visual Studio's automation server (VisualStudio.DTE.18.0) isn't registered, orPRIMAL_EDITOR_BUILD=msbuild, the editor- adds new scripts by editing the game project's
.vcxproj(and.filtersif there is one) and opens the.cppin VS Code (code.cmdon the PATH; otherwise the program Windows associates with.cpp); - builds the
.slnwith MSBuild (found withvswhere, works with the BuildTools), with the output in the log panel (errors and warnings typed) andPRIMAL_ENGINEpassed 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=vsforces 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).
- adds new scripts by editing the game project's
- 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 withDispatcher.BeginInvokeand 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'sread_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
TestScrwith 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 readsDrainLog); a DLL reload with a script on an entity no longer crashes; the built game (Ctrl+F5) logsbegin_playonce,log_debugevery 120 frames, and after Shift+F5end_play after 663 frames (TestScr.cpp:21)in itsprimal.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=0starts without vsync (EngineTest/RenderItem.cpp,TestRenderer.cpp,test_env_u32()inTest.h). -
Found with it: (1) D3D12's
ExecuteIndirectpath, 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, andallocate()returningnullptrwasn'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 callsConstantBuffer::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) andgpu_address()/range()take no lock. -
D3D12 draws: direct by default (user's choice),
PRIMAL_D3D12_DRAW_INDIRECT=1forExecuteIndirect(replaces theDRAW_INDIRECTdefine). Logged at start-up ("Draws: ..."). -
D3D12 parallel recording (
PRIMAL_D3D12_PARALLEL_RECORDING=0turns it off): above 512 items, jobs record batches into command lists of their own (an allocator per thread and frame,ThreadCommandListsinD3D12Core.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,
UnitTests128/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 reportsVUID-VkShaderModuleCreateInfo-pCode-07912, pipeline creation fails andVkCallbreaks (no debugger: the editor exits). The editor on Windows stays D3D12-only until #35. - A16.4 (missing script), 2026-11-13: passes.
NewProjectTestwith its script renamed toMissingScriptin 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 withEditorUi.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.
EntityScripthaslog_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_SCRIPTstores the name (detail::set_script_type_name<T>(), an index into a table inScript.cpp, soEntityScriptstays 16 bytes: a pointer mademath::vecmembers in scripts padded, MSVC C4324 inEngineTest/Scripts.cpp).GameEntity.hincludesLog.h, solog::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 exportsset_log_forward(Script.cpp,USE_WITH_EDITOR),LoadGameCodeDll()passes it EngineDLL'swrite_forwarded, and the DLL's copy then formats and hands each message over. File names are copied into the receiving log'sState(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), categoryd3d12, text "Debug layer: ... (message )".error()flushes beforeSetBreakOnSeverity()breaks. Unregistered beforeReportLiveDeviceObjects(), 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 anerrorline (message 741).
- Tooling note: building
EngineTest.vcxprojalone (a variant) did not rebuild a changed engine once; buildPrimal.slnxfirst. GUI tests can be closed without the user: postWM_CLOSEto 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
(
PrimalEditorCS0649 onNodeMaterial/CodeMaterial._inputsis pre-existing). - Fixes (Windows-only, the Linux build can't catch them):
Engine/Input/InputWin32.cpptested#ifdef PRIMAL_PLATFORM_WINDOWSbefore any include, so the macro (fromPlatformDetection.h) wasn't defined and the whole file compiled empty → LNK2019 forprocess_input_message,map_virtual_key,modifier_keys. Now includesCommonHeaders.hfirst. (Pre-port it used the compiler's_WIN64.) Rule: any file guarded by aPRIMAL_*macro must includeCommonHeaders.h/PlatformDetection.hbefore the guard.Engine/Utilities/Vector.hreserve():if constexpr (relocate_with_move) { ...; return; }left the realloc path unreachable → C4702 (MSVC only). Nowif constexpr ... else.ContentTools.vcxproj:<Exec Command="CompileShaders">relied on cmd finding the script in the current directory, which fails (9009) whenNoDefaultCurrentDirectoryInExePathis set. Nowcall "$(ProjectDir)CompileShaders.cmd".
- Tests (scripted):
TEST_ENTITY_COMPONENTS(stdinqafter 4 rounds) exits 0.TEST_WINDOW: 4 windows, resize event, quits after the lastWM_CLOSE, exit 0.TEST_RENDERERDebug + Release: 4 render windows, 20 s/15 s without asserts, clean close, exit 0. Note:EngineTest.vcxprojalways 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.DXC1.9.2602.24 has SPIR-V codegen (-spirvoutput passesspirv-val), so Vulkan on Windows step 4 needs no other DXC. LunarG SDK 1.3.290.0 is installed (VULKAN_SDKset; its DXC is 1.8). - Assets: the renderer test assets are already in
x64/(git-ignored; from the 7z linked inx64/dropbox.txt). For Linux, copyx64/*.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.
- 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). - Run
TEST_ENTITY_COMPONENTSandTEST_WINDOW(Test.h): close / resize / Alt+Enter / quit when all windows are closed. - Run
TEST_RENDERERon D3D12 and check it looks the same as before the port (meshes, lights, IBL, F11 restart). - Capture a D3D12 reference frame of the renderer test in RenderDoc (kept for milestones c–g, see Verification).
- 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.DXChas 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 byEngine,EngineTest,EngineDLLand the editor's 4 game project templates (PrimalEditor/Resources/ProjectTemplates/*/MSVCProject, via$(PRIMAL_ENGINE), guarded byExists). It setsPrimalVulkan=truewhenVULKAN_SDKpoints at an SDK (opt out:/p:PrimalVulkan=false), and then adds$(VULKAN_SDK)\Include,PRIMAL_GRAPHICS_VULKAN=1, linksvulkan-1.lib+delayimp.liband delay-loadsvulkan-1.dll(instead of volk): a D3D12 run never loads it (checked), so machines without a loader still start.create_instance()callsLoadLibraryW(L"vulkan-1.dll")first and fails cleanly if it's missing. Since 2026-11-14 (#18): no linking at all; the engine loadsvulkan-1.dlland every function itself (Graphics/Vulkan/VulkanLoader.h), andVulkan.propsonly adds the include path and the defines. Must be imported after the project'sItemDefinitionGroups (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.cppfiles withCondition="'$(PrimalVulkan)' == 'true'"(they aren't guarded in code).TestSurfaces.hinEngineTest.vcxproj.VulkanSurface.cpp:native_window_handle::win32case (vkCreateWin32SurfaceKHR,<vulkan/vulkan_win32.h>).VulkanCommonHeaders.hnow includes<Windows.h>(lean,NOMINMAX) first on Windows:Platform/PlatformTypes.hincludes it withoutNOMINMAX, and themin/maxmacros brokestd::min/maxinVulkanSurface.cpp.- Bug fix (both OSes):
VK_EXT_layer_settingsis 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 withvkEnumerateInstanceExtensionProperties(validation_layer_name, ...). - Verified: all 4 configurations build clean;
/p:PrimalVulkan=falsebuilds 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 inTest.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:
- SDK / build. Install the LunarG Vulkan SDK (headers,
vulkan-1.lib, validation layer, and a DXC with SPIR-V support; it setsVULKAN_SDK).Engine.vcxproj(+ filters): add the 7Graphics/Vulkan/files,$(VULKAN_SDK)\Includeto the include path, linkvulkan-1.libfor the executables (EngineTest, the game,EngineDLL), and definePRIMAL_GRAPHICS_VULKAN=1(PlatformDetection.hdefaults it to Linux only). Option: use volk (load the loader at run time) so machines without the loader can still start with D3D12. - Win32 surface.
VulkanSurface.cppcreate_platform_surface(): add thenative_window_handle::win32case (VkWin32SurfaceCreateInfoKHR { hinstance = (HINSTANCE)native.display, hwnd = (HWND)native.window },vkCreateWin32SurfaceKHR).PlatformWin32.cppalready fills both fields. Include<vulkan/vulkan_win32.h>after<Windows.h>(WIN32_LEAN_AND_MEAN,NOMINMAX) in that file only.VulkanCore.cppalready enablesVK_KHR_win32_surfaceon Windows. - MSVC portability in the backend — done (2026-11-06, from Linux; not compiled with MSVC yet).
VulkanCommonHeaders.h:PRIMAL_VK_DEBUG_BREAK()(__debugbreakon MSVC,__builtin_debugtrapon clang,raise(SIGTRAP)on gcc) andvulkan::log_message(format, ...)(printf-style, format-checked on clang/gcc; defined inVulkanCore.cpp), which writes tostderrand, on Windows, also toOutputDebugStringAbecause aWinMainprocess has no console. All backend output goes through it — use it (notfprintf) in new Vulkan code.use_validation()uses_dupenv_son MSVC (std::getenvraises C4996).VulkanCore.cppincludes<Windows.h>(lean,NOMINMAX) on Windows forOutputDebugStringA. - Shaders.
compile_shaders(graphics_platform::vulkan)already writesshaders/vulkan/shaders.binon any OS, and the NuGetMicrosoft.Direct3D.DXC1.9.2602.24 has SPIR-V codegen (checked 2026-11-06). The SPIR-V hash path doesn't depend on DXC. - Choosing the backend.
TestRenderer.cppandEngineDLL/EngineAPI.cpphardcodegraphics_platform::direct3d12. Make it a choice (command line / env var / editor setting); the shader paths per backend are already inRenderer.cpp. - Window behavior. Nothing to do for the background (
set_has_graphics_surfaceis 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 needVK_EXT_full_screen_exclusive(optional). Editor child windows (HWND) work with the Win32 surface as-is. - 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. - Verify. Run the
SURFACEStest (addTestSurfaces.htoEngineTest.vcxproj, setTEST_SURFACES 1inTest.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.hincludes<wrl.h>(Windows). It's only needed fortools::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
- Backend selection ("Vulkan on Windows" step 5):
TestRenderer.cpp:252andEngineDLL/EngineAPI.cpp:172hardcodegraphics_platform::direct3d12. Default per OS (default_shader_platforminShaderCompilation.halready does this: D3D12 on Windows, Vulkan on Linux) with an override, e.g. env varPRIMAL_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()inEngineDLL/ShaderCompilation.h/.cppreadsPRIMAL_GRAPHICS(vulkan/d3d12; unknown values → stderr + default;_dupenv_son MSVC), elsedefault_shader_platform. Used byTestRenderer.cppandEngineAPI.cpp(compile_shaders(platform)+graphics::initialize(platform)) and byRenderItem.cppfor the TestShader material variants (those were compiled for the OS default → DXIL handed to Vulkan on Windows). On Linux it lives in theShaderCompilerlibrary with the rest ofShaderCompilation.cpp(step 3). Not yet built on Linux. - Shader-compile retry: keep the
MessageBoxretry on Windows (#if PRIMAL_PLATFORM_WINDOWS), stderr + fail on Linux. - Shader compiler linkage: on Linux link the
ShaderCompilerlibrary forTEST_RENDERER(EngineTest/CMakeLists.txt already links it forSURFACES; extend the condition) and only#include "ShaderCompilation.cpp"on Windows (EngineTest.vcxprojdoesn't compile it separately). KeepTestSurfaces.hworking on both (Windows gets the definitions fromTestRenderer.cpp). RenderItem.cpp: replace theContentTools/Geometry.hinclude (moveelements_typesomewhere engine-side both can include, or use the values directly like the drivers do);_countof→std::size; fix theIBL/Set4path case.- 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_scriptinScripts.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,dlcloseshim), Release fps, F11 restart, resize, Alt+Enter, close windows → exit 0, X11 and Wayland. - Windows: same test with
PRIMAL_GRAPHICS=vulkanandd3d12; RenderDoc capture of both (same frame) and compare (Open items A7). Done 2026-11-08 (user). - EngineDLL (editor path):
EngineAPI.cppbackend 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.cppkeeps theMessageBoxretry under#if PRIMAL_PLATFORM_WINDOWS; elsewhere stderr +return false. - Step 3:
EngineTest/CMakeLists.txtlinksShaderCompilerforRENDERERas well asSURFACES;TestRenderer.cpponly#includesShaderCompilation.cppon Windows (EngineTest.vcxprojdoesn't compile it). - Step 4:
RenderItem.cppno longer includesContentTools/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,dlcloseshim): 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
counterset-but-unused inengine_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_NONLINEARwhile Windows HDR is off, so Vulkan on Windows getsB8G8R8A8_SRGBthere (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=0turns 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(settinggpuav_enable; the olderVK_LAYER_VALIDATE_GPU_BASEDis 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_PRELOADa shim whosedlclose()returns 0 so LSan can symbolize them (see the Steps doc).Tools/CI/ci.sh sanitizersdoes this for the graphics tests (Tools/CI/noclose.c,Tools/CI/lsan.supp). GraphicsTests(since 2026-11-10):x64/<Config>/GraphicsTestsruns the window, surface and scene test cases on the session's display and GPU;xvfb-run -aruns 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
.vcxprojbuild 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
.vcxprojfiles usestdcpp23(=/std:c++23preview, v145; confirmed 2026-11-09 in the toolset'scl.xml). - Commits: the user commits manually; never commit on their behalf.
- Licensing: this is Charles Smith's fork, still MIT.
LICENSEkeeps Arash Khatami's notice and addsCopyright (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.