Get rid of processResidency() calls with null ResidencyContainer 3/n

Change-Id: I526cac86f7e4eb61f7962d1ddd33a5d029451111
Signed-off-by: Maciej Dziuban <maciej.dziuban@intel.com>
This commit is contained in:
Maciej Dziuban 2018-09-11 11:46:33 +02:00 committed by sys_ocldev
parent ed4e1e9c3e
commit f1a264e380
3 changed files with 27 additions and 28 deletions

View File

@ -465,10 +465,9 @@ uint64_t WddmMemoryManager::getInternalHeapBaseAddress() {
}
bool WddmMemoryManager::makeResidentResidencyAllocations(ResidencyContainer *allocationsForResidency, OsContext &osContext) {
DEBUG_BREAK_IF(allocationsForResidency == nullptr);
auto &residencyAllocations = allocationsForResidency ? *allocationsForResidency : this->residencyAllocations;
size_t residencyCount = residencyAllocations.size();
size_t residencyCount = allocationsForResidency->size();
std::unique_ptr<D3DKMT_HANDLE[]> handlesForResidency(new D3DKMT_HANDLE[residencyCount * max_fragments_count]);
uint32_t totalHandlesCount = 0;
@ -478,7 +477,7 @@ bool WddmMemoryManager::makeResidentResidencyAllocations(ResidencyContainer *all
DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "currentFenceValue =", osContext.get()->getMonitoredFence().currentFenceValue);
for (uint32_t i = 0; i < residencyCount; i++) {
WddmAllocation *allocation = reinterpret_cast<WddmAllocation *>(residencyAllocations[i]);
WddmAllocation *allocation = reinterpret_cast<WddmAllocation *>((*allocationsForResidency)[i]);
bool mainResidency = false;
bool fragmentResidency[3] = {false, false, false};
@ -528,7 +527,7 @@ bool WddmMemoryManager::makeResidentResidencyAllocations(ResidencyContainer *all
if (result == true) {
for (uint32_t i = 0; i < residencyCount; i++) {
WddmAllocation *allocation = reinterpret_cast<WddmAllocation *>(residencyAllocations[i]);
WddmAllocation *allocation = reinterpret_cast<WddmAllocation *>((*allocationsForResidency)[i]);
// Update fence value not to early destroy / evict allocation
auto currentFence = osContext.get()->getMonitoredFence().currentFenceValue;
allocation->getResidencyData().updateCompletionData(currentFence, &osContext);

View File

@ -209,7 +209,7 @@ TEST_F(WddmCommandStreamTest, Flush) {
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr, *device->getOsContext());
auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, &csr->getResidencyAllocations(), *device->getOsContext());
EXPECT_EQ(1u, wddm->submitResult.called);
EXPECT_TRUE(wddm->submitResult.success);
@ -227,7 +227,7 @@ TEST_F(WddmCommandStreamTest, givenGraphicsAllocationWithDifferentGpuAddressThen
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr, *device->getOsContext());
auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, &csr->getResidencyAllocations(), *device->getOsContext());
EXPECT_EQ(mockGpuAddres, wddm->submitResult.commandBufferSubmitted);
memManager->freeGraphicsMemory(commandBuffer);
}
@ -238,7 +238,7 @@ TEST_F(WddmCommandStreamTest, FlushWithOffset) {
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), offset, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr, *device->getOsContext());
csr->flush(batchBuffer, EngineType::ENGINE_RCS, &csr->getResidencyAllocations(), *device->getOsContext());
EXPECT_EQ(1u, wddm->submitResult.called);
EXPECT_TRUE(wddm->submitResult.success);
EXPECT_EQ(wddm->submitResult.commandBufferSubmitted, commandBuffer->getGpuAddress() + offset);
@ -252,7 +252,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledThenCoherencyRequiredFl
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr, *device->getOsContext());
csr->flush(batchBuffer, EngineType::ENGINE_RCS, &csr->getResidencyAllocations(), *device->getOsContext());
auto commandHeader = wddm->submitResult.commandHeaderSubmitted;
COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandHeader);
@ -281,7 +281,7 @@ TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOf
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
OsContext *osContext = new OsContext(executionEnvironment.osInterface.get());
osContext->incRefInternal();
executionEnvironment.commandStreamReceiver->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr, *osContext);
executionEnvironment.commandStreamReceiver->flush(batchBuffer, EngineType::ENGINE_RCS, &executionEnvironment.commandStreamReceiver->getResidencyAllocations(), *osContext);
auto commandHeader = wddm->submitResult.commandHeaderSubmitted;
COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandHeader);
@ -308,7 +308,7 @@ TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOn
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
OsContext *osContext = new OsContext(executionEnvironment.osInterface.get());
osContext->incRefInternal();
executionEnvironment.commandStreamReceiver->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr, *osContext);
executionEnvironment.commandStreamReceiver->flush(batchBuffer, EngineType::ENGINE_RCS, &executionEnvironment.commandStreamReceiver->getResidencyAllocations(), *osContext);
auto commandHeader = wddm->submitResult.commandHeaderSubmitted;
COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandHeader);
@ -349,7 +349,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndThrottleIsToLowThenS
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::LOW, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr, *device->getOsContext());
csr->flush(batchBuffer, EngineType::ENGINE_RCS, &csr->getResidencyAllocations(), *device->getOsContext());
auto commandHeader = wddm->submitResult.commandHeaderSubmitted;
COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandHeader);
@ -367,7 +367,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndThrottleIsToMediumTh
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr, *device->getOsContext());
csr->flush(batchBuffer, EngineType::ENGINE_RCS, &csr->getResidencyAllocations(), *device->getOsContext());
auto commandHeader = wddm->submitResult.commandHeaderSubmitted;
COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandHeader);
@ -385,7 +385,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndThrottleIsToHighThen
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::HIGH, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr, *device->getOsContext());
csr->flush(batchBuffer, EngineType::ENGINE_RCS, &csr->getResidencyAllocations(), *device->getOsContext());
auto commandHeader = wddm->submitResult.commandHeaderSubmitted;
COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandHeader);
@ -425,7 +425,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithoutA
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
wddm->setKmDafEnabled(true);
auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr, *device->getOsContext());
auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, &csr->getResidencyAllocations(), *device->getOsContext());
EXPECT_EQ(0u, wddm->kmDafLockResult.called);
EXPECT_EQ(0u, wddm->kmDafLockResult.lockedAllocations.size());
@ -448,7 +448,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithResi
EXPECT_EQ(linearStreamAllocation, memManager->getResidencyAllocations()[0]);
wddm->setKmDafEnabled(true);
auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr, *device->getOsContext());
auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, &csr->getResidencyAllocations(), *device->getOsContext());
EXPECT_EQ(1u, wddm->kmDafLockResult.called);
EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size());
@ -694,7 +694,7 @@ TEST_F(WddmCommandStreamMockGdiTest, FlushCallsWddmMakeResidentForResidencyAlloc
gdi->getMakeResidentArg().NumAllocations = 0;
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr, *device->getOsContext());
csr->flush(batchBuffer, EngineType::ENGINE_RCS, &csr->getResidencyAllocations(), *device->getOsContext());
EXPECT_NE(0u, gdi->getMakeResidentArg().NumAllocations);
@ -713,7 +713,7 @@ TEST_F(WddmCommandStreamMockGdiTest, makeResidentClearsResidencyAllocations) {
EXPECT_EQ(trimListUnusedPosition, ((WddmAllocation *)commandBuffer)->getTrimCandidateListPosition());
csr->processResidency(nullptr, *device->getOsContext());
csr->processResidency(&csr->getResidencyAllocations(), *device->getOsContext());
csr->makeSurfacePackNonResident(nullptr);

View File

@ -1048,7 +1048,7 @@ TEST_F(WddmMemoryManagerResidencyTest, makeResidentResidencyAllocationsMarksAllo
memoryManager->pushAllocationForResidency(&allocation3);
memoryManager->pushAllocationForResidency(&allocation4);
memoryManager->makeResidentResidencyAllocations(nullptr, *osContext);
memoryManager->makeResidentResidencyAllocations(&memoryManager->getResidencyAllocations(), *osContext);
EXPECT_TRUE(allocation1.getResidencyData().resident);
EXPECT_TRUE(allocation2.getResidencyData().resident);
@ -1066,7 +1066,7 @@ TEST_F(WddmMemoryManagerResidencyTest, makeResidentResidencyAllocationsUpdatesLa
osContext->get()->getMonitoredFence().currentFenceValue = 20;
memoryManager->makeResidentResidencyAllocations(nullptr, *osContext);
memoryManager->makeResidentResidencyAllocations(&memoryManager->getResidencyAllocations(), *osContext);
EXPECT_EQ(20u, allocation1.getResidencyData().getFenceValueForContextId(osContext->getContextId()));
EXPECT_EQ(20u, allocation2.getResidencyData().getFenceValueForContextId(osContext->getContextId()));
@ -1084,7 +1084,7 @@ TEST_F(WddmMemoryManagerResidencyTest, makeResidentResidencyAllocationsMarksTrip
memoryManager->pushAllocationForResidency(allocationTriple);
memoryManager->pushAllocationForResidency(&allocation2);
memoryManager->makeResidentResidencyAllocations(nullptr, *osContext);
memoryManager->makeResidentResidencyAllocations(&memoryManager->getResidencyAllocations(), *osContext);
for (uint32_t i = 0; i < allocationTriple->fragmentsStorage.fragmentCount; i++) {
EXPECT_TRUE(allocationTriple->fragmentsStorage.fragmentStorageData[i].residency->resident);
@ -1106,7 +1106,7 @@ TEST_F(WddmMemoryManagerResidencyTest, makeResidentResidencyAllocationsSetsLastF
memoryManager->pushAllocationForResidency(allocationTriple);
memoryManager->pushAllocationForResidency(&allocation2);
memoryManager->makeResidentResidencyAllocations(nullptr, *osContext);
memoryManager->makeResidentResidencyAllocations(&memoryManager->getResidencyAllocations(), *osContext);
for (uint32_t i = 0; i < allocationTriple->fragmentsStorage.fragmentCount; i++) {
EXPECT_EQ(20u, allocationTriple->fragmentsStorage.fragmentStorageData[i].residency->getFenceValueForContextId(0));
@ -1737,7 +1737,7 @@ TEST_F(WddmMemoryManagerTest2, makeResidentResidencyAllocationsDoesNotMarkAlloca
memoryManager->pushAllocationForResidency(&allocation3);
memoryManager->pushAllocationForResidency(&allocation4);
bool result = memoryManager->makeResidentResidencyAllocations(nullptr, *osContext);
bool result = memoryManager->makeResidentResidencyAllocations(&memoryManager->getResidencyAllocations(), *osContext);
EXPECT_FALSE(result);
@ -1762,7 +1762,7 @@ TEST_F(WddmMemoryManagerTest2, makeResidentResidencyAllocationsDoesNotMarkTriple
memoryManager->pushAllocationForResidency(allocationTriple);
memoryManager->pushAllocationForResidency(&allocation2);
bool result = memoryManager->makeResidentResidencyAllocations(nullptr, *osContext);
bool result = memoryManager->makeResidentResidencyAllocations(&memoryManager->getResidencyAllocations(), *osContext);
EXPECT_FALSE(result);
@ -1786,7 +1786,7 @@ TEST_F(WddmMemoryManagerTest2, makeResidentResidencyAllocationsFailsWhenMakeResi
memoryManager->pushAllocationForResidency(&allocation3);
memoryManager->pushAllocationForResidency(&allocation4);
bool result = memoryManager->makeResidentResidencyAllocations(nullptr, *osContext);
bool result = memoryManager->makeResidentResidencyAllocations(&memoryManager->getResidencyAllocations(), *osContext);
EXPECT_FALSE(result);
@ -1807,7 +1807,7 @@ TEST_F(WddmMemoryManagerTest2, makeResidentResidencyAllocationsCallsMakeResident
memoryManager->pushAllocationForResidency(&allocation1);
bool result = memoryManager->makeResidentResidencyAllocations(nullptr, *osContext);
bool result = memoryManager->makeResidentResidencyAllocations(&memoryManager->getResidencyAllocations(), *osContext);
EXPECT_FALSE(result);
}
@ -1853,7 +1853,7 @@ TEST_F(WddmMemoryManagerTest2, makeResidentResidencyAllocationsSucceedsWhenMakeR
memoryManager->pushAllocationForResidency(&allocation1);
bool result = memoryManager->makeResidentResidencyAllocations(nullptr, *osContext);
bool result = memoryManager->makeResidentResidencyAllocations(&memoryManager->getResidencyAllocations(), *osContext);
EXPECT_TRUE(result);
@ -1869,7 +1869,7 @@ TEST_F(WddmMemoryManagerTest2, givenMemoryManagerWhenMakeResidentFailsThenMemory
EXPECT_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(2).WillOnce(::testing::Invoke(makeResidentThatFails)).WillOnce(::testing::Invoke(makeResidentThatSucceds));
memoryManager->pushAllocationForResidency(&allocation1);
bool result = memoryManager->makeResidentResidencyAllocations(nullptr, *osContext);
bool result = memoryManager->makeResidentResidencyAllocations(&memoryManager->getResidencyAllocations(), *osContext);
EXPECT_TRUE(memoryManager->isMemoryBudgetExhausted());
}