docs: 重构 API 文档结构并修正源码准确性

- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
  - math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
  - containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
  - core: 修复 types 链接错误
  - debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
  - memory: 修复头文件路径, malloc vs operator new, 新增方法文档
  - resources: 修复 Shader/Texture 链接错误
  - threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
This commit is contained in:
2026-03-19 00:22:30 +08:00
parent d0e16962c8
commit dc850d7739
1012 changed files with 26673 additions and 9222 deletions

View File

@@ -0,0 +1,22 @@
# RHICommandList::ClearDepthStencil
```cpp
virtual void ClearDepthStencil(void* depthStencil, float depth, uint8_t stencil) = 0;
```
清除深度模板缓冲区。
**参数:**
- `depthStencil` - 深度模板缓冲区指针
- `depth` - 深度值
- `stencil` - 模板值
**示例:**
```cpp
cmdList->ClearDepthStencil(depthStencil, 1.0f, 0);
```
## 相关文档
- [RHICommandList 总览](command-list.md) - 返回类总览

View File

@@ -0,0 +1,22 @@
# RHICommandList::ClearRenderTarget
```cpp
virtual void ClearRenderTarget(void* renderTarget, const float color[4]) = 0;
```
清除渲染目标。
**参数:**
- `renderTarget` - 渲染目标指针
- `color` - 清除颜色 [r, g, b, a]
**示例:**
```cpp
float color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
cmdList->ClearRenderTarget(renderTarget, color);
```
## 相关文档
- [RHICommandList 总览](command-list.md) - 返回类总览

View File

@@ -0,0 +1,102 @@
# RHICommandList
**命名空间**: `XCEngine::RHI`
**类型**: `class` (abstract)
**描述**: GPU 命令列表抽象接口,用于录制和执行 GPU 命令。
## 公共方法
### 命令录制控制
| 方法 | 文档 |
|------|------|
| `Reset` | [详细文档](../../resources/resourcehandle/reset.md) |
| `Close` | [详细文档](../../core/filewriter/close.md) |
### 资源状态转换
| 方法 | 文档 |
|------|------|
| `TransitionBarrier` | [详细文档](transition-barrier.md) |
### 渲染状态设置
| 方法 | 文档 |
|------|------|
| `SetPipelineState` | [详细文档](set-pipeline-state.md) |
| `SetPrimitiveTopology` | [详细文档](set-primitive-topology.md) |
| `SetViewport` | [详细文档](set-viewport.md) |
| `SetViewports` | [详细文档](set-viewports.md) |
| `SetScissorRect` | [详细文档](set-scissor-rect.md) |
| `SetScissorRects` | [详细文档](set-scissor-rects.md) |
| `SetRenderTargets` | [详细文档](set-render-targets.md) |
### 深度/混合状态
| 方法 | 文档 |
|------|------|
| `SetDepthStencilState` | [详细文档](set-depth-stencil-state.md) |
| `SetStencilRef` | [详细文档](set-stencil-ref.md) |
| `SetBlendState` | [详细文档](set-blend-state.md) |
| `SetBlendFactor` | [详细文档](set-blend-factor.md) |
### 顶点/索引缓冲
| 方法 | 文档 |
|------|------|
| `SetVertexBuffer` | [详细文档](set-vertex-buffer.md) |
| `SetVertexBuffers` | [详细文档](set-vertex-buffers.md) |
| `SetIndexBuffer` | [详细文档](set-index-buffer.md) |
### 绘制命令
| 方法 | 文档 |
|------|------|
| `Draw` | [详细文档](draw.md) |
| `DrawIndexed` | [详细文档](draw-indexed.md) |
### 清除命令
| 方法 | 文档 |
|------|------|
| `Clear` | [详细文档](../../memory/linear-allocator/clear.md) |
| `ClearRenderTarget` | [详细文档](clear-render-target.md) |
| `ClearDepthStencil` | [详细文档](clear-depth-stencil.md) |
### 资源复制
| 方法 | 文档 |
|------|------|
| `CopyResource` | [详细文档](copy-resource.md) |
### 计算着色器
| 方法 | 文档 |
|------|------|
| `Dispatch` | [详细文档](dispatch.md) |
### 生命周期
| 方法 | 文档 |
|------|------|
| `Shutdown` | [详细文档](../../threading/task-system/shutdown.md) |
## 使用示例
```cpp
commandList->Reset();
commandList->SetPipelineState(pipelineState);
commandList->SetPrimitiveTopology(PrimitiveTopology::TriangleList);
commandList->SetViewport(viewport);
commandList->SetRenderTargets(1, &renderTarget, depthStencil);
commandList->DrawIndexed(indexCount, 1, 0, 0, 0);
commandList->Close();
commandQueue->ExecuteCommandLists(1, (void**)&commandList);
```
## 相关文档
- [../rhi/rhi.md](../rhi.md) - RHI 模块总览
- [RHICommandQueue](../command-queue/command-queue.md) - 命令队列

