fix: reset d3d12 command allocators before reuse

This commit is contained in:
2026-03-28 16:37:38 +08:00
parent ec1535ad25
commit 519bc1dbf2
2 changed files with 14 additions and 1 deletions

View File

@@ -90,6 +90,7 @@ void D3D12CommandList::Shutdown() {
void D3D12CommandList::Reset() {
if (m_commandList && m_commandAllocator) {
m_commandAllocator->Reset();
m_commandList->Reset(m_commandAllocator.Get(), nullptr);
}
m_currentTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;

View File

@@ -11,4 +11,16 @@ TEST_F(D3D12TestFixture, CommandList_Close_Basic) {
TEST_F(D3D12TestFixture, CommandList_Get_Desc) {
auto type = GetCommandList()->GetCommandList()->GetType();
EXPECT_EQ(type, D3D12_COMMAND_LIST_TYPE_DIRECT);
}
}
TEST_F(D3D12TestFixture, CommandList_Reset_AfterExecute_ReopensCommandList) {
GetCommandList()->Close();
void* commandLists[] = { GetCommandList() };
GetCommandQueue()->ExecuteCommandLists(1, commandLists);
GetCommandQueue()->WaitForPreviousFrame();
GetCommandList()->Reset();
EXPECT_TRUE(SUCCEEDED(GetCommandList()->GetCommandList()->Close()));
}