# 0s-been/dx12_study architecture

> Architecture diagram of the GitHub repository 0s-been/dx12_study, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/0s-been/dx12_study
- Repository: https://github.com/0s-been/dx12_study

## Overview

#### Purpose and Entry Point
This is a Windows Direct3D 12 study/rendering project centered on a CubeMap sample with shadows and screen-space ambient occlusion (SSAO). The buildable application is the Visual Studio solution/project at `DX12_Study_Root/Proj/CubeMap/CubeMap.sln` and `DX12_Study_Root/Proj/CubeMap/CubeMap.vcxproj`; its application implementation is `DX12_Study_Root/Proj/CubeMap/CubeMapApp.cpp`.

#### Application and Device Lifecycle
The renderer is structured around a reusable D3D12 application base that likely owns the Win32 window, D3D12 device, swap chain, command queue/list, descriptor heaps, synchronization, resize, and message loop. The sample-specific app subclasses or uses this foundation to initialize assets and drive per-frame update/draw work.
- `DX12_Study_Root/Common/d3dApp.h`
- `DX12_Study_Root/Common/d3dApp.cpp`
- `DX12_Study_Root/Proj/CubeMap/CubeMapApp.cpp`

#### Frame Scheduling and GPU Data
Per-frame resources isolate CPU updates from GPU consumption, typically including command allocators and upload-backed constant buffers. The shared upload-buffer abstraction supports structured/constant GPU uploads; timer and camera state feed the frame update path.
- `DX12_Study_Root/Proj/CubeMap/FrameResource.h`
- `DX12_Study_Root/Proj/CubeMap/FrameResource.cpp`
- `DX12_Study_Root/Common/UploadBuffer.h`

#### Scene, Camera, and Asset Inputs
The application renders generated geometry and model assets, with camera transforms controlling view/projection. Texture inputs are primarily DDS files, including cube maps and normal maps; loading is provided by the common DDS loader. Geometry/model boundaries are CPU-side asset construction versus GPU vertex/index/resource creation in the app.
- `DX12_Study_Root/Common/Camera.h`
- `DX12_Study_Root/Common/GeometryGenerator.h`
- `DX12_Study_Root/Common/DDSTextureLoader.cpp`
- `DX12_Study_Root/Proj/CubeMap/Models/car.txt`

#### Shader and Material Pipeline
HLSL source defines the GPU shading contract: shared constants, default lighting/material rendering, sky/cubemap rendering, normal visualization, and shadow/SSAO passes. `CubeMapApp.cpp` is the integration point expected to compile shaders, establish root signatures and pipeline-state objects, bind descriptors, and issue draws.
- `DX12_Study_Root/Proj/CubeMap/Shaders/Common.hlsl`
- `DX12_Study_Root/Proj/CubeMap/Shaders/Default.hlsl`
- `DX12_Study_Root/Proj/CubeMap/Shaders/Sky.hlsl`

#### Shadow Mapping
Shadow mapping is encapsulated as a dedicated render target/resource component. The control flow is a depth-oriented shadow pass from the light viewpoint, followed by scene shading that samples the shadow map through the shadows shader logic.
- `DX12_Study_Root/Proj/CubeMap/ShadowMap.h`
- `DX12_Study_Root/Proj/CubeMap/ShadowMap.cpp`
- `DX12_Study_Root/Proj/CubeMap/Shaders/Shadows.hlsl`

#### SSAO Post-Processing
SSAO is another owned GPU resource/pass subsystem, with distinct ambient-occlusion generation, blur, and debugging shaders. It consumes scene depth/normal-oriented data, produces an AO texture, optionally blurs it, then contributes to final lighting/debug visualization.
- `DX12_Study_Root/Proj/CubeMap/Ssao.h`
- `DX12_Study_Root/Proj/CubeMap/Ssao.cpp`
- `DX12_Study_Root/Proj/CubeMap/Shaders/Ssao.hlsl`

#### Runtime and UI Boundary
The runtime is native C++ on Windows using Direct3D 12 and Win32. Dear ImGui is vendored with Win32 and DX12 backends, providing an optional immediate-mode debug/control UI that must be initialized against the app’s window, device, descriptor heap, and command list.
- `DX12_Study_Root/Proj/CubeMap/ImGUI/imgui.cpp`
- `DX12_Study_Root/Proj/CubeMap/ImGUI/backends/imgui_impl_win32.cpp`
- `DX12_Study_Root/Proj/CubeMap/ImGUI/backends/imgui_impl_dx12.cpp`

