|
16 | 16 | #include "shared/source/memory_manager/memory_manager.h" |
17 | 17 | #include "shared/source/utilities/compiler_support.h" |
18 | 18 |
|
19 | | -#include "level_zero/core/source/helpers/properties_parser.h" |
20 | 19 | #include "level_zero/core/source/image/image_formats.h" |
21 | 20 | #include "level_zero/core/source/image/image_hw.h" |
22 | 21 |
|
23 | 22 | namespace L0 { |
24 | | - |
25 | 23 | template <GFXCORE_FAMILY gfxCoreFamily> |
26 | 24 | ze_result_t ImageCoreFamily<gfxCoreFamily>::initialize(Device *device, const ze_image_desc_t *desc) { |
27 | 25 | using RENDER_SURFACE_STATE = typename GfxFamily::RENDER_SURFACE_STATE; |
28 | 26 |
|
29 | | - StructuresLookupTable lookupTable = {}; |
30 | | - auto parseResult = prepareL0StructuresLookupTable(lookupTable, desc); |
31 | | - |
32 | | - if (parseResult != ZE_RESULT_SUCCESS) { |
33 | | - return parseResult; |
34 | | - } |
35 | | - |
36 | 27 | bool isMediaFormatLayout = isMediaFormat(desc->format.layout); |
37 | 28 |
|
38 | | - imgInfo.imgDesc = lookupTable.imageProperties.imageDescriptor; |
| 29 | + auto imageDescriptor = convertDescriptor(*desc); |
| 30 | + imgInfo.imgDesc = imageDescriptor; |
39 | 31 |
|
40 | 32 | imgInfo.surfaceFormat = &ImageFormats::formats[desc->format.layout][desc->format.type]; |
41 | 33 | imageFormatDesc = *const_cast<ze_image_desc_t *>(desc); |
@@ -65,36 +57,34 @@ ze_result_t ImageCoreFamily<gfxCoreFamily>::initialize(Device *device, const ze_ |
65 | 57 | } |
66 | 58 |
|
67 | 59 | imgInfo.linearStorage = surfaceType == RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_1D; |
68 | | - imgInfo.plane = isImageView ? static_cast<GMM_YUV_PLANE>(lookupTable.imageProperties.planeIndex + 1u) : GMM_NO_PLANE; |
| 60 | + imgInfo.plane = GMM_NO_PLANE; |
69 | 61 | imgInfo.useLocalMemory = false; |
70 | 62 | imgInfo.preferRenderCompression = false; |
71 | 63 |
|
72 | | - if (!isImageView) { |
73 | | - if (lookupTable.isSharedHandle) { |
74 | | - if (!lookupTable.sharedHandleType.isSupportedHandle) { |
| 64 | + if (desc->pNext) { |
| 65 | + const ze_base_desc_t *extendedDesc = reinterpret_cast<const ze_base_desc_t *>(desc->pNext); |
| 66 | + if (extendedDesc->stype == ZE_STRUCTURE_TYPE_EXTERNAL_MEMORY_EXPORT_DESC) { |
| 67 | + return ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION; |
| 68 | + } else if (extendedDesc->stype == ZE_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMPORT_FD) { |
| 69 | + const ze_external_memory_import_fd_t *externalMemoryImportDesc = |
| 70 | + reinterpret_cast<const ze_external_memory_import_fd_t *>(extendedDesc); |
| 71 | + if (externalMemoryImportDesc->flags & ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_FD) { |
75 | 72 | return ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION; |
76 | 73 | } |
77 | | - if (lookupTable.sharedHandleType.isDMABUFHandle) { |
78 | | - NEO::AllocationProperties properties(device->getRootDeviceIndex(), true, imgInfo, NEO::GraphicsAllocation::AllocationType::SHARED_IMAGE, device->getNEODevice()->getDeviceBitfield()); |
79 | | - allocation = device->getNEODevice()->getMemoryManager()->createGraphicsAllocationFromSharedHandle(lookupTable.sharedHandleType.fd, properties, false, false); |
80 | | - device->getNEODevice()->getMemoryManager()->closeSharedHandle(allocation); |
81 | | - } else if (lookupTable.sharedHandleType.isNTHandle) { |
82 | | - auto verifyResult = device->getNEODevice()->getMemoryManager()->verifyHandle(NEO::toOsHandle(lookupTable.sharedHandleType.ntHnadle), device->getNEODevice()->getRootDeviceIndex(), true); |
83 | | - if (!verifyResult) { |
84 | | - return ZE_RESULT_ERROR_INVALID_ARGUMENT; |
85 | | - } |
86 | | - allocation = device->getNEODevice()->getMemoryManager()->createGraphicsAllocationFromNTHandle(lookupTable.sharedHandleType.ntHnadle, device->getNEODevice()->getRootDeviceIndex()); |
87 | | - } |
88 | | - } else { |
89 | | - NEO::AllocationProperties properties(device->getRootDeviceIndex(), true, imgInfo, NEO::GraphicsAllocation::AllocationType::IMAGE, device->getNEODevice()->getDeviceBitfield()); |
90 | 74 |
|
91 | | - allocation = device->getNEODevice()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties); |
92 | | - } |
93 | | - if (allocation == nullptr) { |
94 | | - return ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY; |
| 75 | + NEO::AllocationProperties properties(device->getRootDeviceIndex(), true, imgInfo, NEO::GraphicsAllocation::AllocationType::SHARED_IMAGE, device->getNEODevice()->getDeviceBitfield()); |
| 76 | + |
| 77 | + allocation = device->getNEODevice()->getMemoryManager()->createGraphicsAllocationFromSharedHandle(externalMemoryImportDesc->fd, properties, false, false); |
| 78 | + device->getNEODevice()->getMemoryManager()->closeSharedHandle(allocation); |
| 79 | + } else { |
| 80 | + return ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION; |
95 | 81 | } |
96 | | - } |
| 82 | + } else { |
| 83 | + NEO::AllocationProperties properties(device->getRootDeviceIndex(), true, imgInfo, NEO::GraphicsAllocation::AllocationType::IMAGE, device->getNEODevice()->getDeviceBitfield()); |
97 | 84 |
|
| 85 | + allocation = device->getNEODevice()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties); |
| 86 | + } |
| 87 | + UNRECOVERABLE_IF(allocation == nullptr); |
98 | 88 | auto gmm = this->allocation->getDefaultGmm(); |
99 | 89 | auto gmmHelper = static_cast<const NEO::RootDeviceEnvironment &>(device->getNEODevice()->getRootDeviceEnvironment()).getGmmHelper(); |
100 | 90 |
|
|
0 commit comments