feat: add Graphics module with D3D12 backend and documentation

Graphics Module:
- Add platform abstraction layer (GraphicsPlatformInterface)
- Add unified renderer entry point (Renderer)
- Add D3D12 backend implementation (D3D12Core, D3D12Interface)
- Add TestRenderer for multi-window rendering tests

Documentation:
- Add Graphics渲染架构分析.md
- Add D3D12学习Wiki.md
- Add changelogs directory with per-commit documentation
- Add 20260326-dx12-initial.md for initial framework
- Add 20260326-d3d12-foundation.md for Graphics module

Fixes:
- Resolve header include issues and type redefinition errors
This commit is contained in:
SpecialX
2026-03-26 16:53:09 +08:00
parent 6ca6970e34
commit b7eebc11b2
18 changed files with 937 additions and 2 deletions

View File

@@ -0,0 +1,101 @@
# 变更记录D3D12 基础框架
**提交日期**: 2026-03-26
**提交哈希**: `16723ba`
**变更类型**: 新增功能
---
## 变更概述
本次提交新增了 Graphics 渲染模块和 Direct3D12 后端框架,实现了平台抽象层设计,为后续图形渲染功能奠定基础。
## 新增文件
### Engine/Graphics/Direct3D12/
| 文件 | 说明 |
|------|------|
| `D3D12CommonHeader.h` | D3D12 公共头文件,引入 DXGI、D3D12、WRL 依赖 |
| `D3D12Core.h` | D3D12 核心模块头文件 |
| `D3D12Core.cpp` | D3D12 核心初始化/关闭实现(框架代码) |
| `D3D12Interface.h` | 平台接口绑定声明 |
| `D3D12Interface.cpp` | 将 D3D12 实现绑定到平台接口 |
### Engine/Graphics/
| 文件 | 说明 |
|------|------|
| `GraphicsPlatformInterface.h` | 平台抽象接口定义 |
| `Renderer.h` | 统一渲染器入口声明 |
| `Renderer.cpp` | 渲染器初始化与平台选择逻辑 |
### EngineTest/
| 文件 | 说明 |
|------|------|
| `TestRenderer.h` | 渲染测试类声明 |
| `TestRenderer.cpp` | 多窗口渲染测试实现 |
### docs/
| 文件 | 说明 |
|------|------|
| `架构分析/Graphics渲染架构分析.md` | Graphics 模块架构分析文档 |
| `wiki/D3D12学习Wiki.md` | D3D12 学习知识汇总 |
---
## 技术要点
### 1. 平台抽象接口
```cpp
struct platform_interface {
bool(*initialize)(void);
void(*shutdown)(void);
};
```
通过函数指针实现运行时平台选择,支持 D3D12/Vulkan/OpenGL 多后端。
### 2. 渲染器入口
```cpp
enum class graphics_platform : u32 {
direct3d12 = 0,
vulkan = 1,
opengl = 2,
};
bool initialize(graphics_platform platform);
void shutdown();
```
### 3. 多窗口测试
TestRenderer 支持创建 4 个独立渲染窗口,并实现 Alt+Enter 全屏切换。
---
## 依赖引入
- `<dxgi_6.h>` - DXGI 6.0 接口
- `<d3d12.h>` - Direct3D 12 API
- `<wrl.h>` - COM 智能指针
---
## 后续工作
- [ ] 适配器枚举与设备创建
- [ ] 命令队列实现
- [ ] 交换链管理
- [ ] 描述符堆
---
## 相关文档
- [Graphics渲染架构分析](../架构分析/Graphics渲染架构分析.md)
- [D3D12学习Wiki](../wiki/D3D12学习Wiki.md)

View File

