How 0s-been/dx12_study works
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: CubeMapApp.cpp CubeMapApp · Default.hlsl Default lighting shader · Common.hlsl Shared shader contract · ShadowMap.cpp Shadow map
Components 18
Windows D3D12 Host
- CubeMap project · Buildable native application.
DX12_Study_Root/Proj/CubeMap/CubeMap.vcxproj - CubeMapApp · Initializes assets and drives frame update and drawing.
DX12_Study_Root/Proj/CubeMap/CubeMapApp.cpp - D3D application base · Owns the Win32 and core D3D12 lifecycle.
DX12_Study_Root/Common/d3dApp.cpp
Frame Data
- Frame resources · Separates CPU updates from GPU consumption.
DX12_Study_Root/Proj/CubeMap/FrameResource.cpp - UploadBuffer
DX12_Study_Root/Common/UploadBuffer.h
Render Pipeline
- Shared shader contract
DX12_Study_Root/Proj/CubeMap/Shaders/Common.hlsl - Default lighting shader
DX12_Study_Root/Proj/CubeMap/Shaders/Default.hlsl - Sky cubemap shader
DX12_Study_Root/Proj/CubeMap/Shaders/Sky.hlsl - Shadow map · Dedicated shadow render resource.
DX12_Study_Root/Proj/CubeMap/ShadowMap.cpp - Shadow shader
DX12_Study_Root/Proj/CubeMap/Shaders/Shadows.hlsl - SSAO subsystem · Generates and blurs ambient occlusion.
DX12_Study_Root/Proj/CubeMap/Ssao.cpp - SSAO shaders
DX12_Study_Root/Proj/CubeMap/Shaders/Ssao.hlsl
Scene Assets
- Camera
DX12_Study_Root/Common/Camera.h - Generated geometry
DX12_Study_Root/Common/GeometryGenerator.h - Car model
DX12_Study_Root/Proj/CubeMap/Models/car.txt - DDS texture loader
DX12_Study_Root/Common/DDSTextureLoader.cpp
Debug UI
- Dear ImGui
DX12_Study_Root/Proj/CubeMap/ImGUI/imgui.cpp - ImGui DX12 backend · Binds UI rendering to D3D12 descriptors and command lists.
DX12_Study_Root/Proj/CubeMap/ImGUI/backends/imgui_impl_dx12.cpp
Connections 22
- 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