Skip to content

Commit 642bdd1

Browse files
feature: Add support for d3d11 texture handle types for import and export
Related-To: NEO-14329 Signed-off-by: Aravind Gopalakrishnan <[email protected]>
1 parent be8545f commit 642bdd1

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

level_zero/core/source/device/device_imp_wddm/device_imp_wddm.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2022-2024 Intel Corporation
2+
* Copyright (C) 2022-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -32,7 +32,8 @@ ze_result_t DeviceImp::getExternalMemoryProperties(ze_device_external_memory_pro
3232
pExternalMemoryProperties->imageExportTypes = ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32;
3333
pExternalMemoryProperties->imageImportTypes = ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32 |
3434
ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D12_HEAP |
35-
ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D12_RESOURCE;
35+
ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D12_RESOURCE |
36+
ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D11_TEXTURE;
3637
pExternalMemoryProperties->memoryAllocationExportTypes = ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32;
3738
pExternalMemoryProperties->memoryAllocationImportTypes = ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32 |
3839
ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D12_HEAP |

level_zero/core/source/helpers/properties_parser.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2021-2024 Intel Corporation
2+
* Copyright (C) 2021-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -109,7 +109,8 @@ inline ze_result_t prepareL0StructuresLookupTable(StructuresLookupTable &lookupT
109109
const ze_external_memory_import_win32_handle_t *windowsExternalMemoryImportDesc = reinterpret_cast<const ze_external_memory_import_win32_handle_t *>(extendedDesc);
110110
if ((windowsExternalMemoryImportDesc->flags == ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32) ||
111111
(windowsExternalMemoryImportDesc->flags == ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D12_HEAP) ||
112-
(windowsExternalMemoryImportDesc->flags == ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D12_RESOURCE)) {
112+
(windowsExternalMemoryImportDesc->flags == ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D12_RESOURCE) ||
113+
(windowsExternalMemoryImportDesc->flags == ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D11_TEXTURE)) {
113114
lookupTable.sharedHandleType.isSupportedHandle = true;
114115
lookupTable.sharedHandleType.isNTHandle = true;
115116
lookupTable.sharedHandleType.ntHandle = windowsExternalMemoryImportDesc->handle;

level_zero/core/test/unit_tests/sources/device/device_wddm/test_device_exensions.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2023-2024 Intel Corporation
2+
* Copyright (C) 2023-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -57,6 +57,7 @@ TEST_F(DeviceExtensionTest, whenGetExternalMemoryPropertiesIsCalledThenSuccessIs
5757
EXPECT_TRUE(externalMemoryProperties.imageImportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32);
5858
EXPECT_TRUE(externalMemoryProperties.imageImportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D12_HEAP);
5959
EXPECT_TRUE(externalMemoryProperties.imageImportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D12_RESOURCE);
60+
EXPECT_TRUE(externalMemoryProperties.imageImportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D11_TEXTURE);
6061
EXPECT_FALSE(externalMemoryProperties.imageImportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_DMA_BUF);
6162
EXPECT_TRUE(externalMemoryProperties.memoryAllocationExportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32);
6263
EXPECT_FALSE(externalMemoryProperties.memoryAllocationExportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_DMA_BUF);

level_zero/core/test/unit_tests/sources/image/test_image.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,25 @@ HWTEST2_F(ImageCreateExternalMemoryTest, givenD3D12ResourceHandleWhenCreatingIma
733733
imageHW.reset(nullptr);
734734
}
735735

736+
HWTEST2_F(ImageCreateExternalMemoryTest, givenD3D11TextureHandleWhenCreatingImageThenSuccessIsReturned, MatchAny) {
737+
ze_external_memory_import_win32_handle_t importNTHandle = {};
738+
importNTHandle.handle = &imageHandle;
739+
importNTHandle.flags = ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D11_TEXTURE;
740+
importNTHandle.stype = ZE_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMPORT_WIN32;
741+
desc.pNext = &importNTHandle;
742+
743+
delete driverHandle->svmAllocsManager;
744+
driverHandle->setMemoryManager(execEnv->memoryManager.get());
745+
driverHandle->svmAllocsManager = new NEO::SVMAllocsManager(execEnv->memoryManager.get(), false);
746+
747+
auto imageHW = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
748+
auto ret = imageHW->initialize(device, &desc);
749+
ASSERT_EQ(ZE_RESULT_SUCCESS, ret);
750+
ASSERT_EQ(imageHW->getAllocation()->peekSharedHandle(), NEO::toOsHandle(importNTHandle.handle));
751+
752+
imageHW.reset(nullptr);
753+
}
754+
736755
using ImageCreateWithMemoryManagerNTHandleMock = Test<DeviceFixtureWithCustomMemoryManager<MemoryManagerNTHandleMock>>;
737756

738757
HWTEST2_F(ImageCreateWithMemoryManagerNTHandleMock, givenNTHandleWhenCreatingNV12ImageThenSuccessIsReturnedAndUVOffsetIsSet, MatchAny) {

0 commit comments

Comments
 (0)