2026-03-13 15:07:03 +08:00
|
|
|
|
# XCEngine
|
2026-03-11 17:39:33 +08:00
|
|
|
|
|
2026-03-13 20:38:32 +08:00
|
|
|
|
基于 DirectX 12 的渲染引擎项目,包含体积渲染器、基础渲染示例和核心模块单元测试。
|
2026-03-13 15:07:03 +08:00
|
|
|
|
|
|
|
|
|
|
## 项目概述
|
|
|
|
|
|
|
2026-03-13 20:38:32 +08:00
|
|
|
|
XCEngine 是一个正在开发中的图形渲染引擎,使用 DirectX 12 作为底层渲染 API。项目采用模块化设计,包含核心库和单元测试。
|
2026-03-11 17:39:33 +08:00
|
|
|
|
|
|
|
|
|
|
## 技术栈
|
|
|
|
|
|
|
2026-03-13 15:07:03 +08:00
|
|
|
|
- **渲染 API**: DirectX 12
|
2026-03-11 17:39:33 +08:00
|
|
|
|
- **语言**: C++17
|
|
|
|
|
|
- **构建系统**: CMake
|
2026-03-13 20:38:32 +08:00
|
|
|
|
- **测试框架**: Google Test
|
2026-03-11 17:39:33 +08:00
|
|
|
|
|
|
|
|
|
|
## 项目结构
|
|
|
|
|
|
|
|
|
|
|
|
```
|
2026-03-13 15:07:03 +08:00
|
|
|
|
XCEngine/
|
2026-03-13 20:38:32 +08:00
|
|
|
|
├── engine/ # 核心引擎库
|
|
|
|
|
|
│ ├── include/XCEngine/
|
|
|
|
|
|
│ │ ├── Containers/ # 容器模块
|
|
|
|
|
|
│ │ │ ├── String.h # 字符串类
|
|
|
|
|
|
│ │ │ ├── Array.h # 动态数组
|
|
|
|
|
|
│ │ │ └── HashMap.h # 哈希表
|
|
|
|
|
|
│ │ ├── Memory/ # 内存管理模块
|
|
|
|
|
|
│ │ │ ├── Allocator.h # 分配器接口
|
|
|
|
|
|
│ │ │ ├── LinearAllocator.h # 线性分配器
|
|
|
|
|
|
│ │ │ ├── PoolAllocator.h # 内存池分配器
|
|
|
|
|
|
│ │ │ ├── ProxyAllocator.h # 代理分配器
|
|
|
|
|
|
│ │ │ └── MemoryManager.h # 内存管理器
|
|
|
|
|
|
│ │ ├── Threading/ # 线程模块
|
|
|
|
|
|
│ │ │ ├── Thread.h # 线程类
|
|
|
|
|
|
│ │ │ ├── Mutex.h # 互斥锁
|
|
|
|
|
|
│ │ │ ├── SpinLock.h # 自旋锁
|
|
|
|
|
|
│ │ │ ├── ReadWriteLock.h # 读写锁
|
|
|
|
|
|
│ │ │ ├── Task.h # 任务基类
|
|
|
|
|
|
│ │ │ ├── LambdaTask.h # Lambda任务
|
|
|
|
|
|
│ │ │ ├── TaskGroup.h # 任务组
|
|
|
|
|
|
│ │ │ ├── TaskSystem.h # 任务系统
|
|
|
|
|
|
│ │ │ └── TaskSystemConfig.h # 任务系统配置
|
|
|
|
|
|
│ │ ├── Math/ # 数学库
|
|
|
|
|
|
│ │ │ ├── Vector.h
|
|
|
|
|
|
│ │ │ ├── Matrix.h
|
|
|
|
|
|
│ │ │ ├── Quaternion.h
|
|
|
|
|
|
│ │ │ └── ...
|
|
|
|
|
|
│ │ └── Core/ # 核心模块
|
2026-03-13 15:07:03 +08:00
|
|
|
|
│ │
|
2026-03-13 20:38:32 +08:00
|
|
|
|
│ └── src/ # 实现文件
|
|
|
|
|
|
│ ├── Containers/
|
|
|
|
|
|
│ ├── Memory/
|
|
|
|
|
|
│ ├── Threading/
|
|
|
|
|
|
│ └── Math/
|
|
|
|
|
|
│
|
|
|
|
|
|
├── tests/ # 单元测试
|
|
|
|
|
|
│ ├── containers/ # 容器测试
|
|
|
|
|
|
│ ├── memory/ # 内存管理测试
|
|
|
|
|
|
│ ├── threading/ # 线程模块测试
|
|
|
|
|
|
│ ├── core/ # 核心模块测试
|
|
|
|
|
|
│ └── math/ # 数学库测试
|
|
|
|
|
|
│
|
|
|
|
|
|
├── docs/ # 设计文档
|
|
|
|
|
|
│ ├── XCEngine渲染引擎架构设计.md
|
|
|
|
|
|
│ └── ...
|
2026-03-13 15:07:03 +08:00
|
|
|
|
│
|
2026-03-13 20:38:32 +08:00
|
|
|
|
└── build/ # 构建目录
|
2026-03-11 17:39:33 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-03-13 15:07:03 +08:00
|
|
|
|
## 快速开始
|
2026-03-11 17:39:33 +08:00
|
|
|
|
|
|
|
|
|
|
### 前置要求
|
|
|
|
|
|
|
|
|
|
|
|
- Windows 10/11
|
|
|
|
|
|
- Visual Studio 2019 或更高版本
|
|
|
|
|
|
- CMake 3.15+
|
|
|
|
|
|
|
2026-03-13 15:07:03 +08:00
|
|
|
|
### 构建项目
|
|
|
|
|
|
|
2026-03-11 17:39:33 +08:00
|
|
|
|
```bash
|
2026-03-13 20:38:32 +08:00
|
|
|
|
# 创建构建目录
|
2026-03-11 17:39:33 +08:00
|
|
|
|
mkdir build && cd build
|
2026-03-13 20:38:32 +08:00
|
|
|
|
|
|
|
|
|
|
# 配置 CMake
|
|
|
|
|
|
cmake .. -A x64
|
|
|
|
|
|
|
|
|
|
|
|
# 编译
|
|
|
|
|
|
cmake --build . --config Debug
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### 运行测试
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
cd build/tests
|
|
|
|
|
|
ctest -C Debug --output-on-failure
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
或直接运行测试可执行文件:
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
build/tests/containers/Debug/xcengine_containers_tests.exe
|
|
|
|
|
|
build/tests/memory/Debug/xcengine_memory_tests.exe
|
|
|
|
|
|
build/tests/threading/Debug/xcengine_threading_tests.exe
|
2026-03-11 17:39:33 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-03-13 20:38:32 +08:00
|
|
|
|
## 核心模块说明
|
|
|
|
|
|
|
|
|
|
|
|
### Containers(容器)
|
|
|
|
|
|
|
|
|
|
|
|
- **String**: 动态字符串类,支持常用字符串操作
|
|
|
|
|
|
- **Array**: 模板动态数组,自动内存管理
|
|
|
|
|
|
- **HashMap**: 模板哈希表,支持自定义键类型
|
|
|
|
|
|
|
|
|
|
|
|
### Memory(内存管理)
|
|
|
|
|
|
|
|
|
|
|
|
- **IAllocator**: 内存分配器接口
|
|
|
|
|
|
- **LinearAllocator**: 线性分配器,适合帧分配
|
|
|
|
|
|
- **PoolAllocator**: 内存池分配器,适合固定大小对象
|
|
|
|
|
|
- **ProxyAllocator**: 代理分配器,跟踪内存使用统计
|
|
|
|
|
|
- **MemoryManager**: 全局内存管理器
|
2026-03-11 17:39:33 +08:00
|
|
|
|
|
2026-03-13 20:38:32 +08:00
|
|
|
|
### Threading(线程)
|
2026-03-11 17:39:33 +08:00
|
|
|
|
|
2026-03-13 20:38:32 +08:00
|
|
|
|
- **Thread**: 线程封装类
|
|
|
|
|
|
- **Mutex**: 互斥锁
|
|
|
|
|
|
- **SpinLock**: 自旋锁,适合短临界区
|
|
|
|
|
|
- **ReadWriteLock**: 读写锁
|
|
|
|
|
|
- **TaskSystem**: 多线程任务系统
|
|
|
|
|
|
- **Task/TaskGroup**: 任务和任务组管理
|
2026-03-13 15:07:03 +08:00
|
|
|
|
|
2026-03-13 20:38:32 +08:00
|
|
|
|
### Math(数学库)
|
2026-03-12 01:58:17 +08:00
|
|
|
|
|
2026-03-13 20:38:32 +08:00
|
|
|
|
- **Vector**: 向量运算
|
|
|
|
|
|
- **Matrix**: 矩阵运算
|
|
|
|
|
|
- **Quaternion**: 四元数
|
|
|
|
|
|
- **Transform**: 变换
|
|
|
|
|
|
- **Color**: 颜色
|
|
|
|
|
|
- **Frustum**: 视锥体
|
|
|
|
|
|
- **Bounds**: 边界框
|
2026-03-13 15:07:03 +08:00
|
|
|
|
|
2026-03-13 20:38:32 +08:00
|
|
|
|
## 测试覆盖
|
2026-03-13 15:07:03 +08:00
|
|
|
|
|
2026-03-13 20:38:32 +08:00
|
|
|
|
- Containers: 51+ 测试用例
|
|
|
|
|
|
- Memory: 19 测试用例
|
|
|
|
|
|
- Threading: 13 测试用例
|
|
|
|
|
|
- Math: 通过
|
2026-03-13 15:07:03 +08:00
|
|
|
|
|
|
|
|
|
|
## 文档
|
|
|
|
|
|
|
|
|
|
|
|
更多详细设计文档请参考 `docs/` 目录。
|
|
|
|
|
|
|
|
|
|
|
|
## 许可证
|
|
|
|
|
|
|
|
|
|
|
|
MIT License
|