Main entry points: [`DX12_Study_Root/Proj/CubeMap/CubeMapApp.cpp`](https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/CubeMapApp.cpp) (CubeMapApp), [`DX12_Study_Root/Proj/CubeMap/Shaders/Default.hlsl`](https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/Shaders/Default.hlsl) (Default lighting shader), [`DX12_Study_Root/Proj/CubeMap/Shaders/Common.hlsl`](https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/Shaders/Common.hlsl) (Shared shader contract), [`DX12_Study_Root/Proj/CubeMap/ShadowMap.cpp`](https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/ShadowMap.cpp) (Shadow map)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Windows D3D12 Host"]
  node_project["CubeMap project<br/>Visual Studio build<br/>[CubeMap.vcxproj]"]
  node_app["CubeMapApp<br/>sample renderer<br/>[CubeMapApp.cpp]"]
  node_d3dapp["D3D application base<br/>D3D12 host<br/>[d3dApp.cpp]"]
end

subgraph group_frame["Frame Data"]
  node_frame_resource[("Frame resources<br/>per-frame GPU state<br/>[FrameResource.cpp]")]
  node_upload_buffer["UploadBuffer<br/>GPU upload abstraction<br/>[UploadBuffer.h]"]
end

subgraph group_render["Render Pipeline"]
  node_shader_contract["Shared shader contract<br/>HLSL constants<br/>[Common.hlsl]"]
  node_default_shader["Default lighting shader<br/>HLSL scene shading<br/>[Default.hlsl]"]
  node_sky_shader["Sky cubemap shader<br/>HLSL sky shading<br/>[Sky.hlsl]"]
  node_shadow_map[("Shadow map<br/>light-depth target<br/>[ShadowMap.cpp]")]
  node_shadow_shader["Shadow shader<br/>HLSL shadow pass<br/>[Shadows.hlsl]"]
  node_ssao[("SSAO subsystem<br/>AO render targets<br/>[Ssao.cpp]")]
  node_ssao_shader["SSAO shaders<br/>HLSL post-process<br/>[Ssao.hlsl]"]
end

subgraph group_assets["Scene Assets"]
  node_camera["Camera<br/>view state<br/>[Camera.h]"]
  node_geometry["Generated geometry<br/>CPU mesh builder"]
  node_car_model["Car model<br/>model asset<br/>[car.txt]"]
  node_dds_loader["DDS texture loader<br/>asset loader"]
end

subgraph group_ui["Debug UI"]
  node_imgui["Dear ImGui<br/>debug UI<br/>[imgui.cpp]"]
  node_imgui_dx12["ImGui DX12 backend<br/>D3D12 UI backend"]
end

node_project -->|"builds"| node_app
node_app -->|"uses lifecycle"| node_d3dapp
node_app -->|"updates each frame"| node_frame_resource
node_frame_resource -->|"uses"| node_upload_buffer
node_camera -->|"supplies view transforms"| node_app
node_geometry -->|"supplies meshes"| node_app
node_car_model -->|"loads model"| node_app
node_dds_loader -->|"loads textures"| node_app
node_app -->|"compiles and binds"| node_shader_contract
node_shader_contract -->|"shared by"| node_default_shader
node_shader_contract -->|"shared by"| node_sky_shader
node_app -->|"renders light depth"| node_shadow_map
node_shadow_shader -->|"writes"| node_shadow_map
node_shadow_map -->|"sampled for lighting"| node_default_shader
node_app -->|"runs post-process"| node_ssao
node_ssao_shader -->|"generates and blurs AO"| node_ssao
node_ssao -->|"contributes AO"| node_default_shader
node_app -->|"issues scene draws"| node_default_shader
node_app -->|"issues sky draw"| node_sky_shader
node_app -.->|"hosts debug UI"| node_imgui
node_imgui -->|"renders through"| node_imgui_dx12
node_imgui_dx12 -.->|"uses device and command list"| node_d3dapp