@@ -0,0 +1,116 @@
# 变更记录DX12 初始框架
**提交日期**: 2026-03-26
**提交哈希**: `60f73b5`
**变更类型**: 初始化项目
---
## 变更概述
本次提交是项目的初始版本,建立了完整的引擎基础框架,包括组件系统、平台抽象层、内容加载器和测试框架。
## 新增模块
### Engine/Common/
| 文件 | 说明 |
|------|------|
| `CommonHeader.h` | 公共头文件,定义基础类型和宏 |
| `Id.h` | 强类型 ID 系统 |
| `XEnginType.h` | 引擎类型定义 |
### Engine/Components/
| 文件 | 说明 |
|------|------|
| `Entity.cpp/.h` | 实体组件实现 |
| `Script.cpp/.h` | 脚本组件实现 |
| `Transform.cpp/.h` | 变换组件实现 |
### Engine/EngineAPI/
| 文件 | 说明 |
|------|------|
| `Camera.h` | 相机 API |
| `GameEntity.h` | 游戏实体 API |
| `Light.h` | 光源 API |
| `ScriptComponent.h` | 脚本组件 API |
| `TransformComponent.h` | 变换组件 API |
### Engine/Platform/
| 文件 | 说明 |
|------|------|
| `Platform.h` | 平台抽象接口 |
| `PlatformTypes.h` | 平台类型定义 |
| `PlatformWin32.cpp` | Win32 平台实现 |
| `Window.cpp/.h` | 窗口管理 |
### Engine/Content/
| 文件 | 说明 |
|------|------|
| `ContentLoader.cpp/.h` | 内容加载器 |
| `ContentToEngine.cpp/.h` | 内容到引擎转换 |
### Engine/Utilities/
| 文件 | 说明 |
|------|------|
| `FreeList.h` | 空闲列表内存池 |
| `IOStream.h` | IO 流工具 |
| `Math.h` | 数学工具 |
| `MathTypes.h` | 数学类型 |
| `Vector.h` | 向量容器 |
| `Utilities.h` | 通用工具 |
### ContentTools/
| 文件 | 说明 |
|------|------|
| `FbxImporter.cpp/.h` | FBX 模型导入 |
| `Geometry.cpp/.h` | 几何处理 |
| `MeshPrimitives.cpp/.h` | 网格图元 |
### EngineTest/
| 文件 | 说明 |
|------|------|
| `Main.cpp` | 测试入口 |
| `Test.h` | 测试框架基类 |
| `TestEntityComponent.h` | 实体组件测试 |
| `ShaderComponents.cpp/.h` | 着色器组件测试 |
| `Lights.cpp` | 光源测试 |
| `RenderItem.cpp` | 渲染项测试 |
---
## 核心设计
### 1. 强类型 ID 系统
```cpp
DEFINE_TYPED_ID(id_type);
```
通过宏生成类型安全的 ID支持代数校验防止使用已删除对象。
### 2. 组件系统架构
- **EngineAPI 层**: 对外契约,暴露稳定接口
- **Components 层**: 运行时实现,管理内部存储
### 3. 平台抽象
Win32 平台实现封装,上层代码通过抽象接口访问平台功能。
---
## 相关文档
- [Id机制分析](../架构分析/Id机制分析.md)
- [Entity组件分析](../架构分析/Entity组件分析.md)
- [Script组件分析](../架构分析/Script组件分析.md)
- [Transform组件分析](../架构分析/Transform组件分析.md)
- [项目约定规范](../架构分析/项目约定规范.md)

24
docs/changelogs/README.md Normal file
View File

@@ -0,0 +1,24 @@
# 变更日志索引
本目录记录每次代码提交的详细变更文档。
## 目录结构
```
changelogs/
├── README.md # 本文件 - 索引
├── 2026-03/ # 按月份组织
│ └── xxx.md # 具体变更文档
└── ...
```
## 变更记录
| 日期 | 提交 | 变更内容 |
|------|------|----------|
| 2026-03-26 | [Graphics模块](./2026-03/20260326-d3d12-foundation.md) | Graphics 模块与 D3D12 后端框架 |
| 2026-03-19 | [DX12初始框架](./2026-03/20260326-dx12-initial.md) | 初始 DX12 基础框架 |
---
> 每次提交变更后,请在对应月份目录下创建独立的变更文档。