diff --git a/runtime/command_stream/aub_command_stream_receiver_hw.inl b/runtime/command_stream/aub_command_stream_receiver_hw.inl index 941b16218d..07a1aa219c 100644 --- a/runtime/command_stream/aub_command_stream_receiver_hw.inl +++ b/runtime/command_stream/aub_command_stream_receiver_hw.inl @@ -668,7 +668,7 @@ void AUBCommandStreamReceiverHw::processResidency(ResidencyContainer template void AUBCommandStreamReceiverHw::makeNonResident(GraphicsAllocation &gfxAllocation) { if (gfxAllocation.residencyTaskCount[this->deviceIndex] != ObjectNotResident) { - this->pushAllocationForEviction(&gfxAllocation); + this->getEvictionAllocations().push_back(&gfxAllocation); gfxAllocation.residencyTaskCount[this->deviceIndex] = ObjectNotResident; } } diff --git a/runtime/command_stream/command_stream_receiver.cpp b/runtime/command_stream/command_stream_receiver.cpp index 00c032152c..67cbec9e4b 100644 --- a/runtime/command_stream/command_stream_receiver.cpp +++ b/runtime/command_stream/command_stream_receiver.cpp @@ -55,7 +55,7 @@ CommandStreamReceiver::~CommandStreamReceiver() { void CommandStreamReceiver::makeResident(GraphicsAllocation &gfxAllocation) { auto submissionTaskCount = this->taskCount + 1; if (gfxAllocation.residencyTaskCount[deviceIndex] < (int)submissionTaskCount) { - this->pushAllocationForResidency(&gfxAllocation); + this->getResidencyAllocations().push_back(&gfxAllocation); gfxAllocation.taskCount = submissionTaskCount; if (gfxAllocation.residencyTaskCount[deviceIndex] == ObjectNotResident) { this->totalMemoryUsed += gfxAllocation.getUnderlyingBufferSize(); @@ -65,14 +65,14 @@ void CommandStreamReceiver::makeResident(GraphicsAllocation &gfxAllocation) { } void CommandStreamReceiver::processEviction() { - this->clearEvictionAllocations(); + this->getEvictionAllocations().clear(); } void CommandStreamReceiver::makeNonResident(GraphicsAllocation &gfxAllocation) { if (gfxAllocation.residencyTaskCount[deviceIndex] != ObjectNotResident) { makeCoherent(gfxAllocation); if (gfxAllocation.peekEvictable()) { - this->pushAllocationForEviction(&gfxAllocation); + this->getEvictionAllocations().push_back(&gfxAllocation); } else { gfxAllocation.setEvictable(true); } @@ -88,11 +88,7 @@ void CommandStreamReceiver::makeSurfacePackNonResident(ResidencyContainer *alloc for (auto &surface : residencyAllocations) { this->makeNonResident(*surface); } - if (allocationsForResidency) { - residencyAllocations.clear(); - } else { - this->clearResidencyAllocations(); - } + residencyAllocations.clear(); this->processEviction(); } @@ -255,26 +251,10 @@ ResidencyContainer &CommandStreamReceiver::getResidencyAllocations() { return this->residencyAllocations; } -void CommandStreamReceiver::pushAllocationForResidency(GraphicsAllocation *gfxAllocation) { - this->residencyAllocations.push_back(gfxAllocation); -} - -void CommandStreamReceiver::clearResidencyAllocations() { - this->residencyAllocations.clear(); -} - ResidencyContainer &CommandStreamReceiver::getEvictionAllocations() { return this->evictionAllocations; } -void CommandStreamReceiver::pushAllocationForEviction(GraphicsAllocation *gfxAllocation) { - this->evictionAllocations.push_back(gfxAllocation); -} - -void CommandStreamReceiver::clearEvictionAllocations() { - this->evictionAllocations.clear(); -} - void CommandStreamReceiver::activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) {} GraphicsAllocation *CommandStreamReceiver::allocateDebugSurface(size_t size) { diff --git a/runtime/command_stream/command_stream_receiver.h b/runtime/command_stream/command_stream_receiver.h index 3f62b6f01d..a9c726f489 100644 --- a/runtime/command_stream/command_stream_receiver.h +++ b/runtime/command_stream/command_stream_receiver.h @@ -75,12 +75,7 @@ class CommandStreamReceiver { void setMemoryManager(MemoryManager *mm); ResidencyContainer &getResidencyAllocations(); - void pushAllocationForResidency(GraphicsAllocation *gfxAllocation); - void clearResidencyAllocations(); - ResidencyContainer &getEvictionAllocations(); - void pushAllocationForEviction(GraphicsAllocation *gfxAllocation); - void clearEvictionAllocations(); virtual GmmPageTableMngr *createPageTableManager() { return nullptr; } diff --git a/runtime/os_interface/windows/wddm_device_command_stream.inl b/runtime/os_interface/windows/wddm_device_command_stream.inl index c127693233..111e3f02d2 100644 --- a/runtime/os_interface/windows/wddm_device_command_stream.inl +++ b/runtime/os_interface/windows/wddm_device_command_stream.inl @@ -145,7 +145,7 @@ void WddmCommandStreamReceiver::processResidency(ResidencyContainer & template void WddmCommandStreamReceiver::processEviction() { getMemoryManager()->makeNonResidentEvictionAllocations(this->getEvictionAllocations()); - this->clearEvictionAllocations(); + this->getEvictionAllocations().clear(); } template diff --git a/unit_tests/command_stream/command_stream_receiver_tests.cpp b/unit_tests/command_stream/command_stream_receiver_tests.cpp index 8d2f38f73b..90a1fba439 100644 --- a/unit_tests/command_stream/command_stream_receiver_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_tests.cpp @@ -41,44 +41,6 @@ struct CommandStreamReceiverTest : public DeviceFixture, CommandStreamReceiver *commandStreamReceiver; }; -TEST_F(CommandStreamReceiverTest, givenValidCsrWhenPushingAllocationForResidencyThanAllocationsCountIsIncreated) { - ASSERT_EQ(0u, commandStreamReceiver->getResidencyAllocations().size()); - - GraphicsAllocation allocation(nullptr, 0); - commandStreamReceiver->pushAllocationForResidency(&allocation); - EXPECT_EQ(1u, commandStreamReceiver->getResidencyAllocations().size()); -} - -TEST_F(CommandStreamReceiverTest, givenValidCsrWhenClearingAllocationsForResidencyThenAllAllocationsAreRemoved) { - GraphicsAllocation allocation1(nullptr, 0); - GraphicsAllocation allocation2(nullptr, 0); - commandStreamReceiver->pushAllocationForResidency(&allocation1); - commandStreamReceiver->pushAllocationForResidency(&allocation2); - ASSERT_EQ(2u, commandStreamReceiver->getResidencyAllocations().size()); - - commandStreamReceiver->clearResidencyAllocations(); - EXPECT_EQ(0u, commandStreamReceiver->getResidencyAllocations().size()); -} - -TEST_F(CommandStreamReceiverTest, givenValidCsrWhenPushingAllocationForEvictionThanAllocationsCountIsIncreated) { - ASSERT_EQ(0u, commandStreamReceiver->getResidencyAllocations().size()); - - GraphicsAllocation allocation(nullptr, 0); - commandStreamReceiver->pushAllocationForEviction(&allocation); - EXPECT_EQ(1u, commandStreamReceiver->getEvictionAllocations().size()); -} - -TEST_F(CommandStreamReceiverTest, givenValidCsrWhenClearingAllocationsForEvictionThenAllAllocationsAreRemoved) { - GraphicsAllocation allocation1(nullptr, 0); - GraphicsAllocation allocation2(nullptr, 0); - commandStreamReceiver->pushAllocationForEviction(&allocation1); - commandStreamReceiver->pushAllocationForEviction(&allocation2); - ASSERT_EQ(2u, commandStreamReceiver->getEvictionAllocations().size()); - - commandStreamReceiver->clearEvictionAllocations(); - EXPECT_EQ(0u, commandStreamReceiver->getEvictionAllocations().size()); -} - HWTEST_F(CommandStreamReceiverTest, testCtor) { auto &csr = pDevice->getUltCommandStreamReceiver(); EXPECT_EQ(0u, csr.peekTaskLevel()); diff --git a/unit_tests/command_stream/tbx_command_stream_tests.cpp b/unit_tests/command_stream/tbx_command_stream_tests.cpp index 27236e5b91..26294fbdde 100644 --- a/unit_tests/command_stream/tbx_command_stream_tests.cpp +++ b/unit_tests/command_stream/tbx_command_stream_tests.cpp @@ -160,7 +160,7 @@ TEST(TbxCommandStreamReceiverTest, givenTbxCommandStreamReceiverWhenTypeIsChecke EXPECT_EQ(CommandStreamReceiverType::CSR_TBX, csr->getType()); } -HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenMakeResidentIsCalledForGraphicsAllocationThenItShouldPushAllocationForResidencyToMemoryManager) { +HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenMakeResidentIsCalledForGraphicsAllocationThenItShouldPushAllocationForResidencyToCsr) { TbxCommandStreamReceiverHw *tbxCsr = (TbxCommandStreamReceiverHw *)pCommandStreamReceiver; TbxMemoryManager *memoryManager = tbxCsr->getMemoryManager(); ASSERT_NE(nullptr, memoryManager); @@ -177,7 +177,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenMakeResidentIsC memoryManager->freeGraphicsMemory(graphicsAllocation); } -HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenMakeResidentHasAlreadyBeenCalledForGraphicsAllocationThenItShouldNotPushAllocationForResidencyAgainToMemoryManager) { +HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenMakeResidentHasAlreadyBeenCalledForGraphicsAllocationThenItShouldNotPushAllocationForResidencyAgainToCsr) { TbxCommandStreamReceiverHw *tbxCsr = (TbxCommandStreamReceiverHw *)pCommandStreamReceiver; TbxMemoryManager *memoryManager = tbxCsr->getMemoryManager(); ASSERT_NE(nullptr, memoryManager); @@ -228,8 +228,8 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenProcessResidenc EXPECT_EQ(ObjectNotResident, graphicsAllocation->residencyTaskCount[0u]); - tbxCsr->pushAllocationForResidency(graphicsAllocation); - tbxCsr->processResidency(tbxCsr->getResidencyAllocations(), *pDevice->getOsContext()); + ResidencyContainer allocationsForResidency = {graphicsAllocation}; + tbxCsr->processResidency(allocationsForResidency, *pDevice->getOsContext()); EXPECT_NE(ObjectNotResident, graphicsAllocation->residencyTaskCount[0u]); EXPECT_EQ((int)tbxCsr->peekTaskCount() + 1, graphicsAllocation->residencyTaskCount[0u]); diff --git a/unit_tests/os_interface/linux/drm_command_stream_tests.cpp b/unit_tests/os_interface/linux/drm_command_stream_tests.cpp index 2130ed0810..a591e78d4f 100644 --- a/unit_tests/os_interface/linux/drm_command_stream_tests.cpp +++ b/unit_tests/os_interface/linux/drm_command_stream_tests.cpp @@ -1176,7 +1176,7 @@ TEST_F(DrmCommandStreamLeaksTest, makeResidentTwice) { EXPECT_EQ(buffer, bo1); EXPECT_EQ(1u, bo1->getRefCount()); - csr->clearResidencyAllocations(); + csr->getResidencyAllocations().clear(); csr->makeResident(*allocation); csr->processResidency(csr->getResidencyAllocations(), *osContext); @@ -1368,7 +1368,7 @@ TEST_F(DrmCommandStreamLeaksTest, GivenAllocationsContainingDifferentCountOfFrag EXPECT_EQ(1u, bo->getRefCount()); } mm->freeGraphicsMemory(allocation); - csr->clearResidencyAllocations(); + csr->getResidencyAllocations().clear(); EXPECT_EQ(0u, hostPtrManager.getFragmentCount()); @@ -1423,7 +1423,7 @@ TEST_F(DrmCommandStreamLeaksTest, GivenTwoAllocationsWhenBackingStorageIsTheSame mm->freeGraphicsMemory(allocation); mm->freeGraphicsMemory(allocation2); - csr->clearResidencyAllocations(); + csr->getResidencyAllocations().clear(); } TEST_F(DrmCommandStreamLeaksTest, GivenTwoAllocationsWhenBackingStorageIsDifferentThenMakeResidentShouldAddTwoLocations) { @@ -1446,7 +1446,7 @@ TEST_F(DrmCommandStreamLeaksTest, GivenTwoAllocationsWhenBackingStorageIsDiffere mm->freeGraphicsMemory(allocation); mm->freeGraphicsMemory(allocation2); - csr->clearResidencyAllocations(); + csr->getResidencyAllocations().clear(); } TEST_F(DrmCommandStreamLeaksTest, makeResidentSizeZero) { @@ -1616,7 +1616,7 @@ TEST_F(DrmCommandStreamLeaksTest, CheckDrmFree) { mm->freeGraphicsMemory(allocation); } -TEST_F(DrmCommandStreamLeaksTest, MakeResidentClearResidencyAllocationsInMemoryManager) { +TEST_F(DrmCommandStreamLeaksTest, MakeResidentClearResidencyAllocationsInCommandStreamReceiver) { auto allocation1 = mm->allocateGraphicsMemory(1024); auto allocation2 = mm->allocateGraphicsMemory(1024); diff --git a/unit_tests/os_interface/windows/device_command_stream_tests.cpp b/unit_tests/os_interface/windows/device_command_stream_tests.cpp index a49b92b3e6..553852e572 100644 --- a/unit_tests/os_interface/windows/device_command_stream_tests.cpp +++ b/unit_tests/os_interface/windows/device_command_stream_tests.cpp @@ -547,8 +547,8 @@ TEST_F(WddmCommandStreamTest, processEvictionPlacesAllAllocationsOnTrimCandidate ASSERT_NE(nullptr, allocation); ASSERT_NE(nullptr, allocation2); - csr->pushAllocationForEviction(allocation); - csr->pushAllocationForEviction(allocation2); + csr->getEvictionAllocations().push_back(allocation); + csr->getEvictionAllocations().push_back(allocation2); EXPECT_EQ(2u, csr->getEvictionAllocations().size()); @@ -566,7 +566,7 @@ TEST_F(WddmCommandStreamTest, processEvictionClearsEvictionAllocations) { GraphicsAllocation *allocation = memManager->allocateGraphicsMemory(4096); ASSERT_NE(nullptr, allocation); - csr->pushAllocationForEviction(allocation); + csr->getEvictionAllocations().push_back(allocation); EXPECT_EQ(1u, csr->getEvictionAllocations().size());