diff --git a/shared/source/command_container/cmdcontainer.cpp b/shared/source/command_container/cmdcontainer.cpp index 048a747d06..2756ec92a4 100644 --- a/shared/source/command_container/cmdcontainer.cpp +++ b/shared/source/command_container/cmdcontainer.cpp @@ -473,6 +473,12 @@ void CommandContainer::fillReusableAllocationLists() { auto allocToReuse = this->allocateCommandBuffer(); this->immediateReusableAllocationList->pushTailOne(*allocToReuse); this->getResidencyContainer().push_back(allocToReuse); + + if (this->useSecondaryCommandStream) { + auto hostAllocToReuse = this->allocateCommandBuffer(true); + this->immediateReusableAllocationList->pushTailOne(*hostAllocToReuse); + this->getResidencyContainer().push_back(hostAllocToReuse); + } } if (!this->heapHelper) { diff --git a/shared/test/unit_test/command_container/command_container_tests.cpp b/shared/test/unit_test/command_container/command_container_tests.cpp index 9abe43dde0..486f2a41cb 100644 --- a/shared/test/unit_test/command_container/command_container_tests.cpp +++ b/shared/test/unit_test/command_container/command_container_tests.cpp @@ -1394,6 +1394,29 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenFillReusableAllocationListsThe allocList.freeAllGraphicsAllocations(pDevice); } +TEST_F(CommandContainerTest, givenCreateSecondaryCmdBufferInHostMemWhenFillReusableAllocationListsThenCreateAlocsForSecondaryCmdBuffer) { + DebugManagerStateRestore dbgRestore; + DebugManager.flags.SetAmountOfReusableAllocations.set(1); + auto cmdContainer = std::make_unique(); + auto csr = pDevice->getDefaultEngine().commandStreamReceiver; + + AllocationsList allocList; + cmdContainer->initialize(pDevice, &allocList, true, true); + cmdContainer->setImmediateCmdListCsr(csr); + + auto actualResidencyContainerSize = cmdContainer->getResidencyContainer().size(); + EXPECT_EQ(cmdContainer->immediateReusableAllocationList, nullptr); + + cmdContainer->fillReusableAllocationLists(); + + ASSERT_NE(cmdContainer->immediateReusableAllocationList, nullptr); + EXPECT_FALSE(cmdContainer->immediateReusableAllocationList->peekIsEmpty()); + EXPECT_EQ(cmdContainer->getResidencyContainer().size(), actualResidencyContainerSize + 2); + + cmdContainer.reset(); + allocList.freeAllGraphicsAllocations(pDevice); +} + TEST_F(CommandContainerTest, givenCmdContainerWhenFillReusableAllocationListsWithSharedHeapsEnabledThenOnlyOneHeapFilled) { DebugManagerStateRestore dbgRestore; DebugManager.flags.SetAmountOfReusableAllocations.set(1);