mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-25 21:42:53 +08:00
feature: Add support for d3d12 handle types for import
Related-To: NEO-11292 Signed-off-by: Aravind Gopalakrishnan <aravind.gopalakrishnan@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
d97ef9848b
commit
510a51b9f4
@@ -30,9 +30,13 @@ uint32_t DeviceImp::queryDeviceNodeMask() {
|
||||
|
||||
ze_result_t DeviceImp::getExternalMemoryProperties(ze_device_external_memory_properties_t *pExternalMemoryProperties) {
|
||||
pExternalMemoryProperties->imageExportTypes = ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32;
|
||||
pExternalMemoryProperties->imageImportTypes = ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32;
|
||||
pExternalMemoryProperties->imageImportTypes = ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32 |
|
||||
ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D12_HEAP |
|
||||
ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D12_RESOURCE;
|
||||
pExternalMemoryProperties->memoryAllocationExportTypes = ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32;
|
||||
pExternalMemoryProperties->memoryAllocationImportTypes = ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32;
|
||||
pExternalMemoryProperties->memoryAllocationImportTypes = ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32 |
|
||||
ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D12_HEAP |
|
||||
ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D12_RESOURCE;
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,9 @@ inline ze_result_t prepareL0StructuresLookupTable(StructuresLookupTable &lookupT
|
||||
} else if (extendedDesc->stype == ZE_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMPORT_WIN32) {
|
||||
lookupTable.isSharedHandle = true;
|
||||
const ze_external_memory_import_win32_handle_t *windowsExternalMemoryImportDesc = reinterpret_cast<const ze_external_memory_import_win32_handle_t *>(extendedDesc);
|
||||
if (windowsExternalMemoryImportDesc->flags == ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32) {
|
||||
if ((windowsExternalMemoryImportDesc->flags == ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32) ||
|
||||
(windowsExternalMemoryImportDesc->flags == ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D12_HEAP) ||
|
||||
(windowsExternalMemoryImportDesc->flags == ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D12_RESOURCE)) {
|
||||
lookupTable.sharedHandleType.isSupportedHandle = true;
|
||||
lookupTable.sharedHandleType.isNTHandle = true;
|
||||
lookupTable.sharedHandleType.ntHnadle = windowsExternalMemoryImportDesc->handle;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Intel Corporation
|
||||
* Copyright (C) 2023-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -52,10 +52,14 @@ TEST_F(DeviceExtensionTest, whenGetExternalMemoryPropertiesIsCalledThenSuccessIs
|
||||
EXPECT_TRUE(externalMemoryProperties.imageExportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32);
|
||||
EXPECT_FALSE(externalMemoryProperties.imageExportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_DMA_BUF);
|
||||
EXPECT_TRUE(externalMemoryProperties.imageImportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32);
|
||||
EXPECT_TRUE(externalMemoryProperties.imageImportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D12_HEAP);
|
||||
EXPECT_TRUE(externalMemoryProperties.imageImportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D12_RESOURCE);
|
||||
EXPECT_FALSE(externalMemoryProperties.imageImportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_DMA_BUF);
|
||||
EXPECT_TRUE(externalMemoryProperties.memoryAllocationExportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32);
|
||||
EXPECT_FALSE(externalMemoryProperties.memoryAllocationExportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_DMA_BUF);
|
||||
EXPECT_TRUE(externalMemoryProperties.memoryAllocationImportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32);
|
||||
EXPECT_TRUE(externalMemoryProperties.memoryAllocationImportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D12_HEAP);
|
||||
EXPECT_TRUE(externalMemoryProperties.memoryAllocationImportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D12_RESOURCE);
|
||||
EXPECT_FALSE(externalMemoryProperties.memoryAllocationImportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_DMA_BUF);
|
||||
}
|
||||
} // namespace ult
|
||||
|
||||
@@ -500,25 +500,36 @@ class MemoryManagerNTHandleMock : public NEO::OsAgnosticMemoryManager {
|
||||
}
|
||||
};
|
||||
|
||||
HWTEST2_F(ImageCreate, givenNTHandleWhenCreatingImageThenSuccessIsReturned, IsAtLeastSkl) {
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
class ImageCreateExternalMemory : public DeviceFixture, public testing::Test {
|
||||
public:
|
||||
void SetUp() override {
|
||||
DeviceFixture::setUp();
|
||||
|
||||
desc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
|
||||
desc.type = ZE_IMAGE_TYPE_3D;
|
||||
desc.format.layout = ZE_IMAGE_FORMAT_LAYOUT_8_8_8_8;
|
||||
desc.format.type = ZE_IMAGE_FORMAT_TYPE_UINT;
|
||||
desc.width = 11;
|
||||
desc.height = 13;
|
||||
desc.depth = 17;
|
||||
|
||||
desc.format.x = ZE_IMAGE_FORMAT_SWIZZLE_A;
|
||||
desc.format.y = ZE_IMAGE_FORMAT_SWIZZLE_0;
|
||||
desc.format.z = ZE_IMAGE_FORMAT_SWIZZLE_1;
|
||||
desc.format.w = ZE_IMAGE_FORMAT_SWIZZLE_X;
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
DeviceFixture::tearDown();
|
||||
}
|
||||
|
||||
ze_image_desc_t desc = {};
|
||||
|
||||
desc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
|
||||
desc.type = ZE_IMAGE_TYPE_3D;
|
||||
desc.format.layout = ZE_IMAGE_FORMAT_LAYOUT_8_8_8_8;
|
||||
desc.format.type = ZE_IMAGE_FORMAT_TYPE_UINT;
|
||||
desc.width = 11;
|
||||
desc.height = 13;
|
||||
desc.depth = 17;
|
||||
|
||||
desc.format.x = ZE_IMAGE_FORMAT_SWIZZLE_A;
|
||||
desc.format.y = ZE_IMAGE_FORMAT_SWIZZLE_0;
|
||||
desc.format.z = ZE_IMAGE_FORMAT_SWIZZLE_1;
|
||||
desc.format.w = ZE_IMAGE_FORMAT_SWIZZLE_X;
|
||||
|
||||
uint64_t imageHandle = 0x1;
|
||||
};
|
||||
|
||||
HWTEST2_F(ImageCreateExternalMemory, givenNTHandleWhenCreatingImageThenSuccessIsReturned, IsAtLeastSkl) {
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
|
||||
ze_external_memory_import_win32_handle_t importNTHandle = {};
|
||||
importNTHandle.handle = &imageHandle;
|
||||
importNTHandle.flags = ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32;
|
||||
@@ -538,6 +549,50 @@ HWTEST2_F(ImageCreate, givenNTHandleWhenCreatingImageThenSuccessIsReturned, IsAt
|
||||
imageHW.reset(nullptr);
|
||||
}
|
||||
|
||||
HWTEST2_F(ImageCreateExternalMemory, givenD3D12HeapHandleWhenCreatingImageThenSuccessIsReturned, IsAtLeastSkl) {
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
|
||||
ze_external_memory_import_win32_handle_t importNTHandle = {};
|
||||
importNTHandle.handle = &imageHandle;
|
||||
importNTHandle.flags = ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D12_HEAP;
|
||||
importNTHandle.stype = ZE_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMPORT_WIN32;
|
||||
desc.pNext = &importNTHandle;
|
||||
|
||||
delete driverHandle->svmAllocsManager;
|
||||
execEnv->memoryManager.reset(new MemoryManagerNTHandleMock(*execEnv));
|
||||
driverHandle->setMemoryManager(execEnv->memoryManager.get());
|
||||
driverHandle->svmAllocsManager = new NEO::SVMAllocsManager(execEnv->memoryManager.get(), false);
|
||||
|
||||
auto imageHW = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
|
||||
auto ret = imageHW->initialize(device, &desc);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, ret);
|
||||
ASSERT_EQ(imageHW->getAllocation()->peekSharedHandle(), NEO::toOsHandle(importNTHandle.handle));
|
||||
|
||||
imageHW.reset(nullptr);
|
||||
}
|
||||
|
||||
HWTEST2_F(ImageCreateExternalMemory, givenD3D12ResourceHandleWhenCreatingImageThenSuccessIsReturned, IsAtLeastSkl) {
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
|
||||
ze_external_memory_import_win32_handle_t importNTHandle = {};
|
||||
importNTHandle.handle = &imageHandle;
|
||||
importNTHandle.flags = ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D12_RESOURCE;
|
||||
importNTHandle.stype = ZE_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMPORT_WIN32;
|
||||
desc.pNext = &importNTHandle;
|
||||
|
||||
delete driverHandle->svmAllocsManager;
|
||||
execEnv->memoryManager.reset(new MemoryManagerNTHandleMock(*execEnv));
|
||||
driverHandle->setMemoryManager(execEnv->memoryManager.get());
|
||||
driverHandle->svmAllocsManager = new NEO::SVMAllocsManager(execEnv->memoryManager.get(), false);
|
||||
|
||||
auto imageHW = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
|
||||
auto ret = imageHW->initialize(device, &desc);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, ret);
|
||||
ASSERT_EQ(imageHW->getAllocation()->peekSharedHandle(), NEO::toOsHandle(importNTHandle.handle));
|
||||
|
||||
imageHW.reset(nullptr);
|
||||
}
|
||||
|
||||
HWTEST2_F(ImageCreate, givenNTHandleWhenCreatingNV12ImageThenSuccessIsReturnedAndUVOffsetIsSet, IsAtLeastSkl) {
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
constexpr uint32_t yOffsetForUVPlane = 8u; // mock sets reqOffsetInfo.Lock.Offset to 16 and reqOffsetInfo.Lock.Pitch to 2
|
||||
|
||||
Reference in New Issue
Block a user