# Building a Game Engine from Scratch (Day 8) | DirectX 12 Constant Buffers & Frames in Flight (C++20)

**URL:** <https://forums.unrealengine.com/t/building-a-game-engine-from-scratch-day-8-directx-12-constant-buffers-frames-in-flight-c-20/2859046>\
**Category:** C++\
**Tags:** unreal-engine, CPP\
**Created:** [November 19, 2026, 11:21am UTC](https://forums.unrealengine.com/t/building-a-game-engine-from-scratch-day-8-directx-12-constant-buffers-frames-in-flight-c-20/2859046 "2026-11-19T11:21:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevinpc\_1](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/kevinpc_1/32/1215238_2.png) [@kevinpc\_1](https://forums.unrealengine.com/u/kevinpc_1)\
**Post date:** [November 19, 2026, 11:21am UTC](https://forums.unrealengine.com/t/building-a-game-engine-from-scratch-day-8-directx-12-constant-buffers-frames-in-flight-c-20/2859046/1 "2026-11-19T11:21:35Z")

</div>

Day 8 of building TitanEngine from scratch using C++20 and native DirectX 12 — zero wrappers, zero helper libraries (no d3dx12.h).

Today we open the dynamic CPU-to-GPU communication pipeline by implementing Constant Buffers (CBV) synchronized with our Frames in Flight architecture. Instead of static geometry, the CPU now pushes real-time offset data every frame safely without data races.

🔧 What we built on Day 8:  
• Root Signature update: Adding a Root Parameter (CBV) bound to shader register b0.  
• Strict 256-byte memory alignment enforced at compile-time via static\_assert.  
• Per-frame Constant Buffer allocation on UPLOAD heaps with persistent memory mapping (Map).  
• Real-time buffer updates via memcpy synchronized by frameIndex.  
• HLSL Vertex Shader integration reading cbuffer data from register(b0).

🛠 Tech Stack:  
• Language: C++20  
• Graphics API: Native DirectX 12 / DXGI 1.6 / HLSL (Shader Model 5.0)  
• Platform: Windows x64 (Win32 API)

Link video day 8:[https://youtu.be/-pnQaOFhavA](https://youtu.be/-pnQaOFhavA)

Next up: Index Buffers for complex 3D meshes and high-resolution DeltaTime timing.

#DirectX12 #CPP #GameEngine #GraphicsProgramming #LowLevelCode #EngineProgramming #hlsl #GameDev #TitanEngine
