- Rename texture/dtor.md to destructor.md per template spec - Remove duplicate non-hyphenated fence docs (getnativehandle.md, issignaled.md, getcompletedvalue.md) - Fix template field issues: - swap-chain, command-queue: 类型 now uses 'class (abstract)' - sampler: 头文件 now uses full path 'XCEngine/RHI/RHISampler.h' - types: 类型 fixed from 'structs' to 'struct' - enums: 类型 fixed from 'enums' to 'enum class' - Fix include paths in command-queue and pipeline-layout code examples - Create missing constructor/destructor docs for 11 classes: buffer, texture, shader, device, command-list, command-queue, fence, sampler, swap-chain, pipeline-state, pipeline-layout - Update class overview pages to include constructor/destructor entries
77 lines
2.6 KiB
Markdown
77 lines
2.6 KiB
Markdown
# RHICommandQueue
|
||
|
||
**命名空间**: `XCEngine::RHI`
|
||
|
||
**类型**: `class` (abstract)
|
||
|
||
**头文件**: `XCEngine/RHI/RHICommandQueue.h`
|
||
|
||
**描述**: GPU 命令队列抽象接口,负责提交和执行命令列表,以及 GPU/CPU 同步。
|
||
|
||
## 概述
|
||
|
||
`RHICommandQueue` 是 RHI(Render Hardware Interface)系统中的核心抽象接口之一,封装了底层图形 API(D3D12/Vulkan/Metal 等)的命令队列功能。
|
||
|
||
主要职责:
|
||
- **命令提交**:将准备好的命令列表提交到 GPU 执行
|
||
- **GPU/CPU 同步**:通过栅栏(Fence)机制协调 CPU 和 GPU 的执行顺序
|
||
- **队列类型管理**:区分直接队列、计算队列和复制队列
|
||
|
||
使用场景:
|
||
- 渲染循环中提交绘制命令
|
||
- 资源在 GPU 和 CPU 之间传输时的同步
|
||
- 多线程渲染时的命令生成和提交
|
||
|
||
## 公共方法
|
||
|
||
| 方法 | 描述 |
|
||
|------|------|
|
||
| [`RHICommandQueue`](constructor.md) | 默认构造函数 |
|
||
| [`~RHICommandQueue`](destructor.md) | 虚析构函数 |
|
||
| [`Shutdown`](shutdown.md) | 关闭并释放资源 |
|
||
| [`ExecuteCommandLists`](execute-command-lists.md) | 执行命令列表 |
|
||
| [`Signal`](signal.md) | 向栅栏发送信号 |
|
||
| [`Wait`](wait.md) | 等待栅栏达到指定值 |
|
||
| [`GetCompletedValue`](get-completed-value.md) | 获取栅栏已完成的值 |
|
||
| [`WaitForIdle`](wait-for-idle.md) | 等待队列所有操作完成 |
|
||
| [`GetType`](get-type.md) | 获取队列类型 |
|
||
| [`GetTimestampFrequency`](get-timestamp-frequency.md) | 获取时间戳频率 |
|
||
| [`GetNativeHandle`](get-native-handle.md) | 获取原生句柄 |
|
||
|
||
## 使用示例
|
||
|
||
```cpp
|
||
#include <XCEngine/RHI/RHICommandQueue.h>
|
||
#include <XCEngine/RHI/RHIDevice.h>
|
||
#include <XCEngine/RHI/RHIFence.h>
|
||
#include <XCEngine/RHI/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();
|
||
|
||
void* lists[1] = { commandList };
|
||
commandQueue->ExecuteCommandLists(1, lists);
|
||
commandQueue->Signal(fence, 1);
|
||
fence->Wait(1);
|
||
|
||
commandQueue->WaitForIdle();
|
||
commandQueue->Shutdown();
|
||
}
|
||
```
|
||
|
||
## 相关文档
|
||
|
||
- [RHI 模块](../rhi.md) - RHI 模块总览
|
||
- [RHICommandList](../command-list/command-list.md) - 命令列表
|
||
- [RHIFence](../fence/fence.md) - 同步栅栏
|