Skip to content

feat(rendering): render graph redesign — typed indices, automatic barriers, per-frame RuntimeState - #641

Merged
JeanPhilippeKernel merged 2 commits into
developfrom
feat/render-graph-redesign
Aug 21, 2026
Merged

feat(rendering): render graph redesign — typed indices, automatic barriers, per-frame RuntimeState#641
JeanPhilippeKernel merged 2 commits into
developfrom
feat/render-graph-redesign

Conversation

@JeanPhilippeKernel

@JeanPhilippeKernel JeanPhilippeKernel commented Aug 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replace string-keyed UnorderedHashMap hot path with flat Array<RGPass> / Array<RGResource> indexed by RGResourceHandle (typed uint32_t index + version)
  • RGAccess enum drives barrier derivation via kAccessTable — stage, access mask, and layout are all derived automatically with zero strings on the execute path
  • Execute() builds VkImageMemoryBarriers per frame from RuntimeState (a new separate field from CurrentState) so frame 0 correctly starts from VK_IMAGE_LAYOUT_UNDEFINED rather than leaking compile-time simulation state
  • DepthRead maps to VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL — compatible with MoltenVK and all desktop drivers; depth writes are disabled in the pipeline so the layout is valid for read-only depth testing
  • IRenderGraphCallbackPass interface is unchanged; all pass Setup() / Compile() / Execute() implementations updated to use the new builder API (WriteDepthAttachment, ReadDepth, WriteColorAttachment)
  • GraphicRenderer updated to use GetPass(name) / SetPassEnabled(name, bool) instead of direct NodeMap[] access

Test plan

  • Build arm64 Debug — no compile errors
  • Launch engine — no Vulkan validation errors (vkCmdBeginRenderPass depth layout mismatch gone)
  • Open project — GBuffer pass renders, grid renders, no MoltenVK format errors
  • Resize window — no swapchain crash
  • Import .glb mesh — mesh appears in viewport

… viewport resize

Render graph:
- Replace string-keyed hot path with flat Array<RGPass>/Array<RGResource> indexed by typed
  RGResourceHandle; RGAccess enum drives automatic barrier derivation via kAccessTable
- Per-frame RuntimeState tracking separate from compile-time CurrentState; all render
  targets are transient resources owned and resized by the graph

Deferred lighting pipeline:
- GbufferPass writes three targets: AlbedoAO (R8G8B8A8), NormalRoughness (R16F),
  MetallicEmissive (R8G8B8A8); position reconstructed from depth via InvViewProj
- LightingPass: Cook-Torrance PBR, directional + point lights via LightArrayUBO SSBO
- UBOCameraLayout gains InvViewProj; geometry_bindings.glsl updated accordingly

Viewport resize (swap-and-reuse):
- Image2DBuffer reconstructed in-place at new dimensions in the same manager slot;
  TextureHandle stays stable so the editor ImTextureID never invalidates
- Old VkFramebuffers enqueued for DeferFree before old VkImages (correct ordering);
  resources freed after GPU completes the current timeline value

Descriptor and shader fixes:
- Fragment storage buffer reflection uses operator[] instead of at() to avoid assert
  on uninitialised sets; descriptor pool maxSets counts all non-reserved sets * frames
- AllocateFramebuffers uses stack-local VkImageView[16] to avoid scratch-arena aliasing
  with Device->Arena allocations inside the same loop body
- Spec.Inputs/ExternalOutputs synced after swap so BeginRenderPass resolves valid ptrs
@JeanPhilippeKernel
JeanPhilippeKernel force-pushed the feat/render-graph-redesign branch from daf1a66 to 628afba Compare August 21, 2026 13:31
…imp 350->128 MB

All importers and AssetManager previously created intermediate sub-arenas
(Engine.cpp s_*_arena -> Importer/AssetManager sub-arena), doubling virtual
memory reservations at startup with no benefit.

Single-level: each Initialize() now carves directly from the parent.
- Import: s_gltf/assimp/envmap_arena removed; importers carve from
  ImportPipelineArena directly. Assimp reduced 350->128 MB.
- AssetManager: Arena field changed to pointer; stores parent arena
  reference directly instead of creating a 400 MB sub-arena.

Result: ImportPipeline 84%->62%, AssetManager 79%->actual usage only.
@JeanPhilippeKernel JeanPhilippeKernel added area-linux Work on Linux system area-window Work on Window system area-macOS Work on macOS system labels Aug 21, 2026
@JeanPhilippeKernel JeanPhilippeKernel moved this to In Progress in ZEngine Board Aug 21, 2026
@JeanPhilippeKernel JeanPhilippeKernel self-assigned this Aug 21, 2026
@JeanPhilippeKernel
JeanPhilippeKernel merged commit d01e849 into develop Aug 21, 2026
17 checks passed
@JeanPhilippeKernel
JeanPhilippeKernel deleted the feat/render-graph-redesign branch August 21, 2026 15:24
@github-project-automation github-project-automation Bot moved this from In Progress to Done in ZEngine Board Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-linux Work on Linux system area-macOS Work on macOS system area-window Work on Window system

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant