Skip to content

Finish the module split: HEngine.Runtime, HEngine.Rendering.D3D12, no more Core - #125

Merged
eXoz00rd merged 16 commits into
masterfrom
claude/nastepne-zadanie-cgrms5
Sep 14, 2026
Merged

eXoz00rd merged 16 commits into
masterfrom
claude/nastepne-zadanie-cgrms5

Conversation

@eXoz00rd

@eXoz00rd eXoz00rd commented Sep 11, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Completes the ten-module target from ADR 0001. HEngine.Core is gone, its contents distributed to the modules that own them, and the last two modules — HEngine.Runtime and HEngine.Rendering.D3D12 — now exist.
  • Reverses the dependency that made the split impossible: it was Rendering → Core, it is now Runtime → Rendering. Settings moved to their owning modules (Z4), so AddHEngineRendering takes what it needs rather than the whole EngineConfiguration.
  • HEngine.Rendering declares no Silk.NET package at all. The Direct3D 12 device, swap chain, command lists, PSO/shader managers and concrete renderers live in HEngine.Rendering.D3D12, and the host alone picks the backend (Z8).
  • Texture loading no longer leaks Silk.NET.DXGI.Format — it reports a neutral TextureFormat the backend maps at the GPU boundary.
  • The boundary is machine-enforced, not documented: HEngine.Architecture.Tests now fails if a backend-agnostic module declares a Silk.NET package or if HEngine.Runtime names a backend.
  • Fixes the intermittent CI hang that was costing six-hour runner slots on this branch and on master, and two memory-safety defects in the shader path.

Also removes the numeric PR size rule (≤400 lines / ≤15 files) from CONTRIBUTING.md, AGENTS.md and the backlog-task skill, per the request that prompted this work.

Test plan

  • dotnet build HEngine.slnx in Debug and Release — 0 warnings, 0 errors

  • dotnet test HEngine.slnx — ten of eleven projects fully green without a GPU:

    Foundation 19 · Platform 2 · ECS 103 · Assets 49 · Scene 105
    Serialization 33 · Platform.Windows 24 · Rendering 232
    Runtime 8 · Architecture 21
    Rendering.D3D12   109 passed, 31 failed (no d3d12.dll on this machine)
    

    Every remaining failure is confined to HEngine.Rendering.D3D12.Tests, the one project the repo's convention allows to require Windows and DirectX 12. At the start of this branch the equivalent failures were spread across three projects, two of which were meant to be portable.

  • HEngine.Portable.slnf builds clean, pulls in zero D3D12 projects, and its whole test set passes here without a GPU. That is the split doing its job, checked rather than asserted.

  • HEngine.Rendering.Tests is 232/232 green without a GPU, up from 25 failures.

  • HEngine.Runtime.Tests is 8/8 green without a GPU. It briefly required DirectX 12 because the composition tests asserted on concrete D3D12 types; those moved to the backend's own test project.

  • HEngine.Architecture.Tests 21/21, including the new backend-independence checks. It also had a pre-existing defect: it parsed \-separated MSBuild paths, so all ten of its tests failed on any non-Windows machine while passing in CI.

  • CI hang fixed and measured. Repeated full-solution runs, the loaded case CI reproduces: 3/15 and 2/20 hangs before, 0/30 after.

  • Shader files verified to land in the output of every project that composes the backend, and correctly not in HEngine.Rendering.Tests.

  • The frame-order assertion was mutation-checked: reversing UpdateInput() and RenderFrame() in GameLoop makes it fail.

  • Not verified visually, and two fixes are not runtime-verified. This environment has no GPU and no Windows, so the demo scene was never rendered. The render path is reorganised rather than rewritten — no pass, shader or draw call changed behaviour. The two shader memory-safety fixes below are reasoned and compile-verified but never executed; DirectX12MeshShaderManager has no test coverage at all, since constructing an ID3D10Blob needs the real compiler. Both deserve a look on Windows before merge.

Three defects this PR introduced, all caught by review and fixed

Shader directory. Moving Shaders/ into the new module nested it at Shaders/Shaders/, so the copy item matched nothing and no project received the .hlsl files; six composition tests failed with DirectoryNotFoundException. It could not reproduce on Linux because the item spelled its path Shaders\*.hlsl, and a backslash is an ordinary filename character outside Windows. Now Content with a forward-slash path.

Backend leaking into the agnostic layer. AddHEngineRendering resolved IShadowRenderer with GetRequiredService, but only AddHEngineRenderingD3D12 registers it — so any composition without the backend failed even with shadows disabled, contradicting this PR's own claim. It is optional now; RenderPipeline still fails loudly when shadows are enabled without a renderer.

Broken solution filter. HEngine.Portable.slnf still listed HEngine.Core, HEngine.Core.Tests and HEngine.Core.Benchmarks after they were deleted or renamed, so the filter could not restore. Nothing caught it because the architecture tests only read HEngine.slnx. It now lists the modules that build without the backend.

Pre-existing defects fixed here

The CI hang. HEngine.Assets.Tests intermittently hung its test host until the six-hour Actions timeout, on this branch and on master alike (run 34582792393, commit 013719e). The cause was in the test: LoadMeshAsync_AfterUnloadAllDuringInFlightLoad_StartsFreshLoad assumed its first call had already consumed load attempt 1, but the loader runs via Task.Run, so which attempt executes first is threadpool scheduling rather than call order. When the fresh load won that race it took attempt 1, blocked on a gate the test only opens later, and deadlocked. The loader now signals when the first load is genuinely in flight and the test waits for it. CI also gains timeout-minutes, so a recurrence fails in twenty minutes rather than consuming a runner for six hours.

AssetManager separately published a Lazy evaluated outside _cacheLock, so a pending load could be observed before it had started; it starts under the lock now. That change alone did not fix the hang — measured at 2/20 against a 3/15 baseline — and is kept on its own merits.

Shader macros were unpinned before use. ShaderVariantCompiler assigned its fixed pointer to an outer variable and let the block exit, so the macro array was free to move before the pointer reached the native compiler. Now pinned across the Compile call.

Compiled shaders were released twice. DirectX12MeshShaderManager handed the same ComPtr to its active-variant fields and to the variant cache, which stores it without taking a reference and releases it on Dispose, Clear and Remove. A cache hit in SetVariant released the outgoing shader while it stayed cached — a use-after-free on switching back. The cache owns the blobs and the fields borrow the active one, so the field disposes are gone.

Notes for review

Namespaces follow ADR 0002: moved files keep their existing HEngine.Rendering.* / HEngine.Core.* namespaces, so physical module and namespace still disagree in places. Only genuinely new code got a new namespace, and it uses Direct3D12, not D3D12 — ADR 0009 records why the obvious name does not compile (Silk.NET exports a type called D3D12, which any such namespace shadows across the whole assembly).

Known pre-existing problems found while working here and deliberately not fixed, both verified against master:

  • TextureManager never uploads pixel data. There is no UpdateSubresources, CopyTextureRegion or WriteToSubresource anywhere in the backend, and no barrier out of CopyDest, so every GPU texture is sampled uninitialized and in an invalid state. PixelData is read by nothing outside tests.
  • MeshAssetLoadingSystem is never registered, so MeshAsset components stay NotLoaded at runtime. Deferred by the author.
  • README.md still describes the old Core-centric layout; DirectX12Device creates its own window instead of receiving one from HEngine.Platform; GameTime reads the system clock internally, which Z6 forbids.

Closes #121
Closes #122
Closes #123
Closes #124
Closes #126

MSBuild ProjectReference paths use backslash separators, which are ordinary
filename characters outside Windows, so every module name resolved to the whole
relative path and all ten tests failed on Linux.
Its only consumers are RenderPipeline and ShadowRenderingSystem, and PSSM
cascade math is shadow mapping rather than general-purpose geometry.

