refactor: 将 tests/D3D12 的 CommandList 替换为 D3D12CommandList 类

- 将全局 ID3D12GraphicsCommandList 替换为 D3D12CommandList
- 更新初始化、Reset、Close 调用
- 修复 Initialize 中不应调用 Close() 的问题
- 测试通过,截图与 GT.ppm 完全匹配
This commit is contained in:
2026-03-15 18:10:16 +08:00
parent bf37b1c00c
commit 7050e88c49
4 changed files with 17 additions and 21 deletions

View File

@@ -41,7 +41,7 @@ public:
D3D12CommandList();
~D3D12CommandList();
bool Initialize(ID3D12Device* device, CommandQueueType type = CommandQueueType::Direct);
bool Initialize(ID3D12Device* device, CommandQueueType type = CommandQueueType::Direct, ID3D12CommandAllocator* allocator = nullptr);
void Shutdown();
void Reset(ID3D12CommandAllocator* allocator);

View File

@@ -15,23 +15,13 @@ D3D12CommandList::~D3D12CommandList() {
Shutdown();
}
bool D3D12CommandList::Initialize(ID3D12Device* device, CommandQueueType type) {
bool D3D12CommandList::Initialize(ID3D12Device* device, CommandQueueType type, ID3D12CommandAllocator* allocator) {
D3D12_COMMAND_LIST_TYPE listType = ToD3D12(type);
ComPtr<ID3D12CommandAllocator> tempAllocator;
HRESULT hResult = device->CreateCommandAllocator(
listType,
IID_PPV_ARGS(&tempAllocator)
);
if (FAILED(hResult)) {
return false;
}
hResult = device->CreateCommandList(
HRESULT hResult = device->CreateCommandList(
0,
listType,
tempAllocator.Get(),
allocator,
nullptr,
IID_PPV_ARGS(&m_commandList)
);
@@ -42,7 +32,6 @@ bool D3D12CommandList::Initialize(ID3D12Device* device, CommandQueueType type) {
m_type = type;
m_commandList->Close();
return true;
}