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

51 lines
1.2 KiB
Markdown
Raw Normal View History

# D3D12CommandAllocator
**命名空间**: `XCEngine::RHI`
2026-03-20 02:35:45 +08:00
**类型**: `class` (standalone, does not inherit from base)
**描述**: DirectX 12 命令分配器的 D3D12 实现,用于管理 GPU 命令分配内存。
## 构造函数
| 方法 | 描述 |
|------|------|
| [`D3D12CommandAllocator`](constructor.md) | 默认构造函数 |
## 公共方法
| 方法 | 描述 |
|------|------|
2026-03-20 02:35:45 +08:00
| [`Initialize`](initialize.md) | 初始化命令分配器 |
| [`Shutdown`](shutdown.md) | 关闭命令分配器 |
| [`Reset`](reset.md) | 重置命令分配器 |
| [`IsReady`](is-ready.md) | 检查是否就绪 |
| [`GetCommandAllocator`](get-command-allocator.md) | 获取 D3D12 命令分配器 |
2026-03-20 02:35:45 +08:00
## 析构函数
| 方法 | 描述 |
|------|------|
| [`~D3D12CommandAllocator`](destructor.md) | 析构函数,自动调用 Shutdown |
## 使用示例
```cpp
#include <XCEngine/RHI/D3D12/D3D12CommandAllocator.h>
using namespace XCEngine::RHI;
D3D12CommandAllocator allocator;
if (allocator.Initialize(device, CommandQueueType::Direct)) {
allocator.Reset();
if (allocator.IsReady()) {
ID3D12CommandAllocator* native = allocator.GetCommandAllocator();
}
allocator.Shutdown();
}
```
## 相关文档
2026-03-20 02:35:45 +08:00
- [D3D12 后端总览](../../d3d12/d3d12.md)