Shared renderer modules, D3D12 refit onto them #30

Open
UnflavoredMeson/Primal_Plus_Plus
opened 2026-11-24 20:15:57 +00:00 by UnflavoredMeson · 0 comments
Owner

Why

The fork wrote Vulkan as a copy of D3D12 and ended at 44% identical code, then spent the renderer issue merging it. Moving the API-free code out of D3D12 first, while only D3D12 exists, means Vulkan is written against shared code and the picture stays testable.

Decided

  • Option A: shared CPU-side modules, two backends. Camera math, light sets, the frame packet, frames in flight, engine shader loading and render preparation are written once in Engine/Graphics/ (headers + .cpp, not a module); each backend keeps its resources and records its passes. A render graph and a thin RHI are later issues (S12).
  • The renderer reads S3-05's components: graphics::scene::prepare() once a frame builds the light sets and one backend render item per MeshRenderer entity.
  • Content (meshes, textures, materials, shaders) stays a backend API, read under a shared lock while preparing.

Read first

  • Renderer, sections 1-9; RendererThreading.
  • Engine/Graphics/Direct3D12/D3D12Camera.cpp, D3D12Light.cpp, D3D12Gpass.cpp, Engine/Graphics/Renderer.h on master.

Steps

  • 1. Move the camera into Engine/Graphics/Camera.*; D3D12 uses it. Picture unchanged.
  • 2. Move light sets into Engine/Graphics/Lights.*, with D3D12's GPU buffer derived from a shared LightBuffers.
  • 3. Write graphics::scene::prepare() reading MeshRenderer, the lights and Camera; remove the renderer's own light/camera/render-item API.
  • 4. Convert the renderer EngineTest to entities with render components.

Done when

  • The renderer EngineTest draws the same picture on D3D12 from components; UnitTests cover the light set rebuild; 0 warnings; tidy 0.

Claude can help with

  • Diffing behaviour before and after each move (a log of the frame packet).

Learn

  • What a frame packet is and why it is the boundary between game state and the GPU.
## Why The fork wrote Vulkan as a copy of D3D12 and ended at 44% identical code, then spent the renderer issue merging it. Moving the API-free code out of D3D12 first, while only D3D12 exists, means Vulkan is written against shared code and the picture stays testable. ## Decided - Option A: shared CPU-side modules, two backends. Camera math, light sets, the frame packet, frames in flight, engine shader loading and render preparation are written once in `Engine/Graphics/` (headers + `.cpp`, not a module); each backend keeps its resources and records its passes. A render graph and a thin RHI are later issues (S12). - The renderer reads S3-05's components: `graphics::scene::prepare()` once a frame builds the light sets and one backend render item per `MeshRenderer` entity. - Content (meshes, textures, materials, shaders) stays a backend API, read under a shared lock while preparing. ## Read first - [Renderer](https://forgejo.unflavoredmeson.com/UnflavoredMeson/Primal_Plus_Plus/wiki/Renderer), sections 1-9; [RendererThreading](https://forgejo.unflavoredmeson.com/UnflavoredMeson/Primal_Plus_Plus/wiki/RendererThreading). - `Engine/Graphics/Direct3D12/D3D12Camera.cpp`, `D3D12Light.cpp`, `D3D12Gpass.cpp`, `Engine/Graphics/Renderer.h` on `master`. ## Steps - [ ] 1. Move the camera into `Engine/Graphics/Camera.*`; D3D12 uses it. Picture unchanged. - [ ] 2. Move light sets into `Engine/Graphics/Lights.*`, with D3D12's GPU buffer derived from a shared `LightBuffers`. - [ ] 3. Write `graphics::scene::prepare()` reading `MeshRenderer`, the lights and `Camera`; remove the renderer's own light/camera/render-item API. - [ ] 4. Convert the renderer EngineTest to entities with render components. ## Done when - [ ] The renderer EngineTest draws the same picture on D3D12 from components; UnitTests cover the light set rebuild; 0 warnings; tidy 0. ## Claude can help with - Diffing behaviour before and after each move (a log of the frame packet). ## Learn - What a frame packet is and why it is the boundary between game state and the GPU.
Sign in to join this conversation.
No assignees
No project
No milestone
Blocks Depends on
#20 Transforms as components with a hierarchy
UnflavoredMeson/Primal_Plus_Plus
#23 Render components
UnflavoredMeson/Primal_Plus_Plus
#29 PrimalImport command-line importer
UnflavoredMeson/Primal_Plus_Plus
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
UnflavoredMeson/Primal_Plus_Plus#30
No description provided.