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

38 lines
842 B
Markdown
Raw Normal View History

2026-03-20 02:35:45 +08:00
# D3D12CommandAllocator::Initialize
```cpp
bool Initialize(ID3D12Device* device, CommandQueueType type = CommandQueueType::Direct);
```
初始化 D3D12 命令分配器,创建指定类型的命令分配器。
## 参数
| 参数 | 类型 | 描述 |
|------|------|------|
| `device` | `ID3D12Device*` | D3D12 设备指针 |
| `type` | `CommandQueueType` | 命令队列类型,默认值为 `Direct` |
## 返回值
`bool` - 初始化是否成功
## 示例
```cpp
D3D12CommandAllocator allocator;
if (allocator.Initialize(device, CommandQueueType::Direct)) {
// 分配器初始化成功
}
```
## 复杂度
O(1)
## 相关文档
- [D3D12CommandAllocator 总览](command-allocator.md) - 返回类总览
- [D3D12CommandAllocator::Reset](reset.md) - 重置分配器
- [D3D12CommandAllocator::Shutdown](shutdown.md) - 关闭分配器