Closes #122
…ependency

HEngine.Core was two things at once: the composition root and a dumping ground
for types every other module needed. Splitting it lets the dependency arrow run
the way the target architecture describes, Runtime -> Rendering rather than
Rendering -> Core.

- GameLoop, GameTime, IGameLoop, EngineConfiguration and the DI entry point
  become HEngine.Runtime; AddHEngineCore is now AddHEngineRuntime
- IRenderManager and IRenderPipeline move into Rendering, where the only
  implementations live
- Settings move to the module that owns them: rendering, PBR, shadow and
  post-processing into Rendering, window into Platform, so AddHEngineRendering
  takes what it needs instead of the whole aggregate
- Transform2D moves to Scene, QueryComponentExtensions to ECS
- HEngine.Core.Tests dissolves into the suites for the modules that now own its
  cases; composition coverage becomes HEngine.Runtime.Tests, which also gains
  GameTime tests; HEngine.Core.Benchmarks becomes HEngine.ECS.Benchmarks
- Solution layers renumbered so the dependency direction test sees the new shape

Closes #121
Closes #123
HEngine.Rendering was a backend-agnostic name over an assembly that referenced
Silk.NET.Direct3D12 directly, so headless was a claim rather than a capability.

- HEngine.Rendering.D3D12 takes the device, swap chain, command lists, PSO and
  shader managers, the concrete renderers and the Silk.NET input state
- HEngine.Rendering keeps frame orchestration, ECS systems, materials,
  post-process definitions and contracts, and declares no Silk.NET package
- Texture loading no longer returns a DXGI format; it reports a neutral
  TextureFormat that the backend maps at the GPU boundary
- Registration splits in two, so the host picks the backend (Z8):
  AddHEngineRendering composes the domain, AddHEngineRenderingD3D12 the device
- D3D12-dependent tests become HEngine.Rendering.D3D12.Tests, leaving
  HEngine.Rendering.Tests green without a GPU
- HEngine.Architecture.Tests now fails the build if a backend-agnostic module
  declares a Silk.NET package or Runtime names a backend

New code in the backend uses the Direct3D12 namespace segment; ADR 0009 records
why D3D12 cannot be used there.

Closes #124
Copilot AI lite review requested due to automatic review settings September 11, 2026 19:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical shader deployment, shader ownership, and macro pinning defects remain, alongside runtime test coverage and portability gaps.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Completes the module split by removing HEngine.Core, adding HEngine.Runtime and the isolated D3D12 backend, and updating composition, tests, architecture checks, and documentation.

Changes:

  • Adds runtime configuration, game loop, and dependency-injection composition.
  • Separates backend-agnostic rendering from D3D12 implementations and shaders.
  • Introduces neutral texture formats and updates projects, tests, benchmarks, and architecture enforcement.
