Files
XCEngine/docs/api/rhi/d3d12/command-list/initialize.md

41 lines
985 B
Markdown
Raw Normal View History

2026-03-20 02:35:45 +08:00
# D3D12CommandList::Initialize
```cpp
bool Initialize(ID3D12Device* device, CommandQueueType type = CommandQueueType::Direct, ID3D12CommandAllocator* allocator = nullptr);
```
初始化 D3D12 命令列表,创建 `ID3D12GraphicsCommandList` 实例。
**参数:**
- `device` - D3D12 设备指针
- `type` - 命令队列类型,默认为 `CommandQueueType::Direct`
- `allocator` - 命令分配器指针,如果为 `nullptr`,则由方法内部创建
**返回值:**
- `bool` - 初始化成功返回 `true`,失败返回 `false`
**复杂度:** O(1)
**示例:**
```cpp
D3D12CommandList cmdList;
ID3D12Device* device = /* 获取设备 */;
if (!cmdList.Initialize(device)) {
// 处理初始化失败
return;
}
// 使用命令列表...
cmdList.Reset();
// ... 录制命令
cmdList.Close();
```
## 相关文档
- [D3D12CommandList 总览](command-list.md) - 返回类总览
- [Shutdown](shutdown.md) - 关闭命令列表
- [Close](close.md) - 关闭命令列表