View File

@@ -0,0 +1,21 @@
# RHICommandList::CopyResource
```cpp
virtual void CopyResource(void* dst, void* src) = 0;
```
复制资源。
**参数:**
- `dst` - 目标资源
- `src` - 源资源
**示例:**
```cpp
cmdList->CopyResource(dstTexture, srcTexture);
```
## 相关文档
- [RHICommandList 总览](command-list.md) - 返回类总览

View File

@@ -0,0 +1,22 @@
# RHICommandList::Dispatch
```cpp
virtual void Dispatch(uint32_t x, uint32_t y, uint32_t z) = 0;
```
分发计算着色器。
**参数:**
- `x` - X 方向线程组数量
- `y` - Y 方向线程组数量
- `z` - Z 方向线程组数量
**示例:**
```cpp
cmdList->Dispatch(8, 8, 1); // 分发 8x8x1 线程组
```
## 相关文档
- [RHICommandList 总览](command-list.md) - 返回类总览

View File

@@ -0,0 +1,24 @@
# RHICommandList::DrawIndexed
```cpp
virtual void DrawIndexed(uint32_t indexCount, uint32_t instanceCount = 1, uint32_t startIndex = 0, int32_t baseVertex = 0, uint32_t startInstance = 0) = 0;
```
绘制索引图元。
**参数:**
- `indexCount` - 索引数量
- `instanceCount` - 实例数量默认1
- `startIndex` - 起始索引
- `baseVertex` - 基础顶点索引
- `startInstance` - 起始实例索引
**示例:**
```cpp
cmdList->DrawIndexed(36); // 绘制36个索引
```
## 相关文档
- [RHICommandList 总览](command-list.md) - 返回类总览

View File

@@ -0,0 +1,23 @@
# RHICommandList::Draw
```cpp
virtual void Draw(uint32_t vertexCount, uint32_t instanceCount = 1, uint32_t startVertex = 0, uint32_t startInstance = 0) = 0;
```
绘制调用。
**参数:**
- `vertexCount` - 顶点数量
- `instanceCount` - 实例数量默认1
- `startVertex` - 起始顶点索引
- `startInstance` - 起始实例索引
**示例:**
```cpp
cmdList->Draw(36); // 绘制36个顶点
```
## 相关文档
- [RHICommandList 总览](command-list.md) - 返回类总览

View File

