diff --git a/shared/source/command_container/cmdcontainer.cpp b/shared/source/command_container/cmdcontainer.cpp index 0252a32edc..0c4abc5171 100644 --- a/shared/source/command_container/cmdcontainer.cpp +++ b/shared/source/command_container/cmdcontainer.cpp @@ -552,7 +552,7 @@ void CommandContainer::fillReusableAllocationLists() { defaultHeapAllocationAlignment, device->getRootDeviceIndex()); if (heapToReuse != nullptr) { - this->immediateCmdListCsr->makeResident(*heapToReuse); + this->getResidencyContainer().push_back(heapToReuse); } this->heapHelper->storeHeapAllocation(heapToReuse); } diff --git a/shared/source/command_container/cmdcontainer.h b/shared/source/command_container/cmdcontainer.h index 0323f645f7..a9527493e4 100644 --- a/shared/source/command_container/cmdcontainer.h +++ b/shared/source/command_container/cmdcontainer.h @@ -215,7 +215,7 @@ class CommandContainer : public NonCopyableOrMovableClass { IndirectHeap *getHeapWithRequiredSize(HeapType heapType, size_t sizeRequired, size_t alignment, bool allowGrow); void createAndAssignNewHeap(HeapType heapType, size_t size); IndirectHeap *initIndirectHeapReservation(ReservedIndirectHeap *indirectHeapReservation, size_t size, size_t alignment, HeapType heapType); - inline bool skipHeapAllocationCreation(HeapType heapType); + bool skipHeapAllocationCreation(HeapType heapType); size_t getHeapSize(HeapType heapType); void alignPrimaryEnding(void *endPtr, size_t exactUsedSize); 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 0dfc76a795..8d41d49730 100644 --- a/shared/test/unit_test/command_container/command_container_tests.cpp +++ b/shared/test/unit_test/command_container/command_container_tests.cpp @@ -39,6 +39,7 @@ class MyMockCommandContainer : public CommandContainer { using CommandContainer::getAlignedCmdBufferSize; using CommandContainer::immediateReusableAllocationList; using CommandContainer::secondaryCommandStreamForImmediateCmdList; + using CommandContainer::skipHeapAllocationCreation; GraphicsAllocation *allocateCommandBuffer(bool forceHostMemory) override { allocateCommandBufferCalled[!!forceHostMemory]++; @@ -1439,8 +1440,17 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenFillReusableAllocationListsThe ASSERT_NE(cmdContainer->immediateReusableAllocationList, nullptr); EXPECT_FALSE(cmdContainer->immediateReusableAllocationList->peekIsEmpty()); EXPECT_FALSE(heapHelper->storageForReuse->getAllocationsForReuse().peekIsEmpty()); - EXPECT_EQ(heapHelper->storageForReuse->getAllocationsForReuse().peekHead()->getResidencyTaskCount(csr->getOsContext().getContextId()), 1u); - EXPECT_EQ(cmdContainer->getResidencyContainer().size(), actualResidencyContainerSize + 1); + EXPECT_EQ(heapHelper->storageForReuse->getAllocationsForReuse().peekHead()->getResidencyTaskCount(csr->getOsContext().getContextId()), GraphicsAllocation::objectNotResident); + auto &gfxCoreHelper = pDevice->getGfxCoreHelper(); + auto amountToFill = gfxCoreHelper.getAmountOfAllocationsToFill(); + uint32_t numHeaps = 0; + for (int heapType = 0; heapType < IndirectHeap::Type::numTypes; heapType++) { + if (!cmdContainer->skipHeapAllocationCreation(static_cast(heapType))) { + numHeaps++; + } + } + auto numAllocsAddedToResidencyContainer = amountToFill + (amountToFill * numHeaps); + EXPECT_EQ(cmdContainer->getResidencyContainer().size(), actualResidencyContainerSize + numAllocsAddedToResidencyContainer); cmdContainer.reset(); allocList.freeAllGraphicsAllocations(pDevice); @@ -1463,7 +1473,16 @@ TEST_F(CommandContainerTest, givenCreateSecondaryCmdBufferInHostMemWhenFillReusa ASSERT_NE(cmdContainer->immediateReusableAllocationList, nullptr); EXPECT_FALSE(cmdContainer->immediateReusableAllocationList->peekIsEmpty()); - EXPECT_EQ(cmdContainer->getResidencyContainer().size(), actualResidencyContainerSize + 2); + auto &gfxCoreHelper = pDevice->getGfxCoreHelper(); + auto amountToFill = gfxCoreHelper.getAmountOfAllocationsToFill(); + uint32_t numHeaps = 0; + for (int heapType = 0; heapType < IndirectHeap::Type::numTypes; heapType++) { + if (!cmdContainer->skipHeapAllocationCreation(static_cast(heapType))) { + numHeaps++; + } + } + auto numAllocsAddedToResidencyContainer = 2 * amountToFill + (amountToFill * numHeaps); + EXPECT_EQ(cmdContainer->getResidencyContainer().size(), actualResidencyContainerSize + numAllocsAddedToResidencyContainer); cmdContainer.reset(); allocList.freeAllGraphicsAllocations(pDevice);