docs: 修正 API 文档准确性 (第四轮检查)

修复问题:
- containers: HashMap 实现描述修正
- debug: XE_LOG 宏参数顺序修正
- memory: ProxyAllocator 统计示例修正, PoolAllocator allocate size 检查描述
- resources: ResourceManager 缺失 UnloadGroup 方法
- rhi: D3D12 格式枚举名称修正, Texture Format 枚举补全, ResourceStates 补充
- threading: TaskGroup GetProgress/Wait/Cancel 实现限制说明
This commit is contained in:
2026-03-19 00:43:16 +08:00
parent 870cb3116e
commit 82cf147817
13 changed files with 41 additions and 21 deletions

View File

@@ -8,7 +8,7 @@
## 概述
`HashMap<Key, Value>` 是一个模板哈希表容器,实现了分离链接法的哈希表,支持键值对的插入、查找和删除操作。
`HashMap<Key, Value>` 是一个模板哈希表容器,使用动态数组作为桶来解决哈希冲突,支持键值对的插入、查找和删除操作。
## 公共类型

View File

@@ -70,11 +70,11 @@ Logger::Get().AddSink(std::make_unique<FileLogSink>("app.log"));
Logger::Get().SetMinimumLevel(LogLevel::Debug);
// 记录日志
XE_LOG(LogCategory::Rendering, LogLevel::Info, "Render started");
XE_LOG(LogLevel::Info, LogCategory::Rendering, "Render started");
// 使用宏记录日志
if (condition) {
XE_LOG(LogCategory::General, LogLevel::Error, "Something went wrong");
XE_LOG(LogLevel::Error, LogCategory::General, "Something went wrong");
}
```

View File

@@ -4,10 +4,10 @@
void* Allocate(size_t size, size_t alignment = 0) override;
```
从内存池中分配一个空闲块。此方法忽略 `size` 参数,始终分配一个固定大小的块。如果池中没有空闲块,返回 `nullptr`。分配操作从空闲链表头部取出一个块。
从内存池中分配一个空闲块。每次分配一个固定大小的块。如果 `size` 超过块大小或池中没有空闲块,返回 `nullptr`。分配操作从空闲链表头部取出一个块。
**参数:**
- `size` - 被忽略(始终分配固定块大小)
- `size` - 请求的大小,如果超过构造时指定的块大小则分配失败
- `alignment` - 被忽略(构造时确定)
**返回:** 分配成功返回块指针,池空返回 `nullptr`

View File

@@ -29,11 +29,10 @@ proxy.Free(p1);
proxy.Free(p2);
const auto& stats = proxy.GetStats();
// totalFreed 累加了每次释放时的 allocationCount
// totalFreed 累加了每次释放时的 allocationCount(次数,非字节)
// allocationCount 最终为 0
printf("Total allocated: %zu, Total freed: %zu, Current: %zu\n",
stats.totalAllocated, stats.totalFreed,
stats.totalAllocated - stats.totalFreed);
printf("Total allocated: %zu bytes, Freed count: %zu, Current count: %zu\n",
stats.totalAllocated, stats.totalFreed, stats.allocationCount);
```
## 相关文档

View File

@@ -27,12 +27,12 @@ proxy.Free(proxy.Allocate(256));
const ProxyAllocator::Stats& stats = proxy.GetStats();
printf("Total allocated: %zu bytes\n", stats.totalAllocated);
printf("Total freed: %zu bytes\n", stats.totalFreed);
printf("Total freed: %zu times\n", stats.totalFreed);
printf("Peak allocated: %zu bytes\n", stats.peakAllocated);
printf("Allocation count: %zu\n", stats.allocationCount);
printf("Memory overhead: %zu bytes\n", stats.memoryOverhead);
printf("Current in use: %zu bytes\n",
stats.totalAllocated - stats.totalFreed);
stats.totalAllocated - stats.allocationCount * sizeof(/* typical block */ size_t));
```
## 相关文档

View File

@@ -74,9 +74,12 @@
| `UnorderedAccess` | 无序访问 |
| `DepthWrite` | 深度写入 |
| `DepthRead` | 深度读取 |
| `NonPixelShaderResource` | 非像素着色器资源 |
| `PixelShaderResource` | 像素着色器资源 |
| `CopySrc` | 复制源 |
| `CopyDst` | 复制目标 |
| `Present` | 呈现状态 |
| `GenericRead` | 通用读取 |
## 使用示例

View File