File summaries
File Review summary
Tests/HEngine.Scene.Tests/Components/Transform/Transform2DTests.cs Covers moved Transform2D behavior.
Tests/HEngine.Runtime.Tests/Time/GameTimeTests.cs Tests runtime timing; the clamp assertion is not deterministic. Moderate: use a controlled clock or stalled frame.
Tests/HEngine.Runtime.Tests/HEngine.Runtime.Tests.csproj Adds runtime test project references.
Tests/HEngine.Runtime.Tests/CompositionTests.cs Tests runtime composition. Moderate: concrete D3D12 registration makes these tests platform-dependent.
Tests/HEngine.Rendering.Tests/Shadows/ShadowUtilsTests.cs Covers backend-agnostic shadow utilities.
Tests/HEngine.Rendering.Tests/RenderPipelineTests.cs Updates render pipeline tests and settings usage.
Tests/HEngine.Rendering.Tests/HEngine.Rendering.Tests.csproj Removes the Core dependency from rendering tests.
Tests/HEngine.Rendering.Tests/Assets/TextureLoadResultTests.cs Tests neutral texture load results.
Tests/HEngine.Rendering.Tests/Assets/TextureLoaderTests.cs Tests backend-neutral texture loading.
Tests/HEngine.Rendering.D3D12.Tests/Renderers/PBRMeshRendererTests.cs Covers the D3D12 PBR mesh renderer.
Tests/HEngine.Rendering.D3D12.Tests/Renderers/DirectX12ShadowRendererTests.cs Covers the D3D12 shadow renderer.
Tests/HEngine.Rendering.D3D12.Tests/Renderers/DirectX12MeshRendererTests.cs Covers the D3D12 mesh renderer.
Tests/HEngine.Rendering.D3D12.Tests/Managers/ShadowManagerTests.cs Covers D3D12 shadow management.
Tests/HEngine.Rendering.D3D12.Tests/Managers/RenderTargetManagerTests.cs Covers D3D12 render-target management.
Tests/HEngine.Rendering.D3D12.Tests/Managers/MaterialManagerTextureTests.cs Covers material texture management.
Tests/HEngine.Rendering.D3D12.Tests/HEngine.Rendering.D3D12.Tests.csproj Adds the D3D12 test project.
Tests/HEngine.Rendering.D3D12.Tests/Devices/DescriptorHeapManagerTests.cs Covers descriptor heap management.
Tests/HEngine.Rendering.D3D12.Tests/Assets/TextureManagerTests.cs Covers GPU texture management.
Tests/HEngine.Rendering.D3D12.Tests/Assets/TextureManagerMipmapTests.cs Covers texture mipmap handling.
Tests/HEngine.Core.Tests/Rendering/MeshRenderingSystemTests.cs Removes the obsolete Core rendering test.
Tests/HEngine.Architecture.Tests/ProjectFileTests.cs Updates project-file architecture checks.
Tests/HEngine.Architecture.Tests/HEngine.Architecture.Tests.csproj Updates architecture test references.
Tests/HEngine.Architecture.Tests/DependencyDirectionTests.cs Validates the new dependency direction.
Tests/HEngine.Architecture.Tests/BackendIndependenceTests.cs Enforces backend independence for agnostic modules.
Src/Runtime/HEngine.Runtime/Time/GameTime.cs Moves runtime timing implementation.
Src/Runtime/HEngine.Runtime/Time/GameLoop.cs Adds the runtime frame loop. Moderate: focused loop tests are missing.
Src/Runtime/HEngine.Runtime/HEngine.Runtime.csproj Adds the Runtime project.
Src/Runtime/HEngine.Runtime/Extensions/ServiceCollectionExtensions.cs Registers runtime services.
Src/Runtime/HEngine.Runtime/Contracts/IGameLoop.cs Defines the game-loop contract.
Src/Runtime/HEngine.Runtime/Configuration/EngineConfiguration.cs Adds runtime engine configuration.
Src/Rendering/HEngine.Rendering/Systems/ShadowRenderingSystem.cs Moves the backend-agnostic shadow system.
Src/Rendering/HEngine.Rendering/Shadows/ShadowUtils.cs Moves shadow utility logic.
Src/Rendering/HEngine.Rendering/RenderPipeline.cs Updates the rendering pipeline.
Src/Rendering/HEngine.Rendering/Managers/RenderManager.cs Updates render-manager configuration.
Src/Rendering/HEngine.Rendering/HEngine.Rendering.csproj Removes backend-specific dependencies from rendering.
Src/Rendering/HEngine.Rendering/Factories/RenderContextFactory.cs Maintains the rendering context factory contract.
Src/Rendering/HEngine.Rendering/Extensions/ServiceCollectionExtensions.cs Registers backend-agnostic rendering services.
Src/Rendering/HEngine.Rendering/Contracts/IRenderPipeline.cs Defines the render-pipeline contract.
Src/Rendering/HEngine.Rendering/Contracts/IRenderManager.cs Defines the render-manager contract.
Src/Rendering/HEngine.Rendering/Configuration/RenderingSettings.cs Moves rendering settings.
Src/Rendering/HEngine.Rendering/Assets/TextureLoadResult.cs Removes DXGI format leakage.
Src/Rendering/HEngine.Rendering/Assets/TextureLoader.cs Uses neutral texture formats.
Src/Rendering/HEngine.Rendering/Assets/TextureFormat.cs Adds the neutral texture format enum.
Src/Rendering/HEngine.Rendering.D3D12/TextureFormatMapping.cs Maps neutral formats to D3D12 formats.
Src/Rendering/HEngine.Rendering.D3D12/Systems/SilkDirectX12Renderer.cs Adds the D3D12 renderer system.
Src/Rendering/HEngine.Rendering.D3D12/SilkRenderContextFactory.cs Adds the D3D12 render-context factory.
Src/Rendering/HEngine.Rendering.D3D12/SilkRenderContext.cs Implements the D3D12 render context.
Src/Rendering/HEngine.Rendering.D3D12/Shaders/Shaders/ToneMapping.hlsl Adds the tone-mapping shader.
Src/Rendering/HEngine.Rendering.D3D12/Shaders/Shaders/Sprite.hlsl Adds the sprite shader.
Src/Rendering/HEngine.Rendering.D3D12/Shaders/Shaders/ShadowPass.hlsl Adds the shadow-pass shader.
Src/Rendering/HEngine.Rendering.D3D12/Shaders/Shaders/PostProcessBlit.hlsl Adds the post-process blit shader.
Src/Rendering/HEngine.Rendering.D3D12/Shaders/Shaders/Mesh.hlsl Adds the mesh shader.
Src/Rendering/HEngine.Rendering.D3D12/Shaders/Shaders/FXAA.hlsl Adds the FXAA shader.
Src/Rendering/HEngine.Rendering.D3D12/Shaders/Shaders/Bloom.hlsl Adds the bloom shader.
Src/Rendering/HEngine.Rendering.D3D12/Renderers/DirectX12ShadowRenderer.cs Adds the D3D12 shadow renderer.
Src/Rendering/HEngine.Rendering.D3D12/Managers/TextureManager.cs Manages D3D12 textures.
Src/Rendering/HEngine.Rendering.D3D12/Managers/ShadowPipelineStateManager.cs Manages shadow pipeline state.
Src/Rendering/HEngine.Rendering.D3D12/Managers/ShadowMapManager.cs Manages shadow maps.
Src/Rendering/HEngine.Rendering.D3D12/Managers/ShaderVariantCompiler.cs Compiles shader variants. Critical: the macro array is unpinned during native compilation.
Src/Rendering/HEngine.Rendering.D3D12/Managers/ShaderVariantCache.cs Caches compiled shader variants.
Src/Rendering/HEngine.Rendering.D3D12/Managers/ShaderDiskCache.cs Provides disk-backed shader caching.
Src/Rendering/HEngine.Rendering.D3D12/Managers/DirectX12ShaderManager.cs Manages D3D12 shaders.
Src/Rendering/HEngine.Rendering.D3D12/Managers/DirectX12PipelineStateManager.cs Manages D3D12 pipeline states.
Src/Rendering/HEngine.Rendering.D3D12/Managers/DirectX12MeshShaderManager.cs Manages mesh shader variants. Critical: cached and active ComPtr ownership can release the same shader pointer.
Src/Rendering/HEngine.Rendering.D3D12/Managers/DirectX12BufferManager.cs Manages D3D12 buffers.
Src/Rendering/HEngine.Rendering.D3D12/Input/SilkCameraInputProvider.cs Adds the D3D12 camera input provider.
Src/Rendering/HEngine.Rendering.D3D12/Input/InputState.cs Defines backend input state.
Src/Rendering/HEngine.Rendering.D3D12/HEngine.Rendering.D3D12.csproj Defines the D3D12 backend. Critical: shader assets are globbed from the wrong directory and are not copied to output.
Src/Rendering/HEngine.Rendering.D3D12/Extensions/ServiceCollectionExtensions.cs Registers D3D12 backend services.
Src/Rendering/HEngine.Rendering.D3D12/DirectX12/UploadRingBuffer.cs Implements upload-ring buffering.
Src/Rendering/HEngine.Rendering.D3D12/DirectX12/DirectX12Core.cs Provides D3D12 core setup.
Src/Rendering/HEngine.Rendering.D3D12/DirectX12/DirectX12CommandQueue.cs Implements the D3D12 command queue.
Src/Rendering/HEngine.Rendering.D3D12/DirectX12/DirectX12CommandList.cs Implements D3D12 command lists.
Src/Rendering/HEngine.Rendering.D3D12/Devices/DescriptorHeapManager.cs Manages D3D12 descriptor heaps.
Src/Rendering/HEngine.Rendering.D3D12/Contracts/IDirectX12SpriteRenderer.cs Defines the D3D12 sprite renderer contract.
Src/Rendering/HEngine.Rendering.D3D12/Contracts/IDirectX12ShaderManager.cs Defines the D3D12 shader manager contract.
Src/Rendering/HEngine.Rendering.D3D12/Contracts/IDirectX12Device.cs Defines the D3D12 device contract.
Src/Rendering/HEngine.Rendering.D3D12/Adapters/DirectX12ShaderManagerAdapter.cs Adapts the D3D12 shader manager.
Src/Rendering/HEngine.Rendering.D3D12/Adapters/DirectX12CommandQueueAdapter.cs Adapts the D3D12 command queue.
Src/Core/HEngine.Scene/Components/Transform/Transform2D.cs Moves the scene transform component.
Src/Core/HEngine.Platform/Configuration/WindowSettings.cs Adds platform window settings.
Src/Core/HEngine.ECS/QueryComponentExtensions.cs Moves ECS query helpers.
Src/Core/HEngine.ECS/GlobalUsings.cs Updates ECS global usings.
Src/Core/HEngine.Core/HEngine.Core.csproj Removes the Core project.
Src/Core/HEngine.Core/GlobalUsings.cs Removes Core global usings.
HEngine/Program.cs Updates application startup.
HEngine/HEngine.csproj Updates application project references.
HEngine/GameEngine.cs Wires runtime and D3D12 composition.
HEngine/DemoScene.cs Updates demo scene configuration.
HEngine/Builders/EngineBuilder.cs Adds runtime/backend composition.
HEngine.slnx Updates the solution module layout.
docs/adr/README.md Registers the new ADR.
docs/adr/0009-d3d12-namespace-avoids-silk-collision.md Documents the D3D12 namespace decision.
docs/adr/0001-ten-runtime-modules.md Records completion of the module extraction.
CONTRIBUTING.md Removes the numeric PR size rule.
Benchmarks/HEngine.ECS.Benchmarks/Systems/TransformHierarchyBenchmarks.cs Updates hierarchy benchmarks.
Benchmarks/HEngine.ECS.Benchmarks/Queries/ComponentQueryBenchmarks.cs Updates query benchmarks.
Benchmarks/HEngine.ECS.Benchmarks/HEngine.ECS.Benchmarks.csproj Retargets benchmark references.
AGENTS.md Updates repository guidance. Nit: remove the AI attribution footer from the PR body.
.github/skills/code-review/SKILL.md Updates review guidance.
.github/skills/backlog-task/SKILL.md Removes the PR size rule.
.github/copilot-instructions.md Updates architecture guidance.
Review details

Suppressed comments (4)

AGENTS.md:109

  • The PR body still ends with a _Generated by Claude Code_ attribution, which contradicts the repository rule in AGENTS.md that forbids AI self-attribution in PR bodies. Please remove that footer before merge.
- Keep pull requests small and focused on one coherent change.

