From 4da2dd471d4ed181a5e0edf6b58d1500daef026a Mon Sep 17 00:00:00 2001 From: Maciej Dziuban Date: Tue, 11 Sep 2018 11:19:21 +0200 Subject: [PATCH] Get rid of processResidency() calls with null ResidencyContainer 2/n Change-Id: Ic2495cd21304710825727177a1d90889e22808d8 Signed-off-by: Maciej Dziuban --- runtime/command_stream/command_stream_receiver.cpp | 4 ++++ runtime/command_stream/command_stream_receiver.h | 2 ++ runtime/command_stream/command_stream_receiver_hw.inl | 2 +- runtime/command_stream/tbx_command_stream_receiver_hw.inl | 5 ++--- unit_tests/command_stream/tbx_command_stream_tests.cpp | 3 ++- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/runtime/command_stream/command_stream_receiver.cpp b/runtime/command_stream/command_stream_receiver.cpp index c99f827bca..0aef3a1d52 100644 --- a/runtime/command_stream/command_stream_receiver.cpp +++ b/runtime/command_stream/command_stream_receiver.cpp @@ -264,6 +264,10 @@ void CommandStreamReceiver::initProgrammingFlags() { latestSentStatelessMocsConfig = 0; } +ResidencyContainer &CommandStreamReceiver::getResidencyAllocations() { + return this->memoryManager->getResidencyAllocations(); +} + 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 8f9912d3fc..53c73bb62c 100644 --- a/runtime/command_stream/command_stream_receiver.h +++ b/runtime/command_stream/command_stream_receiver.h @@ -89,6 +89,8 @@ class CommandStreamReceiver { virtual MemoryManager *createMemoryManager(bool enable64kbPages, bool enableLocalMemory) { return nullptr; } void setMemoryManager(MemoryManager *mm); + ResidencyContainer &getResidencyAllocations(); + virtual GmmPageTableMngr *createPageTableManager() { return nullptr; } GraphicsAllocation *createAllocationAndHandleResidency(const void *address, size_t size, bool addToDefferFreeList = true); diff --git a/runtime/command_stream/command_stream_receiver_hw.inl b/runtime/command_stream/command_stream_receiver_hw.inl index 67f9db9df3..94608b26e8 100644 --- a/runtime/command_stream/command_stream_receiver_hw.inl +++ b/runtime/command_stream/command_stream_receiver_hw.inl @@ -443,7 +443,7 @@ CompletionStamp CommandStreamReceiverHw::flushTask( if (submitCSR | submitTask) { if (this->dispatchMode == DispatchMode::ImmediateDispatch) { - flushStamp->setStamp(this->flush(batchBuffer, engineType, nullptr, *device.getOsContext())); + flushStamp->setStamp(this->flush(batchBuffer, engineType, &this->getResidencyAllocations(), *device.getOsContext())); this->latestFlushedTaskCount = this->taskCount + 1; this->makeSurfacePackNonResident(nullptr); } else { diff --git a/runtime/command_stream/tbx_command_stream_receiver_hw.inl b/runtime/command_stream/tbx_command_stream_receiver_hw.inl index 5a5eb9245d..b6f714bd3a 100644 --- a/runtime/command_stream/tbx_command_stream_receiver_hw.inl +++ b/runtime/command_stream/tbx_command_stream_receiver_hw.inl @@ -366,9 +366,8 @@ bool TbxCommandStreamReceiverHw::writeMemory(GraphicsAllocation &gfxA template void TbxCommandStreamReceiverHw::processResidency(ResidencyContainer *allocationsForResidency, OsContext &osContext) { - auto &residencyAllocations = allocationsForResidency ? *allocationsForResidency : this->getMemoryManager()->getResidencyAllocations(); - - for (auto &gfxAllocation : residencyAllocations) { + DEBUG_BREAK_IF(allocationsForResidency == nullptr); + for (auto &gfxAllocation : *allocationsForResidency) { if (!writeMemory(*gfxAllocation)) { DEBUG_BREAK_IF(!(gfxAllocation->getUnderlyingBufferSize() == 0)); } diff --git a/unit_tests/command_stream/tbx_command_stream_tests.cpp b/unit_tests/command_stream/tbx_command_stream_tests.cpp index 4df9d68140..5405a11e26 100644 --- a/unit_tests/command_stream/tbx_command_stream_tests.cpp +++ b/unit_tests/command_stream/tbx_command_stream_tests.cpp @@ -235,6 +235,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenWriteMemoryIsCa HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenProcessResidencyIsCalledWithoutAllocationsForResidencyThenItShouldProcessAllocationsFromMemoryManager) { TbxCommandStreamReceiverHw *tbxCsr = (TbxCommandStreamReceiverHw *)pCommandStreamReceiver; TbxMemoryManager *memoryManager = tbxCsr->getMemoryManager(); + ResidencyContainer &allocationsForResidency = memoryManager->getResidencyAllocations(); ASSERT_NE(nullptr, memoryManager); auto graphicsAllocation = memoryManager->allocateGraphicsMemory(4096); @@ -243,7 +244,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenProcessResidenc EXPECT_EQ(ObjectNotResident, graphicsAllocation->residencyTaskCount); memoryManager->pushAllocationForResidency(graphicsAllocation); - tbxCsr->processResidency(nullptr, *pDevice->getOsContext()); + tbxCsr->processResidency(&allocationsForResidency, *pDevice->getOsContext()); EXPECT_NE(ObjectNotResident, graphicsAllocation->residencyTaskCount); EXPECT_EQ((int)tbxCsr->peekTaskCount() + 1, graphicsAllocation->residencyTaskCount);