click node_project "https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/CubeMap.vcxproj"
click node_app "https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/CubeMapApp.cpp"
click node_d3dapp "https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Common/d3dApp.cpp"
click node_frame_resource "https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/FrameResource.cpp"
click node_upload_buffer "https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Common/UploadBuffer.h"
click node_camera "https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Common/Camera.h"
click node_geometry "https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Common/GeometryGenerator.h"
click node_car_model "https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/Models/car.txt"
click node_dds_loader "https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Common/DDSTextureLoader.cpp"
click node_shader_contract "https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/Shaders/Common.hlsl"
click node_default_shader "https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/Shaders/Default.hlsl"
click node_sky_shader "https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/Shaders/Sky.hlsl"
click node_shadow_map "https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/ShadowMap.cpp"
click node_shadow_shader "https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/Shaders/Shadows.hlsl"
click node_ssao "https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/Ssao.cpp"
click node_ssao_shader "https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/Shaders/Ssao.hlsl"
click node_imgui "https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/ImGUI/imgui.cpp"
click node_imgui_dx12 "https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/ImGUI/backends/imgui_impl_dx12.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_project,node_app,node_d3dapp toneBlue
class node_frame_resource,node_upload_buffer toneAmber
class node_shader_contract,node_default_shader,node_sky_shader,node_shadow_map,node_shadow_shader,node_ssao,node_ssao_shader toneMint
class node_camera,node_geometry,node_car_model,node_dds_loader toneRose
class node_imgui,node_imgui_dx12 toneIndigo
```

## Components

### Windows D3D12 Host

- [CubeMap project](https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/CubeMap.vcxproj): Visual Studio build · Buildable native application. · `DX12_Study_Root/Proj/CubeMap/CubeMap.vcxproj`
- [CubeMapApp](https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/CubeMapApp.cpp): sample renderer · Initializes assets and drives frame update and drawing. · `DX12_Study_Root/Proj/CubeMap/CubeMapApp.cpp`
- [D3D application base](https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Common/d3dApp.cpp): D3D12 host · Owns the Win32 and core D3D12 lifecycle. · `DX12_Study_Root/Common/d3dApp.cpp`

### Frame Data

- [Frame resources](https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/FrameResource.cpp): per-frame GPU state · Separates CPU updates from GPU consumption. · `DX12_Study_Root/Proj/CubeMap/FrameResource.cpp`
- [UploadBuffer](https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Common/UploadBuffer.h): GPU upload abstraction · `DX12_Study_Root/Common/UploadBuffer.h`

### Render Pipeline

- [Shared shader contract](https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/Shaders/Common.hlsl): HLSL constants · `DX12_Study_Root/Proj/CubeMap/Shaders/Common.hlsl`
- [Default lighting shader](https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/Shaders/Default.hlsl): HLSL scene shading · `DX12_Study_Root/Proj/CubeMap/Shaders/Default.hlsl`
- [Sky cubemap shader](https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/Shaders/Sky.hlsl): HLSL sky shading · `DX12_Study_Root/Proj/CubeMap/Shaders/Sky.hlsl`
- [Shadow map](https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/ShadowMap.cpp): light-depth target · Dedicated shadow render resource. · `DX12_Study_Root/Proj/CubeMap/ShadowMap.cpp`
- [Shadow shader](https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/Shaders/Shadows.hlsl): HLSL shadow pass · `DX12_Study_Root/Proj/CubeMap/Shaders/Shadows.hlsl`
- [SSAO subsystem](https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/Ssao.cpp): AO render targets · Generates and blurs ambient occlusion. · `DX12_Study_Root/Proj/CubeMap/Ssao.cpp`
- [SSAO shaders](https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/Shaders/Ssao.hlsl): HLSL post-process · `DX12_Study_Root/Proj/CubeMap/Shaders/Ssao.hlsl`

### Scene Assets

- [Camera](https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Common/Camera.h): view state · `DX12_Study_Root/Common/Camera.h`
- [Generated geometry](https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Common/GeometryGenerator.h): CPU mesh builder · `DX12_Study_Root/Common/GeometryGenerator.h`
- [Car model](https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/Models/car.txt): model asset · `DX12_Study_Root/Proj/CubeMap/Models/car.txt`
- [DDS texture loader](https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Common/DDSTextureLoader.cpp): asset loader · `DX12_Study_Root/Common/DDSTextureLoader.cpp`

### Debug UI

- [Dear ImGui](https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/ImGUI/imgui.cpp): debug UI · `DX12_Study_Root/Proj/CubeMap/ImGUI/imgui.cpp`
- [ImGui DX12 backend](https://github.com/0s-been/dx12_study/blob/main/DX12_Study_Root/Proj/CubeMap/ImGUI/backends/imgui_impl_dx12.cpp): D3D12 UI backend · Binds UI rendering to D3D12 descriptors and command lists. · `DX12_Study_Root/Proj/CubeMap/ImGUI/backends/imgui_impl_dx12.cpp`

## Connections

- CubeMap project → CubeMapApp: builds
- CubeMapApp → D3D application base: uses lifecycle
- CubeMapApp → Frame resources: updates each frame
- Frame resources → UploadBuffer: uses
- Camera → CubeMapApp: supplies view transforms
- Generated geometry → CubeMapApp: supplies meshes
- Car model → CubeMapApp: loads model
- DDS texture loader → CubeMapApp: loads textures
- CubeMapApp → Shared shader contract: compiles and binds
- Shared shader contract → Default lighting shader: shared by
- Shared shader contract → Sky cubemap shader: shared by
- CubeMapApp → Shadow map: renders light depth
- Shadow shader → Shadow map: writes
- Shadow map → Default lighting shader: sampled for lighting
- CubeMapApp → SSAO subsystem: runs post-process
- SSAO shaders → SSAO subsystem: generates and blurs AO
- SSAO subsystem → Default lighting shader: contributes AO
- CubeMapApp → Default lighting shader: issues scene draws
- CubeMapApp → Sky cubemap shader: issues sky draw
- CubeMapApp → Dear ImGui: hosts debug UI
- Dear ImGui → ImGui DX12 backend: renders through
- ImGui DX12 backend → D3D application base: uses device and command list