Src/Runtime/HEngine.Runtime/Time/GameLoop.cs:8

  • The moved GameLoop is the runtime entry point, but HEngine.Runtime.Tests contains no GameLoopTests; only GameTimeTests and composition tests are present. This leaves the new frame execution order, Stop behavior, and exception shutdown path unverified even though the runtime module is being introduced. Add focused tests with substituted manager/pipeline dependencies before relying on this split's test coverage.
    Tests/HEngine.Runtime.Tests/CompositionTests.cs:31
  • Registering the concrete D3D12 backend here makes the Runtime test project resolve DirectX12Device, shader managers, and other Silk.NET services. That makes these composition tests require Windows/DirectX 12 even though the repository convention says only HEngine.Rendering.D3D12.Tests has that requirement; keep backend-specific composition checks in the backend test project or use backend-agnostic fakes so HEngine.Runtime.Tests remains portable.
    Tests/HEngine.Runtime.Tests/Time/GameTimeTests.cs:36
  • This test never creates a stalled frame: it calls Update() immediately after construction, so DeltaTime will normally already be below 0.1 seconds and the assertion passes even if the clamp at GameTime.Update is removed. Use a controllable clock or another deterministic setup that actually crosses the clamp threshold; otherwise this test does not cover the behavior its name claims.
  • Files reviewed: 59/113 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Moving Shaders/ into the new module nested it one level too deep, at
Shaders/Shaders/, so the copy item matched nothing and no project received the
.hlsl files. Composition then failed at ShaderFileLoader with a missing shader
directory, which CI caught in HEngine.Runtime.Tests.

The glob also spelled its path with a backslash, which is an ordinary filename
character outside Windows, so the files could never be copied on Linux and the
breakage could not reproduce there. Declaring the shaders as Content with a
forward-slash path fixes both, and makes them flow to every project that
composes the backend.
Copilot AI review requested due to automatic review settings September 12, 2026 19:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Five critical and one moderate finding remain unresolved and block approval.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (2)

Src/Rendering/HEngine.Rendering.D3D12/Managers/TextureManager.cs:277

  • The resource descriptor is created with multiple mip levels and CopyDest, but this backend never copies loadResult.PixelData (including its mip chain) into the resource or transitions it to a shader-readable state before HasGpuResource becomes true. Consequently default and loaded textures are sampled as GPU-backed by the PBR renderer while containing undefined data; upload through a staging/copy command list and synchronize the transition before exposing the resource.
    Src/Rendering/HEngine.Rendering/Extensions/ServiceCollectionExtensions.cs:55
  • Resolving this newly registered pipeline also constructs ShadowRenderingSystem, whose factory above unconditionally resolves IShadowRenderer; that service is registered only by AddHEngineRenderingD3D12. Any headless or non-D3D12 composition with shadows disabled therefore fails at pipeline resolution instead of using the existing HasShadowRenderer/ShadowSettings.Enabled guard. Make that factory resolve the renderer optionally and let the pipeline reject only configurations that actually enable shadows.
  • Files reviewed: 59/113 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread HEngine/GameEngine.cs Resolved
EngineBuilder.Build() dropped the root ServiceProvider, so disposing the engine
left every singleton holding a native resource alive: the D3D12 device and
command queue, the swap chain, render targets, the texture manager and the
shader file watcher. The engine now owns that provider and disposes it during
shutdown.
Copilot AI review requested due to automatic review settings September 14, 2026 10:29

Copy link
Copy Markdown
Owner Author

build-and-test is hanging in HEngine.Assets.Tests, and it is not this PR's

Both runs on this branch were cancelled at exactly 6h00m — the Actions job timeout, not queue time. I misread the first one as a queue delay; it is a genuine hang.

What actually happens. Every test project runs and passes, then the run stops dead. Timestamps from run 2 (34714087766):

19:26:47  HEngine.Runtime.Tests — Test Run Successful (17 passed, 1 skipped)
          ... 357.9 minute gap ...
01:24:43  Attempting to cancel the build...
          MSB4181: The "VSTestTask" task returned false but did not log an error
          Time Elapsed 05:58:06.34

The gap sits between HEngine.Runtime.Tests completing and HEngine.Assets.Tests — its VSTest host starts and never exits.

