fix: Register shared handle size on windows

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk 2025-04-23 11:22:33 +00:00 committed by Compute-Runtime-Automation
parent 9a87d83134
commit 53f0832614
3 changed files with 25 additions and 2 deletions

View File

@ -840,9 +840,8 @@ bool Wddm::destroyAllocations(const D3DKMT_HANDLE *handles, uint32_t allocationC
destroyAllocation.AllocationCount = allocationCount;
destroyAllocation.Flags.AssumeNotInUse = debugManager.flags.SetAssumeNotInUse.get();
DeallocateGmm deallocateGmm{&destroyAllocation, getGdi()};
if (debugManager.flags.DestroyAllocationsViaGmm.get()) {
DeallocateGmm deallocateGmm{&destroyAllocation, getGdi()};
status = static_cast<NTSTATUS>(this->rootDeviceEnvironment.getGmmClientContext()->deallocate2(&deallocateGmm));
} else {
status = getGdi()->destroyAllocation2(&destroyAllocation);

View File

@ -646,6 +646,7 @@ GraphicsAllocation *WddmMemoryManager::createGraphicsAllocationFromSharedHandle(
} else {
status = mapPhysicalDeviceMemoryToVirtualMemory(allocation.get(), reinterpret_cast<uint64_t>(mapPointer), size);
}
this->registerSysMemAlloc(allocation.get());
DEBUG_BREAK_IF(!status);
if (!status) {
freeGraphicsMemoryImpl(allocation.release());

View File

@ -2932,6 +2932,29 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerSizeZeroWhenCreateFromShared
memoryManager->freeGraphicsMemory(gpuAllocation);
}
TEST_F(WddmMemoryManagerTest, whenOpenSharedHandleThenRegisterAllocationSize) {
MockWddmMemoryManager::OsHandleData osHandleData{1u};
auto size = 4096u;
void *pSysMem = reinterpret_cast<void *>(0x1000);
GmmRequirements gmmRequirements{};
gmmRequirements.allowLargePages = true;
gmmRequirements.preferCompressed = false;
std::unique_ptr<Gmm> gmm(new Gmm(rootDeviceEnvironment->getGmmHelper(), pSysMem, size, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, {}, gmmRequirements));
void *gmmPtrArray[]{gmm->gmmResourceInfo.get()};
setSizesFcn(gmmPtrArray, 1u, 1024u, 1u);
auto usedSystemMemorySize = memoryManager->getUsedSystemMemorySize();
AllocationProperties properties(0, false, size, AllocationType::sharedBuffer, false, false, 0);
auto *gpuAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(osHandleData, properties, false, false, true, nullptr);
ASSERT_NE(nullptr, gpuAllocation);
EXPECT_EQ(size, gpuAllocation->getUnderlyingBufferSize());
EXPECT_EQ(usedSystemMemorySize + size, memoryManager->getUsedSystemMemorySize());
memoryManager->freeGraphicsMemory(gpuAllocation);
}
HWTEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenAllocateGraphicsMemoryWithSetAllocattionPropertisWithAllocationTypeBufferCompressedIsCalledThenIsRendeCompressedTrueAndGpuMappingIsSetWithGoodAddressRange) {
void *ptr = reinterpret_cast<void *>(0x1001);
auto size = MemoryConstants::pageSize;