diff --git a/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp b/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp index e7512e704a..7d567fc940 100644 --- a/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp @@ -495,6 +495,31 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromSharedHandleIs memoryManager->freeGraphicsMemory(gpuAllocation); } +TEST_F(WddmMemoryManagerSimpleTest, whenAllocationCreatedFromSharedHandleIsDestroyedThenNullAllocationHandleAndZeroAllocationCountArePassedTodestroyAllocation) { + gdi->getQueryResourceInfoArgOut().NumAllocations = 1; + std::unique_ptr 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(0x1000); diff --git a/shared/source/os_interface/windows/wddm_memory_manager.cpp b/shared/source/os_interface/windows/wddm_memory_manager.cpp index 85b4b63154..10288790da 100644 --- a/shared/source/os_interface/windows/wddm_memory_manager.cpp +++ b/shared/source/os_interface/windows/wddm_memory_manager.cpp @@ -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()) {