@@ -0,0 +1,201 @@
# RHICommandList 方法
## Reset
```cpp
virtual void Reset() = 0;
```
重置命令列表,开始新的录制。
## Close
```cpp
virtual void Close() = 0;
```
关闭命令列表,结束录制。
## TransitionBarrier
```cpp
virtual void TransitionBarrier(void* resource, ResourceStates stateBefore, ResourceStates stateAfter) = 0;
```
资源状态转换屏障。
## SetPipelineState
```cpp
virtual void SetPipelineState(void* pso) = 0;
```
设置管线状态对象。
## SetPrimitiveTopology
```cpp
virtual void SetPrimitiveTopology(PrimitiveTopology topology) = 0;
```
设置图元拓扑。
## SetViewport
```cpp
virtual void SetViewport(const Viewport& viewport) = 0;
```
设置视口。
## SetViewports
```cpp
virtual void SetViewports(uint32_t count, const Viewport* viewports) = 0;
```
设置多个视口。
## SetScissorRect
```cpp
virtual void SetScissorRect(const Rect& rect) = 0;
```
设置裁剪矩形。
## SetScissorRects
```cpp
virtual void SetScissorRects(uint32_t count, const Rect* rects) = 0;
```
设置多个裁剪矩形。
## SetRenderTargets
```cpp
virtual void SetRenderTargets(uint32_t count, void** renderTargets, void* depthStencil = nullptr) = 0;
```
设置渲染目标。
## SetDepthStencilState
```cpp
virtual void SetDepthStencilState(const DepthStencilState& state) = 0;
```
设置深度模板状态。
## SetStencilRef
```cpp
virtual void SetStencilRef(uint8_t ref) = 0;
```
设置模板参考值。
## SetBlendState
```cpp
virtual void SetBlendState(const BlendState& state) = 0;
```
设置混合状态。
## SetBlendFactor
```cpp
virtual void SetBlendFactor(const float factor[4]) = 0;
```
设置混合因子。
## SetVertexBuffer
```cpp
virtual void SetVertexBuffer(uint32_t slot, void* buffer, uint64_t offset, uint32_t stride) = 0;
```
设置顶点缓冲。
## SetVertexBuffers
```cpp
virtual void SetVertexBuffers(uint32_t startSlot, uint32_t count, const uint64_t* buffers, const uint64_t* offsets, const uint32_t* strides) = 0;
```
设置多个顶点缓冲。
## SetIndexBuffer
```cpp
virtual void SetIndexBuffer(void* buffer, uint64_t offset, Format format) = 0;
```
设置索引缓冲。
## Draw
```cpp
virtual void Draw(uint32_t vertexCount, uint32_t instanceCount = 1, uint32_t startVertex = 0, uint32_t startInstance = 0) = 0;
```
绘制调用。
## DrawIndexed
```cpp
virtual void DrawIndexed(uint32_t indexCount, uint32_t instanceCount = 1, uint32_t startIndex = 0, int32_t baseVertex = 0, uint32_t startInstance = 0) = 0;
```
索引绘制调用。
## Clear
```cpp
virtual void Clear(float r, float g, float b, float a, uint32_t buffers) = 0;
```
清除缓冲。
## ClearRenderTarget
```cpp
virtual void ClearRenderTarget(void* renderTarget, const float color[4]) = 0;
```
清除渲染目标。
## ClearDepthStencil
```cpp
virtual void ClearDepthStencil(void* depthStencil, float depth, uint8_t stencil) = 0;
```
清除深度模板。
## CopyResource
```cpp
virtual void CopyResource(void* dst, void* src) = 0;
```
复制资源。
## Dispatch
```cpp
virtual void Dispatch(uint32_t x, uint32_t y, uint32_t z) = 0;
```
分发计算着色器。
## Shutdown
```cpp
virtual void Shutdown() = 0;
```
释放命令列表资源。

View File

@@ -0,0 +1,21 @@
# RHICommandList::SetBlendFactor
```cpp
virtual void SetBlendFactor(const float factor[4]) = 0;
```
设置混合因子。
**参数:**
- `factor` - 混合因子数组 [r, g, b, a]
**示例:**
```cpp
float factor[4] = {0.5f, 0.5f, 0.5f, 1.0f};
cmdList->SetBlendFactor(factor);
```
## 相关文档
- [RHICommandList 总览](command-list.md) - 返回类总览

View File

@@ -0,0 +1,23 @@
# RHICommandList::SetBlendState
```cpp
virtual void SetBlendState(const BlendState& state) = 0;
```
设置混合状态。
**参数:**
- `state` - 混合状态结构体
**示例:**
```cpp
BlendState blendState;
blendState.alphaToCoverageEnable = false;
blendState.independentBlendEnable = false;
cmdList->SetBlendState(blendState);
```
## 相关文档
- [RHICommandList 总览](command-list.md) - 返回类总览

