Make sure that resources are not made resident multiple times.

Related-To: NEO-3054

Change-Id: I32d01f8993e8d327ee117a352a8b4bcb1bbb7e30
Signed-off-by: Mrozek, Michal <michal.mrozek@intel.com>
This commit is contained in:
Mrozek, Michal
2019-04-16 15:32:15 +02:00
committed by sys_ocldev
parent a807a7498c
commit 97bc604316
2 changed files with 20 additions and 1 deletions

View File

@ -378,6 +378,10 @@ bool TbxCommandStreamReceiverHw<GfxFamily>::writeMemory(GraphicsAllocation &gfxA
writeMemory(gpuAddress, cpuAddress, size, this->getMemoryBank(&gfxAllocation), this->getPPGTTAdditionalBits(&gfxAllocation));
}
if (AubHelper::isOneTimeAubWritableAllocationType(gfxAllocation.getAllocationType())) {
gfxAllocation.setAubWritable(false);
}
return true;
}
@ -385,7 +389,7 @@ template <typename GfxFamily>
void TbxCommandStreamReceiverHw<GfxFamily>::processResidency(ResidencyContainer &allocationsForResidency) {
for (auto &gfxAllocation : allocationsForResidency) {
if (!writeMemory(*gfxAllocation)) {
DEBUG_BREAK_IF(!(gfxAllocation->getUnderlyingBufferSize() == 0));
DEBUG_BREAK_IF(!((gfxAllocation->getUnderlyingBufferSize() == 0) || !gfxAllocation->isAubWritable()));
}
gfxAllocation->updateResidencyTaskCount(this->taskCount + 1, this->osContext->getContextId());
}

View File

@ -212,6 +212,21 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenWriteMemoryIsCa
memoryManager->freeGraphicsMemory(graphicsAllocation);
}
HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenWriteMemoryIsCalledWithGraphicsAllocationThatIsOnlyOneTimeWriteableThenGraphicsAllocationIsUpdated) {
TbxCommandStreamReceiverHw<FamilyType> *tbxCsr = (TbxCommandStreamReceiverHw<FamilyType> *)pCommandStreamReceiver;
TbxMemoryManager *memoryManager = tbxCsr->getMemoryManager();
ASSERT_NE(nullptr, memoryManager);
auto graphicsAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize, GraphicsAllocation::AllocationType::BUFFER});
ASSERT_NE(nullptr, graphicsAllocation);
EXPECT_TRUE(graphicsAllocation->isAubWritable());
EXPECT_TRUE(tbxCsr->writeMemory(*graphicsAllocation));
EXPECT_FALSE(graphicsAllocation->isAubWritable());
memoryManager->freeGraphicsMemory(graphicsAllocation);
}
HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenWriteMemoryIsCalledForGraphicsAllocationWithZeroSizeThenItShouldReturnFalse) {
TbxCommandStreamReceiverHw<FamilyType> *tbxCsr = (TbxCommandStreamReceiverHw<FamilyType> *)pCommandStreamReceiver;
MockGraphicsAllocation graphicsAllocation((void *)0x1234, 0);