Call makeResident only once per BufferObject

When different graphics allocations are created from
the same backing storage makeResident should be called only once.

Change-Id: Ide8ab385894505fd405eef010768dbcac3b92fba
Signed-off-by: Jacek Danecki <jacek.danecki@intel.com>
This commit is contained in:
Jacek Danecki
2018-06-08 14:40:21 +02:00
parent 892cf13c15
commit 4d48a6afec
4 changed files with 40 additions and 11 deletions

View File

@ -1364,6 +1364,29 @@ TEST_F(DrmCommandStreamLeaksTest, GivenAllocationsContainingDifferentCountOfFrag
EXPECT_EQ(0u, hostPtrManager.getFragmentCount());
}
TEST_F(DrmCommandStreamLeaksTest, GivenTwoAllocationsWhenBackingStorageIsTheSameThenMakeResidentShouldAddOnlyOneLocation) {
auto ptr = (void *)0x1000;
auto size = MemoryConstants::pageSize;
auto ptr2 = (void *)0x1000;
auto allocation = mm->allocateGraphicsMemory(size, ptr);
auto allocation2 = mm->allocateGraphicsMemory(size, ptr2);
csr->makeResident(*allocation);
csr->makeResident(*allocation2);
csr->processResidency(nullptr);
EXPECT_EQ(tCsr->getResidencyVector()->size(), 1u);
csr->makeNonResident(*allocation);
csr->makeNonResident(*allocation2);
mm->freeGraphicsMemory(allocation);
mm->freeGraphicsMemory(allocation2);
mm->clearResidencyAllocations();
}
TEST_F(DrmCommandStreamLeaksTest, makeResidentSizeZero) {
std::unique_ptr<BufferObject> buffer(this->createBO(0));
DrmAllocation allocation(buffer.get(), nullptr, buffer->peekSize());