@@ -28,7 +28,7 @@ O(1)
## 示例
```cpp
D3D12_RENDER_TARGET_VIEW_DESC desc = D3D12RenderTargetView::CreateDesc(Format::R8G8B8A8_UNORM);
D3D12_RENDER_TARGET_VIEW_DESC desc = D3D12RenderTargetView::CreateDesc(Format::R8G8B8A8_UNorm);
```
## 相关文档

View File

@@ -29,7 +29,7 @@ O(1)
## 示例
```cpp
D3D12_SHADER_RESOURCE_VIEW_DESC desc = D3D12ShaderResourceView::CreateDesc(Format::R8G8B8A8_UNORM);
D3D12_SHADER_RESOURCE_VIEW_DESC desc = D3D12ShaderResourceView::CreateDesc(Format::R8G8B8A8_UNorm);
```
## 相关文档

View File

@@ -27,7 +27,7 @@ O(1)
## 示例
```cpp
TextureDesc td = { TextureType::Texture2D, 1920, 1080, 1, Format::R8G8B8A8_UNORM };
TextureDesc td = { TextureType::Texture2D, 1920, 1080, 1, Format::R8G8B8A8_UNorm };
D3D12_RESOURCE_DESC d3d12Desc = ToD3D12(td);
```

View File

@@ -55,11 +55,26 @@
| 格式 | 描述 |
|------|------|
| `Format::Unknown` | 未知格式 |
| `Format::R8_UNorm` | 单通道 8 位归一化 |
| `Format::R8G8_UNorm` | 双通道 8 位归一化 |
| `Format::R8G8B8A8_UNorm` | 四通道 8 位归一化 |
| `Format::R16G16B16A16_Float` | 四通道 16 位浮点 |
| `Format::R32G32B32A32_Float` | 四通道 32 位浮点 |
| `Format::R16_Float` | 单通道 16 位浮点 |
| `Format::R32_Float` | 单通道 32 位浮点 |
| `Format::D16_UNorm` | 16 位深度 |
| `Format::D24_UNorm_S8_UInt` | 24 位深度 + 8 位模板 |
| `Format::D32_Float` | 32 位深度 |
| `Format::BC1_UNorm` | BC1 压缩 (DXT1) |
| `Format::BC2_UNorm` | BC2 压缩 (DXT2/3) |
| `Format::BC3_UNorm` | BC3 压缩 (DXT4/5) |
| `Format::BC4_UNorm` | BC4 压缩 |
| `Format::BC5_UNorm` | BC5 压缩 |
| `Format::BC6H_UF16` | BC6H 压缩 (UF16) |
| `Format::BC7_UNorm` | BC7 高质量压缩 |
| `Format::R32G32B32A32_UInt` | 四通道 32 位无符号整数 |
| `Format::R32_UInt` | 单通道 32 位无符号整数 |
## 使用示例

View File

@@ -15,7 +15,8 @@ void Cancel()
**注意:**
- 已完成的任务不受影响。
- 正在执行的任务继续执行直到完成。
- 调用后所有 Wait/WaitFor 会立即返回。
- 调用后所有 Wait/WaitFor 会立即返回(但请参见下方警告)
- **警告**`Cancel()` 调用 `OnCancel()` 后不会减少待完成任务数,因此如果任务组中还有未执行的任务,调用 `Wait()` 会导致永久阻塞。建议在 `Cancel()` 后使用 `IsComplete()` 轮询或使用带超时的 `WaitFor()`
**示例:**

View File

@@ -12,6 +12,8 @@ float GetProgress() const
**复杂度:** O(1)
**注意:** 当前实现中 `m_completedCount` 未被更新,此方法始终返回 0.0f(任务组为空时返回 1.0f)。此为实现限制。
**示例:**
```cpp
@@ -21,13 +23,10 @@ for (int i = 0; i < 1000; ++i) {
group->AddTask([i]() { ProcessItem(i); });
}
// 显示进度
// 显示进度(注意:当前实现始终返回 0.0f
while (!group->IsComplete()) {
float progress = group->GetProgress();
printf("\rLoading: [%-50s] %.1f%%",
std::string(50, '=').substr(0, (int)(progress * 50)).c_str(),
progress * 100.0f);
fflush(stdout);
printf("\rProgress: %.1f%%", progress * 100.0f);
Thread::Sleep(100);
}
printf("\n");

View File

@@ -12,7 +12,10 @@ void Wait()
**复杂度:** O(n)n 为任务数量
**注意:** 如果任务组已被取消,此方法将立即返回。
**注意:**
- 如果任务组已被取消,此方法将立即返回。
- 如果任务组中还有未执行且未被取消的任务,调用此方法将永久阻塞(这是当前实现的限制)。
- 建议使用 `WaitFor()` 代替以避免永久阻塞。
**示例:**