View File

@@ -0,0 +1,24 @@
# RHICommandList::SetDepthStencilState
```cpp
virtual void SetDepthStencilState(const DepthStencilState& state) = 0;
```
设置深度模板状态。
**参数:**
- `state` - 深度模板状态结构体
**示例:**
```cpp
DepthStencilState dsState;
dsState.depthEnable = true;
dsState.depthWriteMask = true;
dsState.depthFunc = ComparisonFunc::Less;
cmdList->SetDepthStencilState(dsState);
```
## 相关文档
- [RHICommandList 总览](command-list.md) - 返回类总览

View File

@@ -0,0 +1,22 @@
# RHICommandList::SetIndexBuffer
```cpp
virtual void SetIndexBuffer(void* buffer, uint64_t offset, Format format) = 0;
```
设置索引缓冲区。
**参数:**
- `buffer` - 索引缓冲区指针
- `offset` - 数据偏移量
- `format` - 索引格式R16_UINT 或 R32_UINT
**示例:**
```cpp
cmdList->SetIndexBuffer(indexBuffer, 0, Format::R16_UINT);
```
## 相关文档
- [RHICommandList 总览](command-list.md) - 返回类总览

View File

@@ -0,0 +1,20 @@
# RHICommandList::SetPipelineState
```cpp
virtual void SetPipelineState(void* pso) = 0;
```
设置渲染管线状态对象。
**参数:**
- `pso` - 管线状态对象指针
**示例:**
```cpp
cmdList->SetPipelineState(pipelineState);
```
## 相关文档
- [RHICommandList 总览](command-list.md) - 返回类总览

View File

@@ -0,0 +1,20 @@
# RHICommandList::SetPrimitiveTopology
```cpp
virtual void SetPrimitiveTopology(PrimitiveTopology topology) = 0;
```
设置图元拓扑类型。
**参数:**
- `topology` - 图元拓扑类型(点、线、三角形等)
**示例:**
```cpp
cmdList->SetPrimitiveTopology(PrimitiveTopology::TriangleList);
```
## 相关文档
- [RHICommandList 总览](command-list.md) - 返回类总览

View File

@@ -0,0 +1,23 @@
# RHICommandList::SetRenderTargets
```cpp
virtual void SetRenderTargets(uint32_t count, void** renderTargets, void* depthStencil = nullptr) = 0;
```
设置渲染目标和深度模板缓冲区。
**参数:**
- `count` - 渲染目标数量
- `renderTargets` - 渲染目标数组
- `depthStencil` - 深度模板缓冲区(可选)
**示例:**
```cpp
void* targets[1] = {renderTarget};
cmdList->SetRenderTargets(1, targets, depthStencil);
```
## 相关文档
- [RHICommandList 总览](command-list.md) - 返回类总览

View File

@@ -0,0 +1,25 @@
# RHICommandList::SetScissorRect
```cpp
virtual void SetScissorRect(const Rect& rect) = 0;
```
设置裁剪矩形。
**参数:**
- `rect` - 裁剪矩形结构体
**示例:**
```cpp
Rect rect;
rect.left = 0;
rect.top = 0;
rect.right = 640;
rect.bottom = 480;
cmdList->SetScissorRect(rect);
```
## 相关文档
- [RHICommandList 总览](command-list.md) - 返回类总览

View File

@@ -0,0 +1,24 @@
# RHICommandList::SetScissorRects
```cpp
virtual void SetScissorRects(uint32_t count, const Rect* rects) = 0;
```
设置多个裁剪矩形。
**参数:**
- `count` - 裁剪矩形数量
- `rects` - 裁剪矩形数组指针
**示例:**
```cpp
Rect rects[2];
rects[0] = {0, 0, 640, 480};
rects[1] = {640, 0, 640, 480};
cmdList->SetScissorRects(2, rects);
```
## 相关文档
- [RHICommandList 总览](command-list.md) - 返回类总览

