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 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
|
# RHICommandQueue
|
|
|
|
|
|
|
|
|
|
|
|
**命名空间**: `XCEngine::RHI`
|
|
|
|
|
|
|
2026-03-20 02:35:45 +08:00
|
|
|
|
**类型**: `class` (抽象基类)
|
|
|
|
|
|
|
|
|
|
|
|
**头文件**: `XCEngine/RHI/RHICommandQueue.h`
|
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 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
|
|
|
|
|
|
|
**描述**: GPU 命令队列抽象接口,负责提交和执行命令列表,以及 GPU/CPU 同步。
|
|
|
|
|
|
|
2026-03-20 02:35:45 +08:00
|
|
|
|
## 概述
|
|
|
|
|
|
|
|
|
|
|
|
`RHICommandQueue` 是 RHI(Render Hardware Interface)系统中的核心抽象接口之一,封装了底层图形 API(D3D12/Vulkan/Metal 等)的命令队列功能。
|
|
|
|
|
|
|
|
|
|
|
|
主要职责:
|
|
|
|
|
|
- **命令提交**:将准备好的命令列表提交到 GPU 执行
|
|
|
|
|
|
- **GPU/CPU 同步**:通过栅栏(Fence)机制协调 CPU 和 GPU 的执行顺序
|
|
|
|
|
|
- **队列类型管理**:区分直接队列、计算队列和复制队列
|
|
|
|
|
|
|
|
|
|
|
|
使用场景:
|
|
|
|
|
|
- 渲染循环中提交绘制命令
|
|
|
|
|
|
- 资源在 GPU 和 CPU 之间传输时的同步
|
|
|
|
|
|
- 多线程渲染时的命令生成和提交
|
|
|
|
|
|
|
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 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
|
## 公共方法
|
|
|
|
|
|
|
2026-03-19 02:01:18 +08:00
|
|
|
|
| 方法 | 描述 |
|
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 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
|
|------|------|
|
2026-03-19 02:01:18 +08:00
|
|
|
|
| [`Shutdown`](shutdown.md) | 关闭并释放资源 |
|
|
|
|
|
|
| [`ExecuteCommandLists`](execute-command-lists.md) | 执行命令列表 |
|
2026-03-20 02:35:45 +08:00
|
|
|
|
| [`Signal`](signal.md) | 向栅栏发送信号 |
|
|
|
|
|
|
| [`Wait`](wait.md) | 等待栅栏达到指定值 |
|
|
|
|
|
|
| [`GetCompletedValue`](get-completed-value.md) | 获取栅栏已完成的值 |
|
|
|
|
|
|
| [`WaitForIdle`](wait-for-idle.md) | 等待队列所有操作完成 |
|
2026-03-19 02:01:18 +08:00
|
|
|
|
| [`GetType`](get-type.md) | 获取队列类型 |
|
|
|
|
|
|
| [`GetTimestampFrequency`](get-timestamp-frequency.md) | 获取时间戳频率 |
|
|
|
|
|
|
| [`GetNativeHandle`](get-native-handle.md) | 获取原生句柄 |
|
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 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
|
|
|
|
|
|
|
## 使用示例
|
|
|
|
|
|
|
|
|
|
|
|
```cpp
|
2026-03-20 02:35:45 +08:00
|
|
|
|
#include "RHICommandQueue.h"
|
|
|
|
|
|
#include "RHIDevice.h"
|
|
|
|
|
|
#include "RHIFence.h"
|
|
|
|
|
|
#include "RHICommandList.h"
|
|
|
|
|
|
|
|
|
|
|
|
void RenderLoop(RHIDevice* device, RHICommandQueue* cmdQueue) {
|
|
|
|
|
|
CommandQueueDesc queueDesc;
|
|
|
|
|
|
queueDesc.queueType = (uint32_t)CommandQueueType::Direct;
|
|
|
|
|
|
RHICommandQueue* commandQueue = device->CreateCommandQueue(queueDesc);
|
|
|
|
|
|
|
|
|
|
|
|
FenceDesc fenceDesc;
|
|
|
|
|
|
RHIFence* fence = device->CreateFence(fenceDesc);
|
|
|
|
|
|
|
|
|
|
|
|
RHICommandList* commandList = device->CreateCommandList();
|
|
|
|
|
|
commandList->Begin();
|
|
|
|
|
|
commandList->DrawInstanced(vertices, vertexCount, 0);
|
|
|
|
|
|
commandList->End();
|
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 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
|
|
2026-03-20 02:35:45 +08:00
|
|
|
|
void* lists[1] = { commandList };
|
|
|
|
|
|
commandQueue->ExecuteCommandLists(1, lists);
|
|
|
|
|
|
commandQueue->Signal(fence, 1);
|
|
|
|
|
|
fence->Wait(1);
|
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 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
|
|
2026-03-20 02:35:45 +08:00
|
|
|
|
commandQueue->WaitForIdle();
|
|
|
|
|
|
commandQueue->Shutdown();
|
|
|
|
|
|
}
|
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 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## 相关文档
|
|
|
|
|
|
|
2026-03-20 02:35:45 +08:00
|
|
|
|
- [RHI 模块](../rhi.md) - RHI 模块总览
|
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 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
|
- [RHICommandList](../command-list/command-list.md) - 命令列表
|
|
|
|
|
|
- [RHIFence](../fence/fence.md) - 同步栅栏
|