Fix destruction of shared handle allocations

Related-To: NEO-4479

Change-Id: Iad7581c40948d2bc83c18a36b230254ee92fc0f7
Signed-off-by: Igor Venevtsev <igor.venevtsev@intel.com>
This commit is contained in:
Igor Venevtsev
2020-06-19 11:08:54 +02:00
committed by sys_ocldev
parent e1d9f92b94
commit 5334f800ea
2 changed files with 26 additions and 1 deletions

View File

@@ -495,6 +495,31 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromSharedHandleIs
memoryManager->freeGraphicsMemory(gpuAllocation);
}
TEST_F(WddmMemoryManagerSimpleTest, whenAllocationCreatedFromSharedHandleIsDestroyedThenNullAllocationHandleAndZeroAllocationCountArePassedTodestroyAllocation) {
gdi->getQueryResourceInfoArgOut().NumAllocations = 1;
std::unique_ptr<Gmm> gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), nullptr, 0, false));
D3DDDI_OPENALLOCATIONINFO allocationInfo;
allocationInfo.pPrivateDriverData = gmm->gmmResourceInfo->peekHandle();
allocationInfo.hAllocation = ALLOCATION_HANDLE;
allocationInfo.PrivateDriverDataSize = sizeof(GMM_RESOURCE_INFO);
gdi->getOpenResourceArgOut().pOpenAllocationInfo = &allocationInfo;
AllocationProperties properties(0, false, 0, GraphicsAllocation::AllocationType::SHARED_BUFFER, false, false, 0);
auto allocation = memoryManager->createGraphicsAllocationFromSharedHandle(1, properties, false);
EXPECT_NE(nullptr, allocation);
memoryManager->setDeferredDeleter(nullptr);
memoryManager->freeGraphicsMemory(allocation);
EXPECT_EQ(1u, memoryManager->freeGraphicsMemoryImplCalled);
auto destroyArg = gdi->getDestroyArg();
EXPECT_EQ(nullptr, destroyArg.phAllocationList);
EXPECT_EQ(0, destroyArg.AllocationCount);
}
TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromNTHandleIsCalledThenNonNullGraphicsAllocationIsReturned) {
void *pSysMem = reinterpret_cast<void *>(0x1000);

View File

@@ -411,7 +411,7 @@ void WddmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation
cleanGraphicsMemoryCreatedFromHostPtr(gfxAllocation);
} else {
if (input->peekSharedHandle()) {
auto status = tryDeferDeletions(&input->getHandles()[0], input->getNumGmms(), input->resourceHandle, gfxAllocation->getRootDeviceIndex());
auto status = tryDeferDeletions(nullptr, 0, input->resourceHandle, gfxAllocation->getRootDeviceIndex());
DEBUG_BREAK_IF(!status);
} else {
for (auto handle : input->getHandles()) {