View File

@@ -0,0 +1,20 @@
# RHICommandList::SetStencilRef
```cpp
virtual void SetStencilRef(uint8_t ref) = 0;
```
设置模板参考值。
**参数:**
- `ref` - 模板参考值
**示例:**
```cpp
cmdList->SetStencilRef(0xFF);
```
## 相关文档
- [RHICommandList 总览](command-list.md) - 返回类总览

View File

@@ -0,0 +1,23 @@
# RHICommandList::SetVertexBuffer
```cpp
virtual void SetVertexBuffer(uint32_t slot, void* buffer, uint64_t offset, uint32_t stride) = 0;
```
设置顶点缓冲区。
**参数:**
- `slot` - 顶点缓冲区槽位
- `buffer` - 顶点缓冲区指针
- `offset` - 数据偏移量
- `stride` - 顶点步长
**示例:**
```cpp
cmdList->SetVertexBuffer(0, vertexBuffer, 0, sizeof(Vertex));
```
## 相关文档
- [RHICommandList 总览](command-list.md) - 返回类总览

View File

@@ -0,0 +1,27 @@
# RHICommandList::SetVertexBuffers
```cpp
virtual void SetVertexBuffers(uint32_t startSlot, uint32_t count, const uint64_t* buffers, const uint64_t* offsets, const uint32_t* strides) = 0;
```
设置多个顶点缓冲区。
**参数:**
- `startSlot` - 起始槽位
- `count` - 缓冲区数量
- `buffers` - 缓冲区指针数组
- `offsets` - 偏移量数组
- `strides` - 步长数组
**示例:**
```cpp
uint64_t buffers[2] = {(uint64_t)vb1, (uint64_t)vb2};
uint64_t offsets[2] = {0, 0};
uint32_t strides[2] = {sizeof(Vertex), sizeof(Vertex)};
cmdList->SetVertexBuffers(0, 2, buffers, offsets, strides);
```
## 相关文档
- [RHICommandList 总览](command-list.md) - 返回类总览

View File

@@ -0,0 +1,27 @@
# RHICommandList::SetViewport
```cpp
virtual void SetViewport(const Viewport& viewport) = 0;
```
设置视口。
**参数:**
- `viewport` - 视口结构体
**示例:**
```cpp
Viewport vp;
vp.topLeftX = 0;
vp.topLeftY = 0;
vp.width = 1280;
vp.height = 720;
vp.minDepth = 0.0f;
vp.maxDepth = 1.0f;
cmdList->SetViewport(vp);
```
## 相关文档
- [RHICommandList 总览](command-list.md) - 返回类总览

View File

@@ -0,0 +1,24 @@
# RHICommandList::SetViewports
```cpp
virtual void SetViewports(uint32_t count, const Viewport* viewports) = 0;
```
设置多个视口。
**参数:**
- `count` - 视口数量
- `viewports` - 视口数组指针
**示例:**
```cpp
Viewport viewports[2];
viewports[0] = {0, 0, 640, 720, 0.0f, 1.0f};
viewports[1] = {640, 0, 640, 720, 0.0f, 1.0f};
cmdList->SetViewports(2, viewports);
```
## 相关文档
- [RHICommandList 总览](command-list.md) - 返回类总览

View File

@@ -0,0 +1,23 @@
# RHICommandList::TransitionBarrier
```cpp
virtual void TransitionBarrier(void* resource, ResourceStates stateBefore, ResourceStates stateAfter) = 0;
```
设置资源状态转换屏障,确保 GPU 资源在状态转换前完成所有操作。
**参数:**
- `resource` - 目标资源指针
- `stateBefore` - 转换前的资源状态
- `stateAfter` - 转换后的资源状态
**示例:**
```cpp
// 将纹理从渲染目标状态转换到着色器读取状态
cmdList->TransitionBarrier(texture, ResourceStates::RenderTarget, ResourceStates::ShaderResource);
```
## 相关文档
- [RHICommandList 总览](command-list.md) - 返回类总览