Repository navigation
Finish the module split: HEngine.Runtime, HEngine.Rendering.D3D12, no more Core - #125
Conversation
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
There was a problem hiding this comment.
🟡 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 inAGENTS.mdthat 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
GameLoopis the runtime entry point, butHEngine.Runtime.Testscontains noGameLoopTests; onlyGameTimeTestsand composition tests are present. This leaves the new frame execution order,Stopbehavior, 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 onlyHEngine.Rendering.D3D12.Testshas that requirement; keep backend-specific composition checks in the backend test project or use backend-agnostic fakes soHEngine.Runtime.Testsremains portable.
Tests/HEngine.Runtime.Tests/Time/GameTimeTests.cs:36 - This test never creates a stalled frame: it calls
Update()immediately after construction, soDeltaTimewill normally already be below 0.1 seconds and the assertion passes even if the clamp atGameTime.Updateis 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.
There was a problem hiding this comment.
🟡 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 copiesloadResult.PixelData(including its mip chain) into the resource or transitions it to a shader-readable state beforeHasGpuResourcebecomes 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 resolvesIShadowRenderer; that service is registered only byAddHEngineRenderingD3D12. Any headless or non-D3D12 composition with shadows disabled therefore fails at pipeline resolution instead of using the existingHasShadowRenderer/ShadowSettings.Enabledguard. 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
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.
|
|
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 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 Generated by Claude Code |
There was a problem hiding this comment.
🟡 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
CopyDesttexture, no code copiesloadResult.PixelDatainto it or transitions it toPixelShaderResourcebefore 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
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.
There was a problem hiding this comment.
🔵 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>inHEngine/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
AddHEngineRenderingis now the backend-agnostic composition boundary, but itsShadowRenderingSystemfactory unconditionally resolvesIShadowRenderer. A headless or alternate backend with shadows disabled therefore still fails whenRenderPipelineis 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 existingRenderPipelinevalidation 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 callsD3D12.GetApi(), soHEngine.Runtime.Testsfails on non-Windows/no-GPU hosts even though the repository convention is that onlyHEngine.Rendering.D3D12.Testsis 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
CI hang fixed in this PR, plus the review findings I had missedI 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:
Second: my first attempt at the CI hang did not work. I changed The actual cause is in the test. Measured on repeated full-solution runs, which is the loaded case CI reproduces:
Test results now — ten of eleven projects fully green without a GPU: Every remaining failure is confined to Still outstanding and not fixed here, both pre-existing and verified against Generated by Claude Code |
There was a problem hiding this comment.
🔵 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
Receivedchecks with an orderedReceived.InOrderassertion forUpdateInput()followed byRenderFrame().
- 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.
There was a problem hiding this comment.
🔵 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
ComPtris a copyable wrapper, not an ownership clone, so this caches the same COM pointers held by_vertexShaderand_pixelShaderwithout an additional reference.SetVariantandReloaddispose 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
macrosPtris passed to the native compiler afterward. A GC duringCompilecan move the managed array, so every variant with defines (including the mesh path) can read invalid macro memory; keep the native call inside thefixedscope 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, whileTextureManagerdepends on this switch to create DXGI resources. Add a backend unit test covering every supported enum value andUnknown, 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.ymlstill runs the full test job withouttimeout-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
The two "critical shader" findings were real — fixed in e3542d0I 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. if (macros != null)
{
fixed (D3DShaderMacro* macroPtr = macros)
{
macrosPtr = macroPtr; // pointer escapes the fixed scope
}
} // array unpinned here
...
_compiler.Compile(..., macrosPtr, ...); // used after unpinningA Fixed by pinning across the call: 2. Compiled shaders were released twice. _vertexShader = newVertexShader;
_pixelShader = newPixelShader;
_variantCache.AddVariant(variant, newVertexShader, newPixelShader);
_vertexShader.Dispose(); // releases a shader the cache still owns
_vertexShader = compiledVariant.VertexShader; // borrows another one the cache ownsso 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 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 Still not addressed, deliberately: the missing texture upload in Generated by Claude Code |
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.
Three more from the latest review, including a build I had broken (70425f9)The review on
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: 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.
CI had no Test results on this head — the same ten of eleven projects green, with Generated by Claude Code |
There was a problem hiding this comment.
🔵 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
ComPtrvalue; they do not create an independent COM reference. The same blobs are owned by_variantCache, andReload()clears that cache before recompiling, so a cache disposal (especially when recompilation fails) can leave_vertexShader/_pixelShaderdangling 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.ymlhas notimeout-minutes, and the reported stress evidence is 30 full-solution runs rather than at least 50 consecutiveHEngine.Assets.Testsruns. 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
There was a problem hiding this comment.
🔵 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.Coreno 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.Renderingcontract 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
PostProcessingSettingsis accepted and registered here, but the runtime never consumes it:GameEngine.Initializestill creates an unconfiguredToneMappingEffect, and no production code readsEnableBloom,ToneMapping,Exposure, orGamma. CustomEngineConfigurationvalues therefore have no observable effect; apply this settings object when building thePostProcessStack(and wire the analogousPbrSettingsvalues) 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.
Latest review: two fixed (f9e3930), one left as pre-existingBoth agent guidance files still pointed contracts at Core.
Wiring it up means constructing the 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. CI on the previous head Generated by Claude Code |
There was a problem hiding this comment.
🔵 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
PostProcessingSettingshere only registers the object; no runtime consumer applies it.GameEnginestill adds a defaultToneMappingEffect, 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
SetVariantassigns the cache'sComPtrvalues directly to the active shader fields. Those fields are only borrowed, so any laterShaderVariantCache.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
IRenderManagerandIRenderPipelinedeclared inHEngine.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.Testsexecutions. 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.
Latest review: two fixed, one measured, two need your callThree 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. _variantCache.Clear(); // releases every cached blob, including the active one
LoadAndCompileShaders(_currentVariant); // reassigns the fields — unless it throwsSo after The fields are now cleared together with the cache, so a failed reload leaves them null rather than dangling. Measured: #126's 50-run requirementCorrect, I reported 30 and the Definition of Done I wrote asks for at least 50. Run properly: 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:
|
There was a problem hiding this comment.
🔵 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
DirectX12PostProcessCommandContextstale: it still says the type is not registered in DI or called byRenderPipeline, while this backend now registers it andRenderPipelineinvokes 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.AddHEngineSerializationis not called, andHEngine.Runtime.csprojdoes not referenceHEngine.Serialization. Consequently a service resolved from the runtime graph cannot obtainSceneSerializerorComponentSerializerRegistry, 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.
Status on the review findings that have no threadSeveral 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
The latest review headlineReview 5198344609 on
Verified pre-existing, deliberately not fixed here
Both are the kind of gap Two decisions still open for the author
Generated by Claude Code |
Summary
HEngine.Coreis gone, its contents distributed to the modules that own them, and the last two modules —HEngine.RuntimeandHEngine.Rendering.D3D12— now exist.Rendering → Core, it is nowRuntime → Rendering. Settings moved to their owning modules (Z4), soAddHEngineRenderingtakes what it needs rather than the wholeEngineConfiguration.HEngine.Renderingdeclares no Silk.NET package at all. The Direct3D 12 device, swap chain, command lists, PSO/shader managers and concrete renderers live inHEngine.Rendering.D3D12, and the host alone picks the backend (Z8).Silk.NET.DXGI.Format— it reports a neutralTextureFormatthe backend maps at the GPU boundary.HEngine.Architecture.Testsnow fails if a backend-agnostic module declares a Silk.NET package or ifHEngine.Runtimenames a backend.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.mdand the backlog-task skill, per the request that prompted this work.Test plan
dotnet build HEngine.slnxin Debug and Release — 0 warnings, 0 errorsdotnet test HEngine.slnx— ten of eleven projects fully green without a GPU: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.slnfbuilds 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.Testsis 232/232 green without a GPU, up from 25 failures.HEngine.Runtime.Testsis 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.Tests21/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()andRenderFrame()inGameLoopmakes 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;
DirectX12MeshShaderManagerhas no test coverage at all, since constructing anID3D10Blobneeds 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 atShaders/Shaders/, so the copy item matched nothing and no project received the.hlslfiles; six composition tests failed withDirectoryNotFoundException. It could not reproduce on Linux because the item spelled its pathShaders\*.hlsl, and a backslash is an ordinary filename character outside Windows. NowContentwith a forward-slash path.Backend leaking into the agnostic layer.
AddHEngineRenderingresolvedIShadowRendererwithGetRequiredService, but onlyAddHEngineRenderingD3D12registers it — so any composition without the backend failed even with shadows disabled, contradicting this PR's own claim. It is optional now;RenderPipelinestill fails loudly when shadows are enabled without a renderer.Broken solution filter.
HEngine.Portable.slnfstill listedHEngine.Core,HEngine.Core.TestsandHEngine.Core.Benchmarksafter they were deleted or renamed, so the filter could not restore. Nothing caught it because the architecture tests only readHEngine.slnx. It now lists the modules that build without the backend.Pre-existing defects fixed here
The CI hang.
HEngine.Assets.Testsintermittently hung its test host until the six-hour Actions timeout, on this branch and onmasteralike (run34582792393, commit 013719e). The cause was in the test:LoadMeshAsync_AfterUnloadAllDuringInFlightLoad_StartsFreshLoadassumed its first call had already consumed load attempt 1, but the loader runs viaTask.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 gainstimeout-minutes, so a recurrence fails in twenty minutes rather than consuming a runner for six hours.AssetManagerseparately published aLazyevaluated 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.
ShaderVariantCompilerassigned itsfixedpointer 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 theCompilecall.Compiled shaders were released twice.
DirectX12MeshShaderManagerhanded the sameComPtrto its active-variant fields and to the variant cache, which stores it without taking a reference and releases it onDispose,ClearandRemove. A cache hit inSetVariantreleased 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 usesDirect3D12, notD3D12— ADR 0009 records why the obvious name does not compile (Silk.NET exports a type calledD3D12, 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:TextureManagernever uploads pixel data. There is noUpdateSubresources,CopyTextureRegionorWriteToSubresourceanywhere in the backend, and no barrier out ofCopyDest, so every GPU texture is sampled uninitialized and in an invalid state.PixelDatais read by nothing outside tests.MeshAssetLoadingSystemis never registered, soMeshAssetcomponents stayNotLoadedat runtime. Deferred by the author.README.mdstill describes the old Core-centric layout;DirectX12Devicecreates its own window instead of receiving one fromHEngine.Platform;GameTimereads the system clock internally, which Z6 forbids.Closes #121
Closes #122
Closes #123
Closes #124
Closes #126