From daec24943007e351ae3bd1c9417264b90240de29 Mon Sep 17 00:00:00 2001 From: Jaroslaw Warchulski Date: Tue, 18 Jun 2024 12:10:24 +0000 Subject: [PATCH] refactor: remove not needed createGraphicsAllocationFromNTHandle method Related-To: NEO-11498 Signed-off-by: Jaroslaw Warchulski --- .../core/source/context/context_imp.cpp | 4 +- .../core/source/driver/driver_handle_imp.cpp | 6 +- .../core/source/helpers/properties_parser.h | 4 +- level_zero/core/source/image/image_hw.inl | 9 ++- .../fixtures/memory_ipc_fixture.cpp | 36 --------- .../unit_tests/fixtures/memory_ipc_fixture.h | 4 - .../sources/context/test_context.cpp | 1 - .../unit_tests/sources/driver/test_driver.cpp | 6 +- .../unit_tests/sources/event/test_event.cpp | 1 - .../helper/properties_parser_tests.cpp | 2 +- .../unit_tests/sources/image/test_image.cpp | 4 +- .../memory/linux/test_memory_linux.cpp | 2 - .../unit_tests/sources/memory/test_memory.cpp | 2 - opencl/source/sharings/d3d/d3d_surface.cpp | 2 +- opencl/source/sharings/d3d/d3d_texture.cpp | 74 +++++++------------ .../sharings/gl/linux/gl_texture_linux.cpp | 2 +- .../gl/windows/gl_texture_windows.cpp | 2 +- .../sharings/unified/unified_sharing.cpp | 27 +++---- .../unit_test/fixtures/d3d_test_fixture.h | 10 --- .../mem_obj/windows/image_windows_tests.cpp | 8 +- .../unified/unified_sharing_fixtures.h | 6 +- .../unified/unified_sharing_image_tests.cpp | 4 +- .../unified/unified_sharing_tests.cpp | 15 +--- shared/source/memory_manager/memory_manager.h | 16 +--- .../os_agnostic_memory_manager.h | 1 - .../os_interface/linux/drm_memory_manager.h | 2 - .../source/os_interface/windows/wddm/wddm.cpp | 4 +- .../source/os_interface/windows/wddm/wddm.h | 4 +- .../windows/wddm_memory_manager.cpp | 30 ++------ .../windows/wddm_memory_manager.h | 3 +- shared/test/common/mock_gdi/mock_gdi.cpp | 2 +- .../test/common/mocks/mock_memory_manager.cpp | 14 ---- .../test/common/mocks/mock_memory_manager.h | 4 - shared/test/common/mocks/mock_wddm.cpp | 2 +- shared/test/common/mocks/mock_wddm.h | 2 +- .../unit_test/device/neo_device_tests.cpp | 1 - .../memory_manager/memory_manager_tests.cpp | 8 -- .../linux/drm_memory_manager_tests.cpp | 6 -- .../os_interface/windows/wddm20_tests.cpp | 4 +- .../windows/wddm_memory_manager_tests.cpp | 16 ++-- 40 files changed, 104 insertions(+), 246 deletions(-) diff --git a/level_zero/core/source/context/context_imp.cpp b/level_zero/core/source/context/context_imp.cpp index aa7020cc5a..26e5827e40 100644 --- a/level_zero/core/source/context/context_imp.cpp +++ b/level_zero/core/source/context/context_imp.cpp @@ -111,7 +111,7 @@ ze_result_t ContextImp::allocHostMem(const ze_host_mem_alloc_desc_t *hostDesc, } else { UNRECOVERABLE_IF(!lookupTable.sharedHandleType.isNTHandle); *ptr = this->driverHandle->importNTHandle(this->devices.begin()->second, - lookupTable.sharedHandleType.ntHnadle, + lookupTable.sharedHandleType.ntHandle, NEO::AllocationType::bufferHostMemory); if (*ptr == nullptr) { return ZE_RESULT_ERROR_INVALID_ARGUMENT; @@ -239,7 +239,7 @@ ze_result_t ContextImp::allocDeviceMem(ze_device_handle_t hDevice, } else { UNRECOVERABLE_IF(!lookupTable.sharedHandleType.isNTHandle); *ptr = this->driverHandle->importNTHandle(hDevice, - lookupTable.sharedHandleType.ntHnadle, + lookupTable.sharedHandleType.ntHandle, NEO::AllocationType::buffer); if (*ptr == nullptr) { return ZE_RESULT_ERROR_INVALID_ARGUMENT; diff --git a/level_zero/core/source/driver/driver_handle_imp.cpp b/level_zero/core/source/driver/driver_handle_imp.cpp index db52d173e7..bec68d4cb1 100644 --- a/level_zero/core/source/driver/driver_handle_imp.cpp +++ b/level_zero/core/source/driver/driver_handle_imp.cpp @@ -886,7 +886,11 @@ void *DriverHandleImp::importNTHandle(ze_device_handle_t hDevice, void *handle, bool isHostIpcAllocation = (allocationType == NEO::AllocationType::bufferHostMemory) ? true : false; NEO::MemoryManager::OsHandleData osHandleData{handle}; - auto alloc = this->getMemoryManager()->createGraphicsAllocationFromNTHandle(osHandleData, neoDevice->getRootDeviceIndex(), NEO::AllocationType::sharedBuffer); + NEO::AllocationProperties properties{neoDevice->getRootDeviceIndex(), + MemoryConstants::pageSize, + allocationType, + neoDevice->getDeviceBitfield()}; + auto alloc = this->getMemoryManager()->createGraphicsAllocationFromSharedHandle(osHandleData, properties, false, false, false, nullptr); if (alloc == nullptr) { return nullptr; diff --git a/level_zero/core/source/helpers/properties_parser.h b/level_zero/core/source/helpers/properties_parser.h index fa1e442857..f6c99207df 100644 --- a/level_zero/core/source/helpers/properties_parser.h +++ b/level_zero/core/source/helpers/properties_parser.h @@ -63,7 +63,7 @@ struct StructuresLookupTable { } imageProperties; struct SharedHandleType { - void *ntHnadle; + void *ntHandle; int fd; bool isSupportedHandle; bool isDMABUFHandle; @@ -107,7 +107,7 @@ inline ze_result_t prepareL0StructuresLookupTable(StructuresLookupTable &lookupT (windowsExternalMemoryImportDesc->flags == ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D12_RESOURCE)) { lookupTable.sharedHandleType.isSupportedHandle = true; lookupTable.sharedHandleType.isNTHandle = true; - lookupTable.sharedHandleType.ntHnadle = windowsExternalMemoryImportDesc->handle; + lookupTable.sharedHandleType.ntHandle = windowsExternalMemoryImportDesc->handle; } else { lookupTable.sharedHandleType.isSupportedHandle = false; return ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION; diff --git a/level_zero/core/source/image/image_hw.inl b/level_zero/core/source/image/image_hw.inl index fc1adc97cc..5ecf780625 100644 --- a/level_zero/core/source/image/image_hw.inl +++ b/level_zero/core/source/image/image_hw.inl @@ -113,17 +113,18 @@ ze_result_t ImageCoreFamily::initialize(Device *device, const ze_ return ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION; } if (lookupTable.sharedHandleType.isDMABUFHandle) { + NEO::MemoryManager::OsHandleData osHandleData{static_cast(lookupTable.sharedHandleType.fd)}; NEO::AllocationProperties properties(device->getRootDeviceIndex(), true, &imgInfo, NEO::AllocationType::sharedImage, device->getNEODevice()->getDeviceBitfield()); - NEO::MemoryManager::ExtendedOsHandleData osHandleData{static_cast(lookupTable.sharedHandleType.fd)}; allocation = device->getNEODevice()->getMemoryManager()->createGraphicsAllocationFromSharedHandle(osHandleData, properties, false, false, true, nullptr); device->getNEODevice()->getMemoryManager()->closeSharedHandle(allocation); } else if (lookupTable.sharedHandleType.isNTHandle) { - auto verifyResult = device->getNEODevice()->getMemoryManager()->verifyHandle(NEO::toOsHandle(lookupTable.sharedHandleType.ntHnadle), device->getNEODevice()->getRootDeviceIndex(), true); + auto verifyResult = device->getNEODevice()->getMemoryManager()->verifyHandle(NEO::toOsHandle(lookupTable.sharedHandleType.ntHandle), device->getNEODevice()->getRootDeviceIndex(), true); if (!verifyResult) { return ZE_RESULT_ERROR_INVALID_ARGUMENT; } - NEO::MemoryManager::ExtendedOsHandleData osHandleData{lookupTable.sharedHandleType.ntHnadle}; - allocation = device->getNEODevice()->getMemoryManager()->createGraphicsAllocationFromNTHandle(osHandleData, device->getNEODevice()->getRootDeviceIndex(), NEO::AllocationType::sharedImage); + NEO::MemoryManager::OsHandleData osHandleData{lookupTable.sharedHandleType.ntHandle}; + NEO::AllocationProperties properties(device->getRootDeviceIndex(), true, &imgInfo, NEO::AllocationType::sharedImage, device->getNEODevice()->getDeviceBitfield()); + allocation = device->getNEODevice()->getMemoryManager()->createGraphicsAllocationFromSharedHandle(osHandleData, properties, false, false, true, nullptr); allocation->getDefaultGmm()->queryImageParams(imgInfo); } } else { diff --git a/level_zero/core/test/unit_tests/fixtures/memory_ipc_fixture.cpp b/level_zero/core/test/unit_tests/fixtures/memory_ipc_fixture.cpp index 18a0bdaa39..7c6cd548e2 100644 --- a/level_zero/core/test/unit_tests/fixtures/memory_ipc_fixture.cpp +++ b/level_zero/core/test/unit_tests/fixtures/memory_ipc_fixture.cpp @@ -379,22 +379,6 @@ NEO::GraphicsAllocation *MemoryManagerOpenIpcMock::createGraphicsAllocationFromM alloc->setGpuBaseAddress(0xabcd); return alloc; } -NEO::GraphicsAllocation *MemoryManagerOpenIpcMock::createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) { - auto ptr = reinterpret_cast(sharedHandleAddress); - sharedHandleAddress += 0x1000; - auto gmmHelper = getGmmHelper(0); - auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr)); - auto alloc = new IpcImplicitScalingMockGraphicsAllocation(0u, - NEO::AllocationType::buffer, - ptr, - 0x1000, - 0u, - MemoryPool::system4KBPages, - MemoryManager::maxOsContextCount, - canonizedGpuAddress); - alloc->setGpuBaseAddress(0xabcd); - return alloc; -}; ze_result_t ContextIpcMock::getIpcMemHandle(const void *ptr, ze_ipc_mem_handle_t *pIpcHandle) { uint64_t handle = mockFd; @@ -493,26 +477,6 @@ NEO::GraphicsAllocation *MemoryManagerIpcImplicitScalingMock::createGraphicsAllo return alloc; } -NEO::GraphicsAllocation *MemoryManagerIpcImplicitScalingMock::createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) { - if (failOnCreateGraphicsAllocationFromNTHandle) { - return nullptr; - } - - auto ptr = reinterpret_cast(sharedHandleAddress); - sharedHandleAddress += 0x1000; - auto gmmHelper = getGmmHelper(0); - auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr)); - auto alloc = new IpcImplicitScalingMockGraphicsAllocation(0u, - NEO::AllocationType::buffer, - ptr, - 0x1000, - 0u, - MemoryPool::system4KBPages, - MemoryManager::maxOsContextCount, - canonizedGpuAddress); - alloc->setGpuBaseAddress(0xabcd); - return alloc; -} NEO::GraphicsAllocation *MemoryManagerIpcImplicitScalingMock::createGraphicsAllocationFromSharedHandle(const OsHandleData &osHandleData, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) { if (failOnCreateGraphicsAllocationFromSharedHandle) { return nullptr; diff --git a/level_zero/core/test/unit_tests/fixtures/memory_ipc_fixture.h b/level_zero/core/test/unit_tests/fixtures/memory_ipc_fixture.h index 9b5243f5e6..0da31322b2 100644 --- a/level_zero/core/test/unit_tests/fixtures/memory_ipc_fixture.h +++ b/level_zero/core/test/unit_tests/fixtures/memory_ipc_fixture.h @@ -194,7 +194,6 @@ class MemoryManagerIpcMock : public NEO::MemoryManager { NEO::GraphicsAllocation *createGraphicsAllocationFromSharedHandle(const OsHandleData &osHandleData, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override { return nullptr; } void addAllocationToHostPtrManager(NEO::GraphicsAllocation *memory) override{}; void removeAllocationFromHostPtrManager(NEO::GraphicsAllocation *memory) override{}; - NEO::GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override { return nullptr; }; AllocationStatus populateOsHandles(NEO::OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override { return AllocationStatus::Success; }; void cleanOsHandles(NEO::OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override{}; void freeGraphicsMemoryImpl(NEO::GraphicsAllocation *gfxAllocation) override{}; @@ -279,7 +278,6 @@ class MemoryManagerOpenIpcMock : public MemoryManagerIpcMock { bool reuseSharedAllocation, void *mapPointer) override; NEO::GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override; - NEO::GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override; void freeGraphicsMemory(GraphicsAllocation *gfxAllocation) override { delete gfxAllocation; @@ -365,7 +363,6 @@ class MemoryManagerIpcImplicitScalingMock : public NEO::MemoryManager { NEO::GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override; - NEO::GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override; NEO::GraphicsAllocation *createGraphicsAllocationFromSharedHandle(const OsHandleData &osHandleData, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override; @@ -376,7 +373,6 @@ class MemoryManagerIpcImplicitScalingMock : public NEO::MemoryManager { uint64_t sharedHandleAddress = 0x1234; bool failOnCreateGraphicsAllocationFromSharedHandle = false; - bool failOnCreateGraphicsAllocationFromNTHandle = true; }; struct MemoryExportImportImplicitScalingTest : public ::testing::Test { diff --git a/level_zero/core/test/unit_tests/sources/context/test_context.cpp b/level_zero/core/test/unit_tests/sources/context/test_context.cpp index 1f694ce2fb..b8ff7fbd9a 100644 --- a/level_zero/core/test/unit_tests/sources/context/test_context.cpp +++ b/level_zero/core/test/unit_tests/sources/context/test_context.cpp @@ -1387,7 +1387,6 @@ class ReserveMemoryManagerMock : public NEO::MemoryManager { NEO::GraphicsAllocation *createGraphicsAllocationFromSharedHandle(const OsHandleData &osHandleData, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override { return nullptr; } void addAllocationToHostPtrManager(NEO::GraphicsAllocation *memory) override{}; void removeAllocationFromHostPtrManager(NEO::GraphicsAllocation *memory) override{}; - NEO::GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override { return nullptr; }; AllocationStatus populateOsHandles(NEO::OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override { return AllocationStatus::Success; }; void cleanOsHandles(NEO::OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override{}; void freeGraphicsMemoryImpl(NEO::GraphicsAllocation *gfxAllocation) override{}; diff --git a/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp b/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp index 3c7bf172ee..da5e956d17 100644 --- a/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp +++ b/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp @@ -275,10 +275,10 @@ class MemoryManagerNTHandleMock : public NEO::OsAgnosticMemoryManager { public: MemoryManagerNTHandleMock(NEO::ExecutionEnvironment &executionEnvironment) : NEO::OsAgnosticMemoryManager(executionEnvironment) {} - NEO::GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override { - auto graphicsAllocation = createMemoryAllocation(allocType, nullptr, reinterpret_cast(1), 1, + NEO::GraphicsAllocation *createGraphicsAllocationFromSharedHandle(const OsHandleData &osHandleData, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override { + auto graphicsAllocation = createMemoryAllocation(properties.allocationType, nullptr, reinterpret_cast(1), 1, 4096u, osHandleData.handle, MemoryPool::systemCpuInaccessible, - rootDeviceIndex, false, false, false); + properties.rootDeviceIndex, false, false, false); graphicsAllocation->setSharedHandle(osHandleData.handle); graphicsAllocation->set32BitAllocation(false); GmmRequirements gmmRequirements{}; diff --git a/level_zero/core/test/unit_tests/sources/event/test_event.cpp b/level_zero/core/test/unit_tests/sources/event/test_event.cpp index 1977a81b8e..629f840b8c 100644 --- a/level_zero/core/test/unit_tests/sources/event/test_event.cpp +++ b/level_zero/core/test/unit_tests/sources/event/test_event.cpp @@ -70,7 +70,6 @@ class MemoryManagerEventPoolFailMock : public NEO::MemoryManager { NEO::GraphicsAllocation *createGraphicsAllocationFromSharedHandle(const OsHandleData &osHandleData, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override { return nullptr; } void addAllocationToHostPtrManager(NEO::GraphicsAllocation *memory) override{}; void removeAllocationFromHostPtrManager(NEO::GraphicsAllocation *memory) override{}; - NEO::GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override { return nullptr; }; AllocationStatus populateOsHandles(NEO::OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override { return AllocationStatus::Success; }; void cleanOsHandles(NEO::OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override{}; void freeGraphicsMemoryImpl(NEO::GraphicsAllocation *gfxAllocation) override{}; diff --git a/level_zero/core/test/unit_tests/sources/helper/properties_parser_tests.cpp b/level_zero/core/test/unit_tests/sources/helper/properties_parser_tests.cpp index 5e56b8f49a..0c778a37a2 100644 --- a/level_zero/core/test/unit_tests/sources/helper/properties_parser_tests.cpp +++ b/level_zero/core/test/unit_tests/sources/helper/properties_parser_tests.cpp @@ -116,7 +116,7 @@ TEST(L0StructuresLookupTableTests, givenL0StructuresWithNTHandleWhenPrepareLooku EXPECT_TRUE(l0LookupTable.isSharedHandle); EXPECT_TRUE(l0LookupTable.sharedHandleType.isSupportedHandle); EXPECT_TRUE(l0LookupTable.sharedHandleType.isNTHandle); - EXPECT_EQ(l0LookupTable.sharedHandleType.ntHnadle, importNTHandle.handle); + EXPECT_EQ(l0LookupTable.sharedHandleType.ntHandle, importNTHandle.handle); } TEST(L0StructuresLookupTableTests, givenL0StructuresWithSupportedExportHandlesWhenPrepareLookupTableThenProperFieldsInLookupTableAreSet) { diff --git a/level_zero/core/test/unit_tests/sources/image/test_image.cpp b/level_zero/core/test/unit_tests/sources/image/test_image.cpp index d9c50cca38..4dcc47a19a 100644 --- a/level_zero/core/test/unit_tests/sources/image/test_image.cpp +++ b/level_zero/core/test/unit_tests/sources/image/test_image.cpp @@ -486,10 +486,10 @@ class MemoryManagerNTHandleMock : public NEO::OsAgnosticMemoryManager { public: MemoryManagerNTHandleMock(NEO::ExecutionEnvironment &executionEnvironment) : NEO::OsAgnosticMemoryManager(executionEnvironment) {} - NEO::GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override { + NEO::GraphicsAllocation *createGraphicsAllocationFromSharedHandle(const OsHandleData &osHandleData, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override { auto graphicsAllocation = createMemoryAllocation(AllocationType::internalHostMemory, nullptr, reinterpret_cast(1), 1, 4096u, osHandleData.handle, MemoryPool::systemCpuInaccessible, - rootDeviceIndex, false, false, false); + properties.rootDeviceIndex, false, false, false); graphicsAllocation->setSharedHandle(osHandleData.handle); graphicsAllocation->set32BitAllocation(false); GmmRequirements gmmRequirements{}; diff --git a/level_zero/core/test/unit_tests/sources/memory/linux/test_memory_linux.cpp b/level_zero/core/test/unit_tests/sources/memory/linux/test_memory_linux.cpp index ea4d2a0261..e7f80c1133 100644 --- a/level_zero/core/test/unit_tests/sources/memory/linux/test_memory_linux.cpp +++ b/level_zero/core/test/unit_tests/sources/memory/linux/test_memory_linux.cpp @@ -67,7 +67,6 @@ class MemoryManagerIpcImplicitScalingObtainFdMock : public NEO::DrmMemoryManager NEO::GraphicsAllocation *createGraphicsAllocationFromSharedHandle(const OsHandleData &osHandleData, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override { return nullptr; } void addAllocationToHostPtrManager(NEO::GraphicsAllocation *memory) override{}; void removeAllocationFromHostPtrManager(NEO::GraphicsAllocation *memory) override{}; - NEO::GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override { return nullptr; }; AllocationStatus populateOsHandles(NEO::OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override { return AllocationStatus::Success; }; void cleanOsHandles(NEO::OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override{}; void freeGraphicsMemoryImpl(NEO::GraphicsAllocation *gfxAllocation) override{}; @@ -484,7 +483,6 @@ class MemoryManagerIpcObtainFdMock : public NEO::DrmMemoryManager { NEO::GraphicsAllocation *createGraphicsAllocationFromSharedHandle(const OsHandleData &osHandleData, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override { return nullptr; } void addAllocationToHostPtrManager(NEO::GraphicsAllocation *memory) override{}; void removeAllocationFromHostPtrManager(NEO::GraphicsAllocation *memory) override{}; - NEO::GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override { return nullptr; }; AllocationStatus populateOsHandles(NEO::OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override { return AllocationStatus::Success; }; void cleanOsHandles(NEO::OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override{}; void freeGraphicsMemoryImpl(NEO::GraphicsAllocation *gfxAllocation) override{}; diff --git a/level_zero/core/test/unit_tests/sources/memory/test_memory.cpp b/level_zero/core/test/unit_tests/sources/memory/test_memory.cpp index e79efb3177..f151862cff 100644 --- a/level_zero/core/test/unit_tests/sources/memory/test_memory.cpp +++ b/level_zero/core/test/unit_tests/sources/memory/test_memory.cpp @@ -240,7 +240,6 @@ TEST_F(MemoryExportImportImplicitScalingTest, uint32_t numIpcHandles = 0; result = context->getIpcMemHandles(ptr, &numIpcHandles, nullptr); EXPECT_EQ(ZE_RESULT_SUCCESS, result); - this->currMemoryManager->failOnCreateGraphicsAllocationFromNTHandle = false; auto usmManager = context->getDriverHandle()->getSvmAllocsManager(); auto currentAllocationCount = usmManager->allocationsCounter.load(); @@ -330,7 +329,6 @@ TEST_F(MemoryExportImportImplicitScalingTest, IpcMemoryData &ipcData = *reinterpret_cast(ipcHandle.data); ipcData.type = static_cast(ZE_MEMORY_TYPE_HOST); currMemoryManager->failOnCreateGraphicsAllocationFromSharedHandle = true; - currMemoryManager->failOnCreateGraphicsAllocationFromNTHandle = true; result = context->openIpcMemHandle(device->toHandle(), ipcHandle, flags, &ipcPtr); EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, result); diff --git a/opencl/source/sharings/d3d/d3d_surface.cpp b/opencl/source/sharings/d3d/d3d_surface.cpp index ce7e4de142..4b684d885e 100644 --- a/opencl/source/sharings/d3d/d3d_surface.cpp +++ b/opencl/source/sharings/d3d/d3d_surface.cpp @@ -89,7 +89,7 @@ Image *D3DSurface::create(Context *context, cl_dx9_surface_info_khr *surfaceInfo AllocationType::sharedImage, false, // isMultiStorageAllocation context->getDeviceBitfieldForAllocation(rootDeviceIndex)); - MemoryManager::ExtendedOsHandleData osHandleData{surfaceInfo->shared_handle}; + MemoryManager::OsHandleData osHandleData{surfaceInfo->shared_handle}; alloc = context->getMemoryManager()->createGraphicsAllocationFromSharedHandle(osHandleData, allocProperties, false, false, true, nullptr); updateImgInfoAndDesc(alloc->getDefaultGmm(), imgInfo, imagePlane, 0u); diff --git a/opencl/source/sharings/d3d/d3d_texture.cpp b/opencl/source/sharings/d3d/d3d_texture.cpp index 594acdbc3f..8b5fc6a446 100644 --- a/opencl/source/sharings/d3d/d3d_texture.cpp +++ b/opencl/source/sharings/d3d/d3d_texture.cpp @@ -73,31 +73,22 @@ Image *D3DTexture::create2d(Context *context, D3DTexture2d *d3dTexture, cl_ auto memoryManager = context->getMemoryManager(); auto rootDeviceIndex = context->getDevice(0)->getRootDeviceIndex(); - if (textureDesc.MiscFlags & D3DResourceFlags::MISC_SHARED_NTHANDLE) { - sharingFcns->getSharedNTHandle(textureStaging, &sharedHandle); - if (memoryManager->verifyHandle(toOsHandle(sharedHandle), rootDeviceIndex, true)) { - MemoryManager::ExtendedOsHandleData osHandleData{sharedHandle, arrayIndex}; - alloc = memoryManager->createGraphicsAllocationFromNTHandle(osHandleData, rootDeviceIndex, AllocationType::sharedImage); - } else { - err.set(CL_INVALID_D3D11_RESOURCE_KHR); - return nullptr; - } + bool ntHandle = textureDesc.MiscFlags & D3DResourceFlags::MISC_SHARED_NTHANDLE; + ntHandle ? sharingFcns->getSharedNTHandle(textureStaging, &sharedHandle) : sharingFcns->getSharedHandle(textureStaging, &sharedHandle); + AllocationProperties allocProperties(rootDeviceIndex, + false, // allocateMemory + 0u, // size + AllocationType::sharedImage, + false, // isMultiStorageAllocation + context->getDeviceBitfieldForAllocation(rootDeviceIndex)); + if (memoryManager->verifyHandle(toOsHandle(sharedHandle), rootDeviceIndex, ntHandle)) { + MemoryManager::OsHandleData osHandleData{sharedHandle, arrayIndex}; + alloc = memoryManager->createGraphicsAllocationFromSharedHandle(osHandleData, allocProperties, false, false, true, nullptr); } else { - sharingFcns->getSharedHandle(textureStaging, &sharedHandle); - AllocationProperties allocProperties(rootDeviceIndex, - false, // allocateMemory - 0u, // size - AllocationType::sharedImage, - false, // isMultiStorageAllocation - context->getDeviceBitfieldForAllocation(rootDeviceIndex)); - if (memoryManager->verifyHandle(toOsHandle(sharedHandle), rootDeviceIndex, false)) { - MemoryManager::ExtendedOsHandleData osHandleData{sharedHandle, arrayIndex}; - alloc = memoryManager->createGraphicsAllocationFromSharedHandle(osHandleData, allocProperties, false, false, true, nullptr); - } else { - err.set(CL_INVALID_D3D11_RESOURCE_KHR); - return nullptr; - } + err.set(CL_INVALID_D3D11_RESOURCE_KHR); + return nullptr; } + if (alloc == nullptr) { err.set(CL_OUT_OF_HOST_MEMORY); return nullptr; @@ -168,31 +159,22 @@ Image *D3DTexture::create3d(Context *context, D3DTexture3d *d3dTexture, cl_ auto memoryManager = context->getMemoryManager(); auto rootDeviceIndex = context->getDevice(0)->getRootDeviceIndex(); - if (textureDesc.MiscFlags & D3DResourceFlags::MISC_SHARED_NTHANDLE) { - sharingFcns->getSharedNTHandle(textureStaging, &sharedHandle); - if (memoryManager->verifyHandle(toOsHandle(sharedHandle), rootDeviceIndex, true)) { - MemoryManager::ExtendedOsHandleData osHandleData{sharedHandle}; - alloc = memoryManager->createGraphicsAllocationFromNTHandle(osHandleData, rootDeviceIndex, AllocationType::sharedImage); - } else { - err.set(CL_INVALID_D3D11_RESOURCE_KHR); - return nullptr; - } + bool ntHandle = textureDesc.MiscFlags & D3DResourceFlags::MISC_SHARED_NTHANDLE; + ntHandle ? sharingFcns->getSharedNTHandle(textureStaging, &sharedHandle) : sharingFcns->getSharedHandle(textureStaging, &sharedHandle); + AllocationProperties allocProperties(rootDeviceIndex, + false, // allocateMemory + 0u, // size + AllocationType::sharedImage, + false, // isMultiStorageAllocation + context->getDeviceBitfieldForAllocation(rootDeviceIndex)); + if (memoryManager->verifyHandle(toOsHandle(sharedHandle), rootDeviceIndex, ntHandle)) { + MemoryManager::OsHandleData osHandleData{sharedHandle}; + alloc = memoryManager->createGraphicsAllocationFromSharedHandle(osHandleData, allocProperties, false, false, true, nullptr); } else { - sharingFcns->getSharedHandle(textureStaging, &sharedHandle); - AllocationProperties allocProperties(rootDeviceIndex, - false, // allocateMemory - 0u, // size - AllocationType::sharedImage, - false, // isMultiStorageAllocation - context->getDeviceBitfieldForAllocation(rootDeviceIndex)); - if (memoryManager->verifyHandle(toOsHandle(sharedHandle), rootDeviceIndex, false)) { - MemoryManager::ExtendedOsHandleData osHandleData{sharedHandle}; - alloc = memoryManager->createGraphicsAllocationFromSharedHandle(osHandleData, allocProperties, false, false, true, nullptr); - } else { - err.set(CL_INVALID_D3D11_RESOURCE_KHR); - return nullptr; - } + err.set(CL_INVALID_D3D11_RESOURCE_KHR); + return nullptr; } + bool is3DUavOrRtv = false; if (textureDesc.BindFlags & D3DBindFLags::D3D11_BIND_RENDER_TARGET || textureDesc.BindFlags & D3DBindFLags::D3D11_BIND_UNORDERED_ACCESS) { is3DUavOrRtv = true; diff --git a/opencl/source/sharings/gl/linux/gl_texture_linux.cpp b/opencl/source/sharings/gl/linux/gl_texture_linux.cpp index 871da936c2..f7d4eda745 100644 --- a/opencl/source/sharings/gl/linux/gl_texture_linux.cpp +++ b/opencl/source/sharings/gl/linux/gl_texture_linux.cpp @@ -145,7 +145,7 @@ Image *GlTexture::createSharedGlTexture(Context *context, cl_mem_flags flags, cl &imgInfo, AllocationType::sharedImage, context->getDeviceBitfieldForAllocation(context->getDevice(0)->getRootDeviceIndex())); - MemoryManager::ExtendedOsHandleData osHandleData{texInfo.globalShareHandle}; + MemoryManager::OsHandleData osHandleData{texInfo.globalShareHandle}; auto alloc = memoryManager->createGraphicsAllocationFromSharedHandle(osHandleData, allocProperties, false, false, false, nullptr); if (alloc == nullptr) { diff --git a/opencl/source/sharings/gl/windows/gl_texture_windows.cpp b/opencl/source/sharings/gl/windows/gl_texture_windows.cpp index cf6f0606c9..99f04b3de5 100644 --- a/opencl/source/sharings/gl/windows/gl_texture_windows.cpp +++ b/opencl/source/sharings/gl/windows/gl_texture_windows.cpp @@ -59,7 +59,7 @@ Image *GlTexture::createSharedGlTexture(Context *context, cl_mem_flags flags, cl AllocationType::sharedImage, false, // isMultiStorageAllocation context->getDeviceBitfieldForAllocation(context->getDevice(0)->getRootDeviceIndex())); - MemoryManager::ExtendedOsHandleData osHandleData{texInfo.globalShareHandle}; + MemoryManager::OsHandleData osHandleData{texInfo.globalShareHandle}; auto alloc = memoryManager->createGraphicsAllocationFromSharedHandle(osHandleData, allocProperties, false, false, true, nullptr); if (alloc == nullptr) { diff --git a/opencl/source/sharings/unified/unified_sharing.cpp b/opencl/source/sharings/unified/unified_sharing.cpp index f5e457253e..26ee483e28 100644 --- a/opencl/source/sharings/unified/unified_sharing.cpp +++ b/opencl/source/sharings/unified/unified_sharing.cpp @@ -40,24 +40,17 @@ GraphicsAllocation *UnifiedSharing::createGraphicsAllocation(Context *context, U GraphicsAllocation *UnifiedSharing::createGraphicsAllocation(Context *context, UnifiedSharingMemoryDescription description, ImageInfo *imgInfo, AllocationType allocationType) { auto memoryManager = context->getMemoryManager(); - switch (description.type) { - case UnifiedSharingHandleType::win32Nt: { - MemoryManager::OsHandleData osHandleData{description.handle}; - return memoryManager->createGraphicsAllocationFromNTHandle(osHandleData, context->getDevice(0)->getRootDeviceIndex(), allocationType); - } - case UnifiedSharingHandleType::linuxFd: - case UnifiedSharingHandleType::win32Shared: { - const AllocationProperties properties{context->getDevice(0)->getRootDeviceIndex(), - false, // allocateMemory - imgInfo, - allocationType, - context->getDeviceBitfieldForAllocation(context->getDevice(0)->getRootDeviceIndex())}; - MemoryManager::OsHandleData osHandleData{description.handle}; - return memoryManager->createGraphicsAllocationFromSharedHandle(osHandleData, properties, false, false, true, nullptr); - } - default: + + if (description.type != UnifiedSharingHandleType::win32Nt && description.type != UnifiedSharingHandleType::linuxFd && description.type != UnifiedSharingHandleType::win32Shared) return nullptr; - } + + const AllocationProperties properties{context->getDevice(0)->getRootDeviceIndex(), + false, // allocateMemory + imgInfo, + allocationType, + context->getDeviceBitfieldForAllocation(context->getDevice(0)->getRootDeviceIndex())}; + MemoryManager::OsHandleData osHandleData{description.handle}; + return memoryManager->createGraphicsAllocationFromSharedHandle(osHandleData, properties, false, false, true, nullptr); } template <> diff --git a/opencl/test/unit_test/fixtures/d3d_test_fixture.h b/opencl/test/unit_test/fixtures/d3d_test_fixture.h index e146f0c260..bbc06c2d4d 100644 --- a/opencl/test/unit_test/fixtures/d3d_test_fixture.h +++ b/opencl/test/unit_test/fixtures/d3d_test_fixture.h @@ -59,16 +59,6 @@ class D3DTests : public PlatformFixture, public ::testing::Test { gmmOwnershipPassed = true; return alloc; } - GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override { - if (failAlloc) { - return nullptr; - } - AllocationProperties properties(rootDeviceIndex, true, 0, AllocationType::internalHostMemory, false, false, 0); - auto alloc = OsAgnosticMemoryManager::createGraphicsAllocationFromSharedHandle(osHandleData, properties, false, false, true, nullptr); - alloc->setDefaultGmm(forceGmm); - gmmOwnershipPassed = true; - return alloc; - } bool verifyValue = true; bool verifyHandle(osHandle handle, uint32_t rootDeviceIndex, bool) override { return verifyValue; } diff --git a/opencl/test/unit_test/mem_obj/windows/image_windows_tests.cpp b/opencl/test/unit_test/mem_obj/windows/image_windows_tests.cpp index e31e900fd0..7ca2abd7ef 100644 --- a/opencl/test/unit_test/mem_obj/windows/image_windows_tests.cpp +++ b/opencl/test/unit_test/mem_obj/windows/image_windows_tests.cpp @@ -14,13 +14,13 @@ using namespace NEO; struct ImageWindowsTestsMockMemoryManager : MockMemoryManager { using MockMemoryManager::MockMemoryManager; - GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override { + GraphicsAllocation *createGraphicsAllocationFromSharedHandle(const OsHandleData &osHandleData, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override { - auto graphicsAllocation = createMemoryAllocation(allocType, nullptr, reinterpret_cast(1), 1, + auto graphicsAllocation = createMemoryAllocation(properties.allocationType, nullptr, reinterpret_cast(1), 1, 4096u, osHandleData.handle, MemoryPool::systemCpuInaccessible, - rootDeviceIndex, false, false, false); + properties.rootDeviceIndex, false, false, false); - graphicsAllocation->setDefaultGmm(new MockGmm(executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getGmmHelper())); + graphicsAllocation->setDefaultGmm(new MockGmm(executionEnvironment.rootDeviceEnvironments[properties.rootDeviceIndex]->getGmmHelper())); graphicsAllocation->getDefaultGmm()->gmmResourceInfo->peekGmmResourceInfo()->OverrideSurfaceType(RESOURCE_BUFFER); return graphicsAllocation; diff --git a/opencl/test/unit_test/sharings/unified/unified_sharing_fixtures.h b/opencl/test/unit_test/sharings/unified/unified_sharing_fixtures.h index cec12bb37a..d1e32ee60f 100644 --- a/opencl/test/unit_test/sharings/unified/unified_sharing_fixtures.h +++ b/opencl/test/unit_test/sharings/unified/unified_sharing_fixtures.h @@ -60,17 +60,17 @@ struct UnifiedSharingContextFixture : ::testing::Test { template struct UnifiedSharingMockMemoryManager : MockMemoryManager { using MockMemoryManager::MockMemoryManager; - GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override { + GraphicsAllocation *createGraphicsAllocationFromSharedHandle(const OsHandleData &osHandleData, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override { if (!validMemoryManager) { return nullptr; } auto graphicsAllocation = createMemoryAllocation(AllocationType::internalHostMemory, nullptr, reinterpret_cast(1), 1, 4096u, osHandleData.handle, MemoryPool::systemCpuInaccessible, - rootDeviceIndex, false, false, false); + properties.rootDeviceIndex, false, false, false); graphicsAllocation->setSharedHandle(osHandleData.handle); graphicsAllocation->set32BitAllocation(false); - graphicsAllocation->setDefaultGmm(new MockGmm(executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getGmmHelper())); + graphicsAllocation->setDefaultGmm(new MockGmm(executionEnvironment.rootDeviceEnvironments[properties.rootDeviceIndex]->getGmmHelper())); return graphicsAllocation; } }; diff --git a/opencl/test/unit_test/sharings/unified/unified_sharing_image_tests.cpp b/opencl/test/unit_test/sharings/unified/unified_sharing_image_tests.cpp index 58d7702da4..da15d8b21f 100644 --- a/opencl/test/unit_test/sharings/unified/unified_sharing_image_tests.cpp +++ b/opencl/test/unit_test/sharings/unified/unified_sharing_image_tests.cpp @@ -110,8 +110,8 @@ class MockProductHelper : public ProductHelperHw { }; struct MemoryManagerReturningCompressedAllocations : UnifiedSharingMockMemoryManager { - GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override { - auto allocation = UnifiedSharingMockMemoryManager::createGraphicsAllocationFromNTHandle(osHandleData, rootDeviceIndex, AllocationType::sharedImage); + GraphicsAllocation *createGraphicsAllocationFromSharedHandle(const OsHandleData &osHandleData, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override { + auto allocation = UnifiedSharingMockMemoryManager::createGraphicsAllocationFromSharedHandle(osHandleData, properties, false, false, false, nullptr); auto gmm = allocation->getDefaultGmm(); auto mockGmmResourceInfo = std::make_unique(gmm->gmmResourceInfo->peekGmmResourceInfo()); diff --git a/opencl/test/unit_test/sharings/unified/unified_sharing_tests.cpp b/opencl/test/unit_test/sharings/unified/unified_sharing_tests.cpp index 30fa9f8c1b..8bc3889d87 100644 --- a/opencl/test/unit_test/sharings/unified/unified_sharing_tests.cpp +++ b/opencl/test/unit_test/sharings/unified/unified_sharing_tests.cpp @@ -164,19 +164,13 @@ struct UnifiedSharingCreateAllocationTests : UnifiedSharingTestsWithMemoryManage struct MemoryManagerCheckingAllocationMethod : MockMemoryManager { using MockMemoryManager::MockMemoryManager; - GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override { - this->createFromNTHandleCalled = true; - this->handle = osHandleData.handle; - return nullptr; - } GraphicsAllocation *createGraphicsAllocationFromSharedHandle(const OsHandleData &osHandleData, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override { this->createFromSharedHandleCalled = true; - this->handle = osHandleData.handle; this->properties = std::make_unique(properties); + this->handle = osHandleData.handle; return nullptr; } - bool createFromNTHandleCalled = false; bool createFromSharedHandleCalled = false; osHandle handle; std::unique_ptr properties; @@ -196,15 +190,14 @@ struct UnifiedSharingCreateAllocationTests : UnifiedSharingTestsWithMemoryManage std::unique_ptr> memoryManagerBackup; }; -TEST_F(UnifiedSharingCreateAllocationTests, givenWindowsNtHandleWhenCreateGraphicsAllocationIsCalledThenUseNtHandleMethod) { +TEST_F(UnifiedSharingCreateAllocationTests, givenWindowsNtHandleWhenCreateGraphicsAllocationIsCalledThenUseSharedHandleMethod) { UnifiedSharingMemoryDescription desc{}; desc.handle = reinterpret_cast(0x1234); desc.type = UnifiedSharingHandleType::win32Nt; AllocationType allocationType = AllocationType::sharedImage; MockSharingHandler::createGraphicsAllocation(this->context.get(), desc, allocationType); - EXPECT_TRUE(memoryManager->createFromNTHandleCalled); - EXPECT_FALSE(memoryManager->createFromSharedHandleCalled); + EXPECT_TRUE(memoryManager->createFromSharedHandleCalled); EXPECT_EQ(toOsHandle(desc.handle), memoryManager->handle); } @@ -215,7 +208,6 @@ TEST_F(UnifiedSharingCreateAllocationTests, givenWindowsSharedHandleWhenCreateGr AllocationType allocationType = AllocationType::sharedImage; MockSharingHandler::createGraphicsAllocation(this->context.get(), desc, allocationType); - EXPECT_FALSE(memoryManager->createFromNTHandleCalled); EXPECT_TRUE(memoryManager->createFromSharedHandleCalled); EXPECT_EQ(toOsHandle(desc.handle), memoryManager->handle); const AllocationProperties expectedProperties{0u, false, 0u, allocationType, false, {}}; @@ -229,7 +221,6 @@ TEST_F(UnifiedSharingCreateAllocationTests, givenLinuxSharedHandleWhenCreateGrap AllocationType allocationType = AllocationType::sharedImage; MockSharingHandler::createGraphicsAllocation(this->context.get(), desc, allocationType); - EXPECT_FALSE(memoryManager->createFromNTHandleCalled); EXPECT_TRUE(memoryManager->createFromSharedHandleCalled); EXPECT_EQ(toOsHandle(desc.handle), memoryManager->handle); const AllocationProperties expectedProperties{0u, false, 0u, allocationType, false, {}}; diff --git a/shared/source/memory_manager/memory_manager.h b/shared/source/memory_manager/memory_manager.h index ccbd7be55d..f96182f6a9 100644 --- a/shared/source/memory_manager/memory_manager.h +++ b/shared/source/memory_manager/memory_manager.h @@ -97,18 +97,11 @@ class MemoryManager { struct OsHandleData { osHandle handle; + uint32_t arrayIndex; - OsHandleData(uint64_t handle) : handle(static_cast(handle)){}; - OsHandleData(void *handle) : handle(toOsHandle(handle)){}; - }; - - struct ExtendedOsHandleData : public OsHandleData { - uint32_t arrayIndex = 0; - - ExtendedOsHandleData(uint64_t handle) : OsHandleData(handle){}; - ExtendedOsHandleData(void *handle) : OsHandleData(handle){}; - ExtendedOsHandleData(osHandle handle, uint32_t arrayIndex) : OsHandleData(handle), arrayIndex(arrayIndex){}; - ExtendedOsHandleData(void *handle, uint32_t arrayIndex) : OsHandleData(handle), arrayIndex(arrayIndex){}; + OsHandleData(uint64_t handle, uint32_t arrayIndex = 0) : handle(static_cast(handle)), arrayIndex(arrayIndex){}; + OsHandleData(void *handle, uint32_t arrayIndex = 0) : handle(toOsHandle(handle)), arrayIndex(arrayIndex){}; + OsHandleData(osHandle handle, uint32_t arrayIndex = 0) : handle(handle), arrayIndex(arrayIndex){}; }; MemoryManager(ExecutionEnvironment &executionEnvironment); @@ -139,7 +132,6 @@ class MemoryManager { virtual GraphicsAllocation *createGraphicsAllocationFromSharedHandle(const OsHandleData &osHandleData, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) = 0; virtual void closeSharedHandle(GraphicsAllocation *graphicsAllocation){}; virtual void closeInternalHandle(uint64_t &handle, uint32_t handleId, GraphicsAllocation *graphicsAllocation){}; - virtual GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) = 0; virtual bool mapAuxGpuVA(GraphicsAllocation *graphicsAllocation); diff --git a/shared/source/memory_manager/os_agnostic_memory_manager.h b/shared/source/memory_manager/os_agnostic_memory_manager.h index eae45aaabf..3557967896 100644 --- a/shared/source/memory_manager/os_agnostic_memory_manager.h +++ b/shared/source/memory_manager/os_agnostic_memory_manager.h @@ -25,7 +25,6 @@ class OsAgnosticMemoryManager : public MemoryManager { ~OsAgnosticMemoryManager() override; GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override; GraphicsAllocation *createGraphicsAllocationFromSharedHandle(const OsHandleData &osHandleData, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override; - GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override { return nullptr; } void addAllocationToHostPtrManager(GraphicsAllocation *gfxAllocation) override; void removeAllocationFromHostPtrManager(GraphicsAllocation *gfxAllocation) override; diff --git a/shared/source/os_interface/linux/drm_memory_manager.h b/shared/source/os_interface/linux/drm_memory_manager.h index f7e0ea164c..9a2d9e9ab4 100644 --- a/shared/source/os_interface/linux/drm_memory_manager.h +++ b/shared/source/os_interface/linux/drm_memory_manager.h @@ -44,8 +44,6 @@ class DrmMemoryManager : public MemoryManager { void closeSharedHandle(GraphicsAllocation *gfxAllocation) override; void closeInternalHandle(uint64_t &handle, uint32_t handleId, GraphicsAllocation *graphicsAllocation) override; - GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override { return nullptr; } - uint64_t getSystemSharedMemory(uint32_t rootDeviceIndex) override; uint64_t getLocalMemorySize(uint32_t rootDeviceIndex, uint32_t deviceBitfield) override; double getPercentOfGlobalMemoryAvailable(uint32_t rootDeviceIndex) override; diff --git a/shared/source/os_interface/windows/wddm/wddm.cpp b/shared/source/os_interface/windows/wddm/wddm.cpp index 6fc31b3076..6e0ac39d40 100644 --- a/shared/source/os_interface/windows/wddm/wddm.cpp +++ b/shared/source/os_interface/windows/wddm/wddm.cpp @@ -828,7 +828,7 @@ bool Wddm::verifySharedHandle(D3DKMT_HANDLE osHandle) { return status == STATUS_SUCCESS; } -bool Wddm::openSharedHandle(const MemoryManager::ExtendedOsHandleData &osHandleData, WddmAllocation *alloc) { +bool Wddm::openSharedHandle(const MemoryManager::OsHandleData &osHandleData, WddmAllocation *alloc) { D3DKMT_QUERYRESOURCEINFO queryResourceInfo = {}; queryResourceInfo.hDevice = device; queryResourceInfo.hGlobalShare = osHandleData.handle; @@ -878,7 +878,7 @@ bool Wddm::verifyNTHandle(HANDLE handle) { return status == STATUS_SUCCESS; } -bool Wddm::openNTHandle(const MemoryManager::ExtendedOsHandleData &osHandleData, WddmAllocation *alloc) { +bool Wddm::openNTHandle(const MemoryManager::OsHandleData &osHandleData, WddmAllocation *alloc) { D3DKMT_QUERYRESOURCEINFOFROMNTHANDLE queryResourceInfoFromNtHandle = {}; queryResourceInfoFromNtHandle.hDevice = device; queryResourceInfoFromNtHandle.hNtHandle = reinterpret_cast(static_cast(osHandleData.handle)); diff --git a/shared/source/os_interface/windows/wddm/wddm.h b/shared/source/os_interface/windows/wddm/wddm.h index a850008c90..6cf0c2d8f9 100644 --- a/shared/source/os_interface/windows/wddm/wddm.h +++ b/shared/source/os_interface/windows/wddm/wddm.h @@ -79,9 +79,9 @@ class Wddm : public DriverModel { MOCKABLE_VIRTUAL NTSTATUS createAllocationsAndMapGpuVa(OsHandleStorage &osHandles); MOCKABLE_VIRTUAL bool destroyAllocations(const D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle); MOCKABLE_VIRTUAL bool verifySharedHandle(D3DKMT_HANDLE osHandle); - MOCKABLE_VIRTUAL bool openSharedHandle(const MemoryManager::ExtendedOsHandleData &osHandleData, WddmAllocation *alloc); + MOCKABLE_VIRTUAL bool openSharedHandle(const MemoryManager::OsHandleData &osHandleData, WddmAllocation *alloc); MOCKABLE_VIRTUAL bool verifyNTHandle(HANDLE handle); - bool openNTHandle(const MemoryManager::ExtendedOsHandleData &osHandleData, WddmAllocation *alloc); + bool openNTHandle(const MemoryManager::OsHandleData &osHandleData, WddmAllocation *alloc); MOCKABLE_VIRTUAL void *lockResource(const D3DKMT_HANDLE &handle, bool applyMakeResidentPriorToLock, size_t size); MOCKABLE_VIRTUAL void unlockResource(const D3DKMT_HANDLE &handle); MOCKABLE_VIRTUAL void kmDafLock(D3DKMT_HANDLE handle); diff --git a/shared/source/os_interface/windows/wddm_memory_manager.cpp b/shared/source/os_interface/windows/wddm_memory_manager.cpp index 01ab5c0ba2..ad7468e302 100644 --- a/shared/source/os_interface/windows/wddm_memory_manager.cpp +++ b/shared/source/os_interface/windows/wddm_memory_manager.cpp @@ -599,16 +599,14 @@ bool WddmMemoryManager::isNTHandle(osHandle handle, uint32_t rootDeviceIndex) { return status; } -GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(const OsHandleData &osHandleData, bool requireSpecificBitness, bool ntHandle, AllocationType allocationType, uint32_t rootDeviceIndex, void *mapPointer) { - auto allocation = std::make_unique(rootDeviceIndex, allocationType, nullptr, 0, osHandleData.handle, MemoryPool::systemCpuInaccessible, maxOsContextCount, 0llu); +GraphicsAllocation *WddmMemoryManager::createGraphicsAllocationFromSharedHandle(const OsHandleData &osHandleData, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) { + auto allocation = std::make_unique(properties.rootDeviceIndex, properties.allocationType, nullptr, 0, osHandleData.handle, MemoryPool::systemCpuInaccessible, maxOsContextCount, 0llu); - bool status = false; - if (allocationType == AllocationType::sharedImage) { - status = ntHandle ? getWddm(rootDeviceIndex).openNTHandle(static_cast(osHandleData), allocation.get()) : getWddm(rootDeviceIndex).openSharedHandle(static_cast(osHandleData), allocation.get()); - } else { - MemoryManager::ExtendedOsHandleData extendedOsHandleData{osHandleData.handle}; - status = ntHandle ? getWddm(rootDeviceIndex).openNTHandle(extendedOsHandleData, allocation.get()) : getWddm(rootDeviceIndex).openSharedHandle(extendedOsHandleData, allocation.get()); - } + bool status; + if (verifyHandle(osHandleData.handle, properties.rootDeviceIndex, false)) + status = getWddm(properties.rootDeviceIndex).openSharedHandle(osHandleData, allocation.get()); + else + status = getWddm(properties.rootDeviceIndex).openNTHandle(osHandleData, allocation.get()); if (!status) { return nullptr; @@ -621,7 +619,7 @@ GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(const OsHandle if (mapPointer == nullptr) { if (is32bit) { void *ptr = nullptr; - if (!getWddm(rootDeviceIndex).reserveValidAddressRange(size, ptr)) { + if (!getWddm(properties.rootDeviceIndex).reserveValidAddressRange(size, ptr)) { return nullptr; } allocation->setReservedAddressRange(ptr, size); @@ -644,18 +642,6 @@ GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(const OsHandle return allocation.release(); } -GraphicsAllocation *WddmMemoryManager::createGraphicsAllocationFromMultipleSharedHandles(const std::vector &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) { - return nullptr; -} - -GraphicsAllocation *WddmMemoryManager::createGraphicsAllocationFromSharedHandle(const OsHandleData &osHandleData, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) { - return createAllocationFromHandle(osHandleData, requireSpecificBitness, false, properties.allocationType, properties.rootDeviceIndex, mapPointer); -} - -GraphicsAllocation *WddmMemoryManager::createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) { - return createAllocationFromHandle(osHandleData, false, true, allocType, rootDeviceIndex, nullptr); -} - void WddmMemoryManager::addAllocationToHostPtrManager(GraphicsAllocation *gfxAllocation) { WddmAllocation *wddmMemory = static_cast(gfxAllocation); FragmentStorage fragment = {}; diff --git a/shared/source/os_interface/windows/wddm_memory_manager.h b/shared/source/os_interface/windows/wddm_memory_manager.h index 5051daa18f..421f4b0a5c 100644 --- a/shared/source/os_interface/windows/wddm_memory_manager.h +++ b/shared/source/os_interface/windows/wddm_memory_manager.h @@ -35,9 +35,8 @@ class WddmMemoryManager : public MemoryManager { void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation, bool isImportedAllocation) override; void handleFenceCompletion(GraphicsAllocation *allocation) override; - GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override; + GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override { return nullptr; } GraphicsAllocation *createGraphicsAllocationFromSharedHandle(const OsHandleData &osHandleData, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override; - GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override; void addAllocationToHostPtrManager(GraphicsAllocation *memory) override; void removeAllocationFromHostPtrManager(GraphicsAllocation *memory) override; diff --git a/shared/test/common/mock_gdi/mock_gdi.cpp b/shared/test/common/mock_gdi/mock_gdi.cpp index 8739d7eec0..3c745dce94 100644 --- a/shared/test/common/mock_gdi/mock_gdi.cpp +++ b/shared/test/common/mock_gdi/mock_gdi.cpp @@ -480,7 +480,7 @@ NTSTATUS __stdcall mockD3DKMTOpenResourceFromNtHandle(IN OUT D3DKMT_OPENRESOURCE } NTSTATUS __stdcall mockD3DKMTQueryResourceInfo(IN OUT D3DKMT_QUERYRESOURCEINFO *queryResourceInfo) { - if (queryResourceInfo->hDevice != DEVICE_HANDLE || queryResourceInfo->hGlobalShare == INVALID_HANDLE) { + if (queryResourceInfo->hDevice != DEVICE_HANDLE || queryResourceInfo->hGlobalShare == INVALID_HANDLE || queryResourceInfo->hGlobalShare == NT_ALLOCATION_HANDLE) { return STATUS_INVALID_PARAMETER; } queryResourceInfo->TotalPrivateDriverDataSize = totalPrivateSize; diff --git a/shared/test/common/mocks/mock_memory_manager.cpp b/shared/test/common/mocks/mock_memory_manager.cpp index 7959bbc8d5..42f5019703 100644 --- a/shared/test/common/mocks/mock_memory_manager.cpp +++ b/shared/test/common/mocks/mock_memory_manager.cpp @@ -232,20 +232,6 @@ GraphicsAllocation *MockMemoryManager::createGraphicsAllocationFromSharedHandle( } } -GraphicsAllocation *MockMemoryManager::createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) { - if (osHandleData.handle != invalidSharedHandle) { - auto graphicsAllocation = createMemoryAllocation(NEO::AllocationType::sharedBuffer, nullptr, reinterpret_cast(1), 1, - ipcAllocationSize, osHandleData.handle, MemoryPool::systemCpuInaccessible, rootDeviceIndex, - false, false, false); - graphicsAllocation->setSharedHandle(osHandleData.handle); - this->capturedSharedHandle = osHandleData.handle; - return graphicsAllocation; - } else { - this->capturedSharedHandle = osHandleData.handle; - return nullptr; - } -} - bool MockMemoryManager::copyMemoryToAllocationBanks(GraphicsAllocation *graphicsAllocation, size_t destinationOffset, const void *memoryToCopy, size_t sizeToCopy, DeviceBitfield handleMask) { copyMemoryToAllocationBanksCalled++; copyMemoryToAllocationBanksParamsPassed.push_back({graphicsAllocation, destinationOffset, memoryToCopy, sizeToCopy, handleMask}); diff --git a/shared/test/common/mocks/mock_memory_manager.h b/shared/test/common/mocks/mock_memory_manager.h index 02441747fc..706260f174 100644 --- a/shared/test/common/mocks/mock_memory_manager.h +++ b/shared/test/common/mocks/mock_memory_manager.h @@ -84,7 +84,6 @@ class MockMemoryManager : public MemoryManagerCreate { GraphicsAllocation *allocateGraphicsMemoryWithProperties(const AllocationProperties &properties, const void *ptr) override; GraphicsAllocation *createGraphicsAllocationFromExistingStorage(AllocationProperties &properties, void *ptr, MultiGraphicsAllocation &multiGraphicsAllocation) override; GraphicsAllocation *createGraphicsAllocationFromSharedHandle(const OsHandleData &osHandleData, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override; - GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override; void *allocateSystemMemory(size_t size, size_t alignment) override; @@ -329,9 +328,6 @@ class FailMemoryManager : public MockMemoryManager { GraphicsAllocation *createGraphicsAllocationFromSharedHandle(const OsHandleData &osHandleData, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override { return nullptr; } - GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override { - return nullptr; - } void *lockResourceImpl(GraphicsAllocation &gfxAllocation) override { return nullptr; }; void unlockResourceImpl(GraphicsAllocation &gfxAllocation) override{}; diff --git a/shared/test/common/mocks/mock_wddm.cpp b/shared/test/common/mocks/mock_wddm.cpp index f24170a5ea..4766139fc3 100644 --- a/shared/test/common/mocks/mock_wddm.cpp +++ b/shared/test/common/mocks/mock_wddm.cpp @@ -161,7 +161,7 @@ bool WddmMock::destroyAllocation(WddmAllocation *alloc, OsContextWin *osContext) return success; } -bool WddmMock::openSharedHandle(const MemoryManager::ExtendedOsHandleData &osHandleData, WddmAllocation *alloc) { +bool WddmMock::openSharedHandle(const MemoryManager::OsHandleData &osHandleData, WddmAllocation *alloc) { if (failOpenSharedHandle) { return false; } else { diff --git a/shared/test/common/mocks/mock_wddm.h b/shared/test/common/mocks/mock_wddm.h index cfa0815870..4f06486605 100644 --- a/shared/test/common/mocks/mock_wddm.h +++ b/shared/test/common/mocks/mock_wddm.h @@ -77,7 +77,7 @@ class WddmMock : public Wddm { NTSTATUS createAllocation(WddmAllocation *wddmAllocation); bool createAllocation64k(WddmAllocation *wddmAllocation); bool destroyAllocation(WddmAllocation *alloc, OsContextWin *osContext); - bool openSharedHandle(const MemoryManager::ExtendedOsHandleData &osHandleData, WddmAllocation *alloc) override; + bool openSharedHandle(const MemoryManager::OsHandleData &osHandleData, WddmAllocation *alloc) override; bool createContext(OsContextWin &osContext) override; void applyAdditionalContextFlags(CREATECONTEXT_PVTDATA &privateData, OsContextWin &osContext) override; bool destroyContext(D3DKMT_HANDLE context) override; diff --git a/shared/test/unit_test/device/neo_device_tests.cpp b/shared/test/unit_test/device/neo_device_tests.cpp index 9e66fa5757..d2593363f7 100644 --- a/shared/test/unit_test/device/neo_device_tests.cpp +++ b/shared/test/unit_test/device/neo_device_tests.cpp @@ -509,7 +509,6 @@ TEST_F(DeviceGetCapsTest, givenFlagEnabled64kbPagesWhenCallConstructorMemoryMana void removeAllocationFromHostPtrManager(GraphicsAllocation *memory) override{}; GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override { return nullptr; } GraphicsAllocation *createGraphicsAllocationFromSharedHandle(const OsHandleData &osHandleData, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override { return nullptr; }; - GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override { return nullptr; }; AllocationStatus populateOsHandles(OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override { return AllocationStatus::Success; }; void cleanOsHandles(OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override{}; void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override{}; diff --git a/shared/test/unit_test/memory_manager/memory_manager_tests.cpp b/shared/test/unit_test/memory_manager/memory_manager_tests.cpp index ac0496a228..9df23e3ad0 100644 --- a/shared/test/unit_test/memory_manager/memory_manager_tests.cpp +++ b/shared/test/unit_test/memory_manager/memory_manager_tests.cpp @@ -1358,14 +1358,6 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenCreateGraphicsAllocat memoryManager.freeGraphicsMemory(sharedAllocation); } -TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenCreateAllocationFromNtHandleIsCalledThenReturnNullptr) { - MockExecutionEnvironment executionEnvironment(defaultHwInfo.get()); - OsAgnosticMemoryManager memoryManager(executionEnvironment); - OsAgnosticMemoryManager::ExtendedOsHandleData osHandleData{(void *)1}; - auto graphicsAllocation = memoryManager.createGraphicsAllocationFromNTHandle(osHandleData, 0, AllocationType::sharedImage); - EXPECT_EQ(nullptr, graphicsAllocation); -} - TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenLockUnlockCalledThenReturnCpuPtr) { MockExecutionEnvironment executionEnvironment(defaultHwInfo.get()); OsAgnosticMemoryManager memoryManager(executionEnvironment); diff --git a/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp index 8eaab68d1e..c402253226 100644 --- a/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp @@ -2304,12 +2304,6 @@ TEST_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatDoesnShareTheSameBuf memoryManager->freeGraphicsMemory(graphicsAllocation2); } -TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDrmMemoryManagerWhenCreateAllocationFromNtHandleIsCalledThenReturnNullptr) { - TestedDrmMemoryManager::ExtendedOsHandleData osHandleData{1u}; - auto graphicsAllocation = memoryManager->createGraphicsAllocationFromNTHandle(osHandleData, 0, AllocationType::sharedImage); - EXPECT_EQ(nullptr, graphicsAllocation); -} - TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenLockUnlockIsCalledThenReturnPtr) { mock->ioctlExpected.gemUserptr = 1; mock->ioctlExpected.gemSetDomain = 1; diff --git a/shared/test/unit_test/os_interface/windows/wddm20_tests.cpp b/shared/test/unit_test/os_interface/windows/wddm20_tests.cpp index 31e3c2bc74..bd458fd203 100644 --- a/shared/test/unit_test/os_interface/windows/wddm20_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/wddm20_tests.cpp @@ -522,7 +522,7 @@ TEST_F(Wddm20WithMockGdiDllTests, givenSharedHandlesWhenCreateGraphicsAllocation AllocationProperties properties(0, false, 4096u, AllocationType::sharedImage, false, {}); for (uint32_t i = 0; i < 3; i++) { - WddmMemoryManager::ExtendedOsHandleData osHandleData{ALLOCATION_HANDLE, i}; + WddmMemoryManager::OsHandleData osHandleData{ALLOCATION_HANDLE, i}; auto graphicsAllocation = mm.createGraphicsAllocationFromSharedHandle(osHandleData, properties, false, false, true, nullptr); auto wddmAllocation = (WddmAllocation *)graphicsAllocation; @@ -970,7 +970,7 @@ NTSTATUS APIENTRY queryResourceInfoMock(D3DKMT_QUERYRESOURCEINFO *pData) { } TEST_F(Wddm20Tests, givenOpenSharedHandleWhenZeroAllocationsThenReturnNull) { - MockMemoryManager::ExtendedOsHandleData osHandleData{static_cast(0ull)}; + MockMemoryManager::OsHandleData osHandleData{static_cast(0ull)}; WddmAllocation *alloc = nullptr; gdi->queryResourceInfo = reinterpret_cast(queryResourceInfoMock); diff --git a/shared/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp b/shared/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp index ece5721d67..273b647372 100644 --- a/shared/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp @@ -972,7 +972,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenSharedHandleWhenCreateGraphicsAllocatio TEST_F(WddmMemoryManagerSimpleTest, givenAllocationPropertiesWhenCreateAllocationFromHandleIsCalledThenCorrectAllocationTypeIsSet) { memoryManager.reset(new MockWddmMemoryManager(false, false, executionEnvironment)); - MockMemoryManager::ExtendedOsHandleData osHandleData{1u}; + MockMemoryManager::OsHandleData osHandleData{1u}; gdi->getQueryResourceInfoArgOut().NumAllocations = 1; GmmRequirements gmmRequirements{}; gmmRequirements.allowLargePages = true; @@ -2626,7 +2626,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromSharedHandleIs memoryManager->freeGraphicsMemory(gpuAllocation); } -TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromNTHandleIsCalledThenNonNullGraphicsAllocationsAreReturned) { +TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromSharedHandleIsCalledThenNonNullGraphicsAllocationsAreReturned) { void *pSysMem = reinterpret_cast(0x1000); GmmRequirements gmmRequirements{}; gmmRequirements.allowLargePages = true; @@ -2637,8 +2637,9 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromNTHandleIsCall setSizesFcn(gmmPtrArray, 2u, 1024u, 1u); for (uint32_t i = 0; i < 3; i++) { - MockWddmMemoryManager::ExtendedOsHandleData osHandleData{1u, i}; - auto *gpuAllocation = memoryManager->createGraphicsAllocationFromNTHandle(osHandleData, 0, AllocationType::sharedImage); + MockWddmMemoryManager::OsHandleData osHandleData{NT_ALLOCATION_HANDLE, i}; + AllocationProperties properties(0, false, 0u, AllocationType::sharedImage, false, 0); + auto *gpuAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(osHandleData, properties, false, false, false, nullptr); auto wddmAlloc = static_cast(gpuAllocation); ASSERT_NE(nullptr, gpuAllocation); EXPECT_EQ(NT_RESOURCE_HANDLE, wddmAlloc->getResourceHandle()); @@ -2654,7 +2655,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromNTHandleIsCall } } -TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromNTHandleIsCalledWithUmKmDataTranslatorEnabledThenNonNullGraphicsAllocationIsReturned) { +TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromSharedHandleIsCalledWithUmKmDataTranslatorEnabledThenNonNullGraphicsAllocationIsReturned) { struct MockUmKmDataTranslator : UmKmDataTranslator { using UmKmDataTranslator::isEnabled; }; @@ -2676,8 +2677,9 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromNTHandleIsCall void *gmmPtrArray[]{gmm->gmmResourceInfo.get()}; setSizesFcn(gmmPtrArray, 1u, 1024u, 1u); - MockWddmMemoryManager::ExtendedOsHandleData osHandleData{1u}; - auto *gpuAllocation = memoryManager->createGraphicsAllocationFromNTHandle(osHandleData, 0, AllocationType::sharedImage); + MockWddmMemoryManager::OsHandleData osHandleData{NT_ALLOCATION_HANDLE}; + AllocationProperties properties(0, false, 0u, AllocationType::sharedImage, false, 0); + auto *gpuAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(osHandleData, properties, false, false, false, nullptr); auto wddmAlloc = static_cast(gpuAllocation); ASSERT_NE(nullptr, gpuAllocation); EXPECT_EQ(NT_RESOURCE_HANDLE, wddmAlloc->getResourceHandle());