It reproduces on master. Run 34582792393, commit 013719e ([Assets] Identify assets by a stable id instead of file path, #116), predates this branch entirely and fails identically: a 355-minute gap, cancelled at ~6h, and HEngine.Assets.Tests is the one project that never reaches Finished: — Foundation, ECS, Scene, Serialization, Platform, Core, Platform.Windows and Rendering all complete. So this is the Assets suite hanging its test host, not the module split.

It is intermittent: master run 34630654673 on 8e86840 (this PR's base) was green in ~2 minutes.

Not fixed here, deliberately. It is in HEngine.Assets, which this PR does not touch, and no fix exists to port. Widening the PR to chase it would bury the split. I could not reproduce it on Linux either — 25 consecutive HEngine.Assets.Tests runs passed, so it looks Windows-specific or much rarer here, and I have no Windows machine to bisect on.

Worth noting it blocks master too whenever it fires, so it deserves its own issue rather than riding along with this one. The suspect worth checking first is AssetManager.LoadMeshAsync: it hands a Lazy<Task<object>> out of a lock (_cacheLock) and completes it from Task.Run inside LoadAssetInternalAsync, which re-takes _cacheLock. A test whose injected Func<string, Task<LoadedMesh>> never completes, or a race on PendingLoad, would hang the host exactly this way.

Both review findings on this PR are fixed and pushed: the nested shader directory (33abb4c) and the undisposed root ServiceProvider (a196727). Tests on the current head: 692 passing, with 31 failing only because this machine has no d3d12.dll.


Generated by Claude Code

Copy link
Copy Markdown
Owner Author

Correction to my comment above: I said the hang was not reproducible on Linux. That was wrong — it was a sample-size problem. Re-running the suite 25 times in a row produced one hang (run 20), killed by a 90-second timeout after emitting no test results at all, where a healthy run finishes in ~0.9s with Passed! 49.

So it is not Windows-specific, it reproduces at roughly 1 in 25 anywhere, and the host wedges very early in the run rather than on a late test. Filed as #126 with the reproducer; the conclusion that it predates this branch and lives in HEngine.Assets is unchanged.


Generated by Claude Code

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Eight unresolved findings remain, including four critical correctness and resource-lifetime issues.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (1)

Src/Rendering/HEngine.Rendering.D3D12/Managers/TextureManager.cs:274

  • The GPU resource path is still incomplete: after this format is used to create a CopyDest texture, no code copies loadResult.PixelData into it or transitions it to PixelShaderResource before the SRV is used. The demo/material textures therefore remain uninitialized and are sampled in an invalid D3D12 state; complete the upload and state transition before publishing the resource.
  • Files reviewed: 59/113 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread HEngine/Builders/EngineBuilder.cs Resolved
GameEngine's constructor runs Initialize(), which sets up the device and
shaders and can throw. The provider was only handed over after a successful
resolve, so a startup failure leaked every disposable singleton created up to
that point.
Copilot AI review requested due to automatic review settings September 14, 2026 10:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

One or more issues must be addressed before approval.

Review details

Suppressed comments (3)

AGENTS.md:46

  • This new repository guidance contradicts the checked-in host project, which still sets <PublishAot>true</PublishAot> in HEngine/HEngine.csproj:5. Remove the Native AOT claim here or remove the project setting so contributors are not given inaccurate build expectations.
.NET 10 throughout. Everything except the Direct3D 12 backend builds and tests anywhere; `HEngine.Rendering.D3D12.Tests` needs Windows and a DirectX 12 GPU. There is no `Samples/` directory and no Native AOT configuration.

Src/Rendering/HEngine.Rendering/Extensions/ServiceCollectionExtensions.cs:18

  • AddHEngineRendering is now the backend-agnostic composition boundary, but its ShadowRenderingSystem factory unconditionally resolves IShadowRenderer. A headless or alternate backend with shadows disabled therefore still fails when RenderPipeline is resolved, even though both the system and the pipeline explicitly support a missing renderer when shadows are off. Resolve the renderer optionally and retain the existing RenderPipeline validation so a missing renderer still fails when shadows are enabled.
    Tests/HEngine.Runtime.Tests/HEngine.Runtime.Tests.csproj:32
  • This project reference makes the supposedly backend-independent Runtime test project load the Direct3D 12 backend for every composition test. Those tests resolve IShadowRenderer, whose constructor calls D3D12.GetApi(), so HEngine.Runtime.Tests fails on non-Windows/no-GPU hosts even though the repository convention is that only HEngine.Rendering.D3D12.Tests is backend-dependent. Keep Runtime.Tests backend-free and move the D3D12 production-composition assertions to the backend test project, or compose the runtime tests with fakes.
  • Files reviewed: 59/113 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

- AddHEngineRendering resolved IShadowRenderer as required, so any composition
  without the D3D12 backend failed even with shadows disabled. It is optional
  now; RenderPipeline still rejects shadows enabled without a renderer.
- Composition tests asserted on concrete D3D12 types, which made
  HEngine.Runtime.Tests need Windows and a GPU. They move to the backend's own
  test project, leaving Runtime.Tests portable.
- GameLoop had no tests: frame order, Stop, and the exception shutdown path are
  covered now.
- The stall-clamp test passed even with the clamp deleted; it now stalls a frame
  and asserts the clamped value.
- AGENTS.md claimed there is no Native AOT configuration while the host sets
  PublishAot.
- AssetManager published a Lazy evaluated outside _cacheLock, so a pending load
  could be observed before it had started. It starts under the lock now.
LoadMeshAsync_AfterUnloadAllDuringInFlightLoad_StartsFreshLoad assumed the
first call had already consumed load attempt 1, but the loader is invoked from
Task.Run, so which attempt runs first is down to threadpool scheduling. When the
fresh load won that race it took attempt 1, blocked on a gate the test only
opens afterwards, and deadlocked the test host.

The loader now signals when the first load is actually in flight and the test
waits for it before unloading, which is the precondition its name claims.

Hang rate on repeated full-solution runs: 3/15 and 2/20 before, 0/30 after.

Refs #126
Copilot AI review requested due to automatic review settings September 14, 2026 11:25

Copy link
Copy Markdown
Owner Author

CI hang fixed in this PR, plus the review findings I had missed

I was wrong twice above and both are worth correcting on the record.

First: I said the comments were all handled. They were not. I only checked posted review threads (four, all resolved) and missed that Copilot puts most findings in the "Suppressed comments" sections inside review bodies. Several were mine. Now addressed in 69ceedf:

  • AddHEngineRendering resolved IShadowRenderer with GetRequiredService, but only AddHEngineRenderingD3D12 registers it. Any composition without the backend therefore failed even with shadows disabled — which directly contradicts this PR's own claim that the layer is backend-agnostic. It is GetService now; RenderPipeline still fails loudly when shadows are enabled without a renderer, which is the behaviour that was actually intended.
  • The composition tests asserted on concrete D3D12 types, which made HEngine.Runtime.Tests require Windows and a GPU. They moved to the backend's own test project, and HEngine.Runtime.Tests dropped its HEngine.Rendering.D3D12 reference.
  • GameLoop shipped with no tests. Frame order, Stop, and the exception shutdown path are covered now.
  • The stall-clamp test passed even with the clamp deleted. It stalls a frame and asserts the clamped value.
  • AGENTS.md claimed there is no Native AOT configuration while HEngine/HEngine.csproj:5 sets PublishAot. Corrected.

Second: my first attempt at the CI hang did not work. I changed AssetManager to start loads eagerly under _cacheLock and reported that as the fix. Measured, it was not: 2 hangs in 20 runs against a 3-in-15 baseline — noise, not a fix. The eager start is a genuine improvement (_pendingLoads now only contains loads that really started, which is what Unload/UnloadAll/IsLoading assume) so it stays, but it was not the cause.

The actual cause is in the test. LoadMeshAsync_AfterUnloadAllDuringInFlightLoad_StartsFreshLoad assumes its first call has already consumed load attempt 1 — but the loader runs via Task.Run, so which attempt executes first is threadpool scheduling, not call order. When the fresh load won that race it took attempt 1, blocked on a gate the test only opens several lines later, and deadlocked the host. No production change can make that assumption hold; the loader is asynchronous by design. Fixed in 79edb38 by having the loader signal when the first load is genuinely in flight and making the test wait for it — the precondition its own name claims.

Measured on repeated full-solution runs, which is the loaded case CI reproduces:

hangs
before 3 / 15, then 2 / 20
after 0 / 30

Test results now — ten of eleven projects fully green without a GPU:

Foundation 19 · Platform 2 · ECS 103 · Assets 49 · Scene 105
Serialization 33 · Platform.Windows 24 · Rendering 232
Runtime 8 · Architecture 21
Rendering.D3D12  100 passed, 31 failed  (no d3d12.dll on this machine)

Every remaining failure is confined to HEngine.Rendering.D3D12.Tests, which is the one project the repo's convention says may require Windows and DirectX 12. Before this round those failures were spread across three projects, including ones that were supposed to be portable.

Still outstanding and not fixed here, both pre-existing and verified against master: the missing texture upload in TextureManager (no UpdateSubresources/CopyTextureRegion anywhere in the backend, and no barrier out of CopyDest, so textures are sampled uninitialized), and MeshAssetLoadingSystem never being registered, which you have deferred deliberately.


Generated by Claude Code

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Critical shader lifetime and compilation defects, plus moderate initialization and shadow-count issues, remain unresolved.

Review details

Suppressed comments (1)

Tests/HEngine.Runtime.Tests/Time/GameLoopTests.cs:41

  • These assertions only verify that both calls occurred; they do not enforce the ordering promised by the test name and required by the frame contract. A regression that renders before pumping input would still pass. Replace the two independent Received checks with an ordered Received.InOrder assertion for UpdateInput() followed by RenderFrame().
  • Files reviewed: 62/116 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

The test is named for input being pumped before rendering, but two independent
Received checks pass regardless of order. Verified by reversing the two calls in
GameLoop: the ordered assertion fails, the previous one did not.
Shader macros were unpinned before use. The fixed block assigned its pointer to
an outer variable and then exited, so the array was free to move before the
pointer reached the native compiler. The array is now pinned across the Compile
call; a fixed statement over a null array yields a null pointer, which is the
wanted behaviour when no defines are set.

Compiled shaders were released twice. DirectX12MeshShaderManager handed the same
ComPtr to both its active-variant fields and the variant cache, which stores it
without taking a reference and releases it on Dispose, Clear and Remove. Every
field Dispose therefore released a pointer the cache still owned, and a cache hit
in SetVariant released the outgoing shader while it remained cached. The cache is
the owner and the fields borrow the active variant, so the field disposes are
gone; the catch path still disposes shaders that never reached the cache.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

One or more issues must be addressed before approval.

Review details

Suppressed comments (5)

HEngine.slnx:25

  • The deleted Core projects are still listed by HEngine.Portable.slnf, including the old Core benchmark and test paths. After this split, building that solution filter resolves missing files and fails; update the filter to the renamed ECS/Rendering/Runtime projects before removing Core.
  <Folder Name="/5-Composition/">
    <Project Path="Src/Runtime/HEngine.Runtime/HEngine.Runtime.csproj" />
  </Folder>

Src/Rendering/HEngine.Rendering.D3D12/Managers/DirectX12MeshShaderManager.cs:205

  • ComPtr is a copyable wrapper, not an ownership clone, so this caches the same COM pointers held by _vertexShader and _pixelShader without an additional reference. SetVariant and Reload dispose those active fields/cache entries before reusing them, leaving cached variants pointing at released blobs and allowing a switch back to bind freed shader bytecode. Give the cache independent COM ownership or make activation transfer ownership explicitly.
    Src/Rendering/HEngine.Rendering.D3D12/Managers/ShaderVariantCompiler.cs:83
  • The macro array is pinned only until this block exits, but macrosPtr is passed to the native compiler afterward. A GC during Compile can move the managed array, so every variant with defines (including the mesh path) can read invalid macro memory; keep the native call inside the fixed scope or otherwise pin the array for the entire call.
    Src/Rendering/HEngine.Rendering.D3D12/TextureFormatMapping.cs:16
  • This new boundary conversion is untested: the current texture tests stop at neutral TextureFormat, while TextureManager depends on this switch to create DXGI resources. Add a backend unit test covering every supported enum value and Unknown, so a mapping typo cannot reach GPU initialization unnoticed.
    Tests/HEngine.Assets.Tests/Assets/AssetManagerTests.cs:220
  • The linked asset-hang task also requires a CI timeout, but .github/workflows/ci.yml still runs the full test job without timeout-minutes. If the race recurs, the runner can again be consumed for six hours despite this test fix; add a bounded job or test-step timeout.
  • Files reviewed: 64/116 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copy link
Copy Markdown
Owner Author

The two "critical shader" findings were real — fixed in e3542d0

I had been reading only the posted threads and the suppressed-comment lists, and treating the review headline as noise. It was not: "critical shader lifetime and compilation defects" pointed at two genuine memory-safety bugs that had been sitting in the file-summary table since the first review. Both verified by reading the code.

1. Shader macros were unpinned before the native call. ShaderVariantCompiler.CompileShader:

if (macros != null)
{
    fixed (D3DShaderMacro* macroPtr = macros)
    {
        macrosPtr = macroPtr;      // pointer escapes the fixed scope
    }
}                                  // array unpinned here
...
_compiler.Compile(..., macrosPtr, ...);   // used after unpinning

A fixed block pins only for its own scope. The pointer was stashed in an outer variable, the block exited, and the array became movable before the pointer reached D3DCompile. Any GC between those two points hands the native compiler a dangling pointer — non-deterministic wrong defines or a crash, and only on the path where defines exist.

Fixed by pinning across the call: macros joins the existing fixed chain. A fixed statement over a null array yields a null pointer, which is exactly the wanted behaviour when there are no defines, so the conditional disappears.

2. Compiled shaders were released twice. DirectX12MeshShaderManager.LoadAndCompileShaders assigns the same ComPtr to both the active-variant fields and the variant cache:

_vertexShader = newVertexShader;
_pixelShader  = newPixelShader;
_variantCache.AddVariant(variant, newVertexShader, newPixelShader);

ShaderVariantCache.AddVariant stores the pointer without taking a reference, and releases it from Dispose, Clear and RemoveVariant. One AddRef, two Releases. Worse than a leak: SetVariant's cache-hit path did

_vertexShader.Dispose();                       // releases a shader the cache still owns
_vertexShader = compiledVariant.VertexShader;  // borrows another one the cache owns

so switching variants released a cached shader that remained reachable — a use-after-free the next time that variant was selected.

The code's own structure settles the ownership question: the cache outlives individual variant switches and disposes what it holds, so the cache owns the blobs and the fields borrow the active one. All three field-level disposes are gone. The catch path still disposes the freshly compiled shaders, because those never reached the cache.

Verification, stated honestly. Both fixes are compile-verified and the full suite is unchanged — ten of eleven projects green, with the same 31 failures confined to HEngine.Rendering.D3D12.Tests for want of d3d12.dll. Neither fix is runtime-verified: this environment has no GPU, and there is no test coverage for DirectX12MeshShaderManager at all, since constructing an ID3D10Blob needs the real compiler. The pinning fix is a language-semantics correction and I am confident in it. The refcount fix rests on reading the ownership model rather than observing it, so it deserves a look on Windows — the failure mode it removes is precisely the kind that only shows up under variant switching with shader reload.

Still not addressed, deliberately: the missing texture upload in TextureManager, and MeshAssetLoadingSystem never being registered.


Generated by Claude Code

Copilot AI review requested due to automatic review settings September 14, 2026 11:52
HEngine.Portable.slnf still listed HEngine.Core, HEngine.Core.Tests and
HEngine.Core.Benchmarks, all removed or renamed by this split, so the filter
could not restore. It now lists the modules that build without the Direct3D 12
backend; verified to build clean and to pull in no D3D12 project, and its whole
test set passes here without a GPU.

TextureFormatMapping was introduced without tests even though TextureManager
depends on it to create DXGI resources. Covered per value, including Unknown,
plus guards that every declared format has a mapping and that two formats cannot
collide on one DXGI format.

CI gains timeout-minutes so a future test-host hang fails in twenty minutes
rather than consuming a six-hour runner slot, which is the remaining item from
issue #126's definition of done.

Copy link
Copy Markdown
Owner Author

Three more from the latest review, including a build I had broken (70425f9)

The review on c8b12ff carried five suppressed findings. Two were the shader defects already fixed in e3542d0. The other three were new, all valid.

HEngine.Portable.slnf was broken by this PR. It still listed HEngine.Core, HEngine.Core.Tests and HEngine.Core.Benchmarks — one deleted, one deleted, one renamed. The filter could not even restore. I deleted those projects and never checked what referenced them outside the solution file; the architecture tests only read HEngine.slnx, so nothing caught it.

It now lists the modules that build without the Direct3D 12 backend, which after this split is a much larger set than before. Verified two ways:

dotnet build HEngine.Portable.slnf -c Release   →  0 errors, 0 warnings
grep -c "HEngine.Rendering.D3D12" (verbose build) →  0
dotnet test  HEngine.Portable.slnf              →  no failing project

The second line is the one worth noting: the portable filter now pulls in zero D3D12 projects and its entire test set passes here without a GPU. That is the module split doing the job it was for, checked rather than asserted.

TextureFormatMapping had no tests. I introduced that file and TextureManager depends on its switch to create DXGI resources, so a typo would have reached GPU initialisation unnoticed while the neutral-format tests stayed green. Now covered per value including Unknown, plus two guards: every declared format must map to something other than FormatUnknown, and two formats must not collide on one DXGI format — so adding a TextureFormat member without a mapping fails the build rather than silently degrading.

CI had no timeout-minutes. Fair catch, and it is the outstanding item from #126's definition of done, which this PR closes. The job now caps at 20 minutes; a healthy run takes about two. If the Assets race ever recurs it fails in twenty minutes instead of consuming a six-hour runner slot.

Test results on this head — the same ten of eleven projects green, with HEngine.Rendering.D3D12.Tests at 109 passing (up 9, the new mapping tests) and the same 31 failures for want of d3d12.dll.


Generated by Claude Code

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

D3D12 lifetime fixes remain unresolved, and the requested documentation and CI safeguards are incomplete.

Review details

Suppressed comments (2)

Src/Rendering/HEngine.Rendering.D3D12/Managers/DirectX12MeshShaderManager.cs:118

  • These assignments only copy the ComPtr value; they do not create an independent COM reference. The same blobs are owned by _variantCache, and Reload() clears that cache before recompiling, so a cache disposal (especially when recompilation fails) can leave _vertexShader/_pixelShader dangling while the renderer still relies on them. Give the active shader handles independent ownership, or redesign the cache/active-variant lifetime so cached cleanup cannot invalidate the active pair.
    Tests/HEngine.Assets.Tests/Assets/AssetManagerTests.cs:205
  • Closing #126 still misses two of its explicit safeguards: .github/workflows/ci.yml has no timeout-minutes, and the reported stress evidence is 30 full-solution runs rather than at least 50 consecutive HEngine.Assets.Tests runs. Add the timeout and run the required suite-specific stress test before considering this issue complete.
  • Files reviewed: 67/119 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 14, 2026 12:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

One or more issues must be addressed before approval.

Review details

Suppressed comments (3)

.github/copilot-instructions.md:20

  • This guidance now contradicts the module boundary established by the PR: the agnostic rendering module owns rendering contracts, and HEngine.Core no longer exists as the contract owner. Leaving the next bullet as “Contracts belong in Core” will direct future changes toward restoring the dependency this split removed; update it to describe domain-owned contracts.
- Backend-agnostic modules must stay platform-agnostic and must not depend on rendering APIs; only `HEngine.Rendering.D3D12` and `HEngine.Platform.Windows` may name Silk.NET
- Contracts belong in Core, implementations belong in Rendering

.github/skills/code-review/SKILL.md:52

  • This review guidance still says that contracts belong in Core, which contradicts the module split and the repository's updated architecture rule that contracts live with their owning domain. Future reviews could therefore reject the intended HEngine.Rendering contract placement or reintroduce a removed Core dependency; update this bullet.
- Backend-agnostic modules must remain free of graphics API references; only `HEngine.Rendering.D3D12` and `HEngine.Platform.Windows` may name Silk.NET.
- Contracts belong in Core; rendering implementations belong in Rendering.

Src/Rendering/HEngine.Rendering/Extensions/ServiceCollectionExtensions.cs:18

  • PostProcessingSettings is accepted and registered here, but the runtime never consumes it: GameEngine.Initialize still creates an unconfigured ToneMappingEffect, and no production code reads EnableBloom, ToneMapping, Exposure, or Gamma. Custom EngineConfiguration values therefore have no observable effect; apply this settings object when building the PostProcessStack (and wire the analogous PbrSettings values) instead of only registering them.
  • Files reviewed: 67/119 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Both agent guidance files still told future changes to put contracts in Core,
which this split removed. Following that rule would rebuild the Rendering to
Core dependency the PR exists to reverse.
Copilot AI review requested due to automatic review settings September 14, 2026 12:41

Copy link
Copy Markdown
Owner Author

Latest review: two fixed (f9e3930), one left as pre-existing

Both agent guidance files still pointed contracts at Core. .github/copilot-instructions.md:20 and .github/skills/code-review/SKILL.md:52 both read "Contracts belong in Core" — a rule that, followed, would rebuild the Rendering → Core dependency this PR exists to reverse. I had edited the bullet directly above each of them and missed the one below. Both now say contracts belong to the module that owns the domain, with backend implementations in HEngine.Rendering.D3D12 or HEngine.Platform.Windows, matching the AGENTS.md wording. Checked that no other file still carries the old rule.

PostProcessingSettings is registered but never read — pre-existing, not folded in. The finding is correct: GameEngine.Initialize creates a bare ToneMappingEffect, and nothing in production reads EnableBloom, ToneMapping, Exposure or Gamma, so custom EngineConfiguration values have no observable effect. But this is not something the split introduced:

$ git show 8e86840:Src/Rendering/HEngine.Rendering/Extensions/ServiceCollectionExtensions.cs | grep PostProcessing
74:        services.AddSingleton(config.PostProcessing);

master registers the same object and reads it in exactly as many places: none. My change made the parameter explicit rather than pulling it off the aggregate, which makes the dead configuration easier to see, but it neither created nor widened it.

Wiring it up means constructing the PostProcessStack from configuration and giving ToneMappingEffect its parameters — a behaviour change in the render path, which is the one thing I cannot verify in this environment. It belongs with the same group as MeshAssetLoadingSystem: real, worth doing, and needing eyes on actual output. Same for the PbrSettings half of the finding.

That is the third instance of the same pattern in this PR's review — configuration or a subsystem that exists, is registered, is tested, and never reaches the screen. AGENTS.md §1 names it as the repository's defining hazard, and it is holding up well as a description.

CI on the previous head 70425f9: build-and-test green in 2m21s, copilot-pull-request-reviewer green.


Generated by Claude Code

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Unresolved critical resource-lifetime and descriptor/draw-safety issues block approval.

Review details

Suppressed comments (5)

HEngine/Builders/EngineBuilder.cs:30

  • Passing PostProcessingSettings here only registers the object; no runtime consumer applies it. GameEngine still adds a default ToneMappingEffect, so configured tone-mapping mode, exposure, gamma, and bloom settings are silently ignored. Apply the settings when constructing the post-processing stack, or remove them from the active engine configuration until they are supported.
        _services.AddHEngineRendering(
            _configuration.Rendering, _configuration.PBR, _configuration.Shadow, _configuration.PostProcessing);

HEngine/HEngine.csproj:12

  • Issue #124's definition of done requires the demo scene to be verified visually, but the PR description explicitly says no Windows/D3D12 render was performed and still closes #124. Because this PR rewires the production GPU composition, please run the demo on a DirectX 12 host and record the result before merging.
      <ProjectReference Include="..\Src\Rendering\HEngine.Rendering\HEngine.Rendering.csproj" />
      <ProjectReference Include="..\Src\Rendering\HEngine.Rendering.D3D12\HEngine.Rendering.D3D12.csproj" />
      <ProjectReference Include="..\Src\Runtime\HEngine.Runtime\HEngine.Runtime.csproj" />

Src/Rendering/HEngine.Rendering.D3D12/Managers/DirectX12MeshShaderManager.cs:119

  • SetVariant assigns the cache's ComPtr values directly to the active shader fields. Those fields are only borrowed, so any later ShaderVariantCache.Clear()/RemoveVariant() can release the same blobs while the active fields still expose them; a subsequent pipeline rebuild can then dereference freed shader bytecode. Give active fields an independent COM reference, or make cache eviction defer disposal until the active variant is replaced and no rebuild is using it.
    Src/Rendering/HEngine.Rendering/Extensions/ServiceCollectionExtensions.cs:18
  • This split relocates the files but leaves IRenderManager and IRenderPipeline declared in HEngine.Core.Rendering.Contracts (for example, IRenderManager.cs:3), so the contracts still expose the removed Core namespace. That does not meet issue #121's explicit namespace requirement (HEngine.Rendering.Contracts) even though this PR closes #121; either rename the contracts and consumers here or leave the issue open/follow it up separately.
    Tests/HEngine.Assets.Tests/Assets/AssetManagerTests.cs:220
  • The PR description reports 0/30 stress runs, but issue #126 explicitly requires at least 50 consecutive HEngine.Assets.Tests executions. Since this PR closes #126, please complete and report the required 50-run stress check before treating the issue as done.
  • Files reviewed: 67/119 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Making the cache the owner left the other direction open: Reload calls
ShaderVariantCache.Clear(), which releases every cached blob including the one
the active fields point at, and only then recompiles. A compile error during
hot reload -- the ordinary case while editing a shader -- left those fields
referencing freed bytecode instead of being reassigned.

The fields are cleared with the cache, so a failed reload leaves them null
rather than dangling.
Copilot AI review requested due to automatic review settings September 14, 2026 13:05

Copy link
Copy Markdown
Owner Author

Latest review: two fixed, one measured, two need your call

Three of the five findings were about promises I made in my own issue Definition of Done sections, which is a fair thing to be held to.

Fixed: the shader lifetime hole my own fix left open (f42801a)

The finding is right and I under-solved this yesterday. Making the cache the owner closed one direction and opened the other. Reload() does:

_variantCache.Clear();                     // releases every cached blob, including the active one
LoadAndCompileShaders(_currentVariant);    // reassigns the fields — unless it throws

So after Clear() the active fields point at released blobs, and if the recompile throws — a shader compile error during hot reload, which is the ordinary case while editing a shader — they stay that way. _isInitialized = false signals trouble but the dangling pointers remain readable through VertexShader/PixelShader.

The fields are now cleared together with the cache, so a failed reload leaves them null rather than dangling. RemoveVariant is the same hazard in principle but has no callers; noting it rather than redesigning around it.

Measured: #126's 50-run requirement

Correct, I reported 30 and the Definition of Done I wrote asks for at least 50. Run properly:

55 consecutive HEngine.Assets.Tests executions → 0 hangs

Together with the earlier full-solution numbers (3/15 and 2/20 before, 0/30 after), the requirement is met rather than approximated.

Not folded in: PostProcessingSettings still unconsumed

Raised again, still pre-existing — master registers the same object and reads it in as many places as this branch does, namely none. Answered in full here.

Two that are your call, because both touch what this PR claims to close

#121 and the contract namespace. The finding is accurate: IRenderManager and IRenderPipeline moved into HEngine.Rendering but still declare HEngine.Core.Rendering.Contracts, while the Definition of Done I wrote for #121 specified HEngine.Rendering.Contracts. That DoD contradicts ADR 0002, which says extraction moves files and leaves namespaces alone, with unification tracked as separate per-module work. I wrote the DoD before weighing that ADR properly.

I measured the rename: 10 declaring files, 43 importing files, and no type name occurs in both namespaces, so merging them is safe from the ambiguity ADR 0002 warns about. It is mechanical and fully compiler-checked — but it is 53 more files on a PR that already touches 119, and it is precisely the follow-up ADR 0002 defers.

Either is defensible: do it here and satisfy the DoD, or drop Closes #121 and let it ride as the ADR-0002 namespace task now that boundaries have stopped moving. I have not guessed.

#124 and visual verification. Also accurate. #124's Definition of Done includes "Demo scene verified visually", this PR closes #124, and I cannot render anything here — no GPU, no Windows. The PR body carries that as an unchecked box, but auto-closing the issue on merge would mark it done with that criterion unverified.

Your call whether to merge and close on the strength of a green CI plus your own look at the demo, or to drop Closes #124 until someone has actually seen it draw.

CI on f9e3930: build-and-test green in 2m15s, reviewer green. Local suite unchanged — ten of eleven projects green, 31 failures confined to HEngine.Rendering.D3D12.Tests for want of d3d12.dll.


Generated by Claude Code

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Unresolved critical and moderate findings, plus unverified Windows/GPU behavior, prevent safe automated approval.

Review details

Suppressed comments (2)

Src/Rendering/HEngine.Rendering.D3D12/Extensions/ServiceCollectionExtensions.cs:67

  • This registration makes the XML documentation on DirectX12PostProcessCommandContext stale: it still says the type is not registered in DI or called by RenderPipeline, while this backend now registers it and RenderPipeline invokes it. Update or remove that claim so the backend's post-processing wiring is not misdiagnosed during future changes.
    Src/Runtime/HEngine.Runtime/Extensions/ServiceCollectionExtensions.cs:19
  • This new runtime composition never registers the serialization module: HEngine.Serialization.Extensions.AddHEngineSerialization is not called, and HEngine.Runtime.csproj does not reference HEngine.Serialization. Consequently a service resolved from the runtime graph cannot obtain SceneSerializer or ComponentSerializerRegistry, despite Runtime being the composition module. Add the project reference and register the serialization services here.
  • Files reviewed: 67/119 changed files
  • Comments generated: 1
  • Review effort level: Lite

Its documentation said the type was not registered in DI and not called from
RenderPipeline. The backend registers it and the pipeline resolves it, so the
comment misdescribed the wiring it sits next to.
Copilot AI review requested due to automatic review settings September 14, 2026 13:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Two unresolved findings remain: one critical failing test and one moderate D3D12 shader-compilation defect.

Review details
  • Files reviewed: 68/119 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copy link
Copy Markdown
Owner Author

Status on the review findings that have no thread

Several findings arrived only as suppressed comments inside review bodies, so there is nowhere to reply inline. Answering them here so none is silently dropped.

Fixed since they were raised

Finding Where
Shader macro array unpinned during native compilation ShaderVariantCompiler — the Compile call is now inside fixed (D3DShaderMacro* macrosPtr = macros), verified by re-read
Cached and active ComPtr releasing the same shader blob DirectX12MeshShaderManager — the cache owns the blobs, the active fields borrow; Reload() clears the fields when it empties the cache (f42801a)
TextureFormatMapping untested Tests/HEngine.Rendering.D3D12.Tests/TextureFormatMappingTests.cs — per-value mapping, Unknown, plus a total-coverage test so a new enum member cannot reach the GPU as FormatUnknown, and an injectivity test
No timeout-minutes on the test job .github/workflows/ci.yml — 20 minutes
HEngine.Runtime.Tests pulling in the D3D12 backend Its .csproj now references only HEngine.Runtime
GameLoop ordering not asserted GameLoopTests uses Received.InOrder; mutation-checked by reversing the two calls
GameTime clamp assertion not deterministic Rewritten around a real stalled frame
"Contracts belong in Core" guidance Corrected in .github/copilot-instructions.md and .github/skills/code-review/SKILL.md
Native AOT claim in AGENTS.md Now states the host sets PublishAot but nothing publishes it
AI attribution footer in the PR body Removed

The latest review headline

Review 5198344609 on 9a1e2fb reports "one critical failing test and one moderate D3D12 shader-compilation defect" but posted 0 comments and no suppressed entries, so there is no location to work from. What can be checked:

  • Failing test. build-and-test is green on 9a1e2fb (windows-latest, 2m18s), which is the only authority on this. Nothing is failing in CI.
  • Shader-compilation defect. Both previously named defects in that path are fixed above. I re-read ShaderVariantCompiler and the DirectX12MeshShaderManager/ShaderVariantCache ownership end to end looking for a third; the remaining rough edge is that DirectX12MeshRenderer.Initialize constructs its own ShaderFileLoader and ShaderDiskCache instead of taking the DI singletons — but it owns those instances, so disposal is correct, and that predates this PR.

Verified pre-existing, deliberately not fixed here

  • PostProcessingSettings and PbrSettings are registered but never read. No production code reads EnableBloom, ToneMapping, Exposure or Gamma from the settings object; GameEngine.Initialize still adds an unconfigured ToneMappingEffect. The only Exposure/Gamma writes in the tree are on DirectX12PostProcessCommandContext's own pending constants. This PR moved the settings to their owning module (Z4); it did not add or remove a consumer.
  • Serialization is registered by no composition. AddHEngineSerialization exists and is called from nowhere — not by AddHEngineRuntime, and not by EngineBuilder. It was equally uncalled on master (HEngine.Core.csproj never referenced HEngine.Serialization), so SceneSerializer and ComponentSerializerRegistry have never been resolvable from the engine graph.

Both are the kind of gap AGENTS.md §6 names, and both are the author's call rather than a mechanical fold-in to a module split.

Two decisions still open for the author

  • Closes #121. The contracts still declare HEngine.Core.Rendering.Contracts, following ADR 0002 (moved files keep their namespaces). Issue [Rendering] IRenderManager and IRenderPipeline contracts live in Core instead of Rendering #121's definition of done asks for HEngine.Rendering.Contracts. The rename measures at 10 declaring files, 43 importing files, zero type-name collisions — cheap, but it contradicts the ADR this PR otherwise follows. Do it here, or drop Closes #121?
  • Closes #124. Its definition of done requires visual verification of the demo scene. This environment has no Windows and no GPU, so that check was never performed and I cannot perform it. Merge on the automated evidence, or drop the auto-close until someone runs it on a DirectX 12 host?

Generated by Claude Code

@eXoz00rd
eXoz00rd merged commit 7f0bcff into master Sep 14, 2026
2 checks passed
@eXoz00rd
eXoz00rd deleted the claude/nastepne-zadanie-cgrms5 branch September 14, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants