mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-19 16:24:18 +08:00
Extended import device memory
Signed-off-by: Kamil Diedrich <kamil.diedrich@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
fc4a1d608d
commit
d5fdb949eb
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "level_zero/core/source/device/device_imp.h"
|
#include "level_zero/core/source/device/device_imp.h"
|
||||||
#include "level_zero/core/source/driver/driver_handle_imp.h"
|
#include "level_zero/core/source/driver/driver_handle_imp.h"
|
||||||
|
#include "level_zero/core/source/helpers/properties_parser.h"
|
||||||
#include "level_zero/core/source/image/image.h"
|
#include "level_zero/core/source/image/image.h"
|
||||||
#include "level_zero/core/source/memory/memory_operations_helper.h"
|
#include "level_zero/core/source/memory/memory_operations_helper.h"
|
||||||
|
|
||||||
@@ -102,50 +103,12 @@ ze_result_t ContextImp::allocDeviceMem(ze_device_handle_t hDevice,
|
|||||||
return ZE_RESULT_ERROR_DEVICE_LOST;
|
return ZE_RESULT_ERROR_DEVICE_LOST;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool relaxedSizeAllowed = false;
|
StructuresLookupTable lookupTable = {};
|
||||||
if (deviceDesc->pNext) {
|
|
||||||
const ze_base_desc_t *extendedDesc = reinterpret_cast<const ze_base_desc_t *>(deviceDesc->pNext);
|
|
||||||
if (extendedDesc->stype == ZE_STRUCTURE_TYPE_EXTERNAL_MEMORY_EXPORT_DESC) {
|
|
||||||
const ze_external_memory_export_desc_t *externalMemoryExportDesc =
|
|
||||||
reinterpret_cast<const ze_external_memory_export_desc_t *>(extendedDesc);
|
|
||||||
// ZE_EXTERNAL_MEMORY_TYPE_FLAG_DMA_BUF supported by default for all
|
|
||||||
// device allocations for the purpose of IPC, so just check correct
|
|
||||||
// flag is passed.
|
|
||||||
if (externalMemoryExportDesc->flags & ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_FD) {
|
|
||||||
return ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
|
|
||||||
}
|
|
||||||
} else if (extendedDesc->stype == ZE_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMPORT_FD) {
|
|
||||||
const ze_external_memory_import_fd_t *externalMemoryImportDesc =
|
|
||||||
reinterpret_cast<const ze_external_memory_import_fd_t *>(extendedDesc);
|
|
||||||
if (externalMemoryImportDesc->flags & ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_FD) {
|
|
||||||
return ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
|
|
||||||
}
|
|
||||||
ze_ipc_memory_flags_t flags = {};
|
|
||||||
*ptr = this->driverHandle->importFdHandle(hDevice, flags, externalMemoryImportDesc->fd, nullptr);
|
|
||||||
if (nullptr == *ptr) {
|
|
||||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
|
||||||
}
|
|
||||||
return ZE_RESULT_SUCCESS;
|
|
||||||
} else if (extendedDesc->stype == ZE_STRUCTURE_TYPE_RELAXED_ALLOCATION_LIMITS_EXP_DESC) {
|
|
||||||
const ze_relaxed_allocation_limits_exp_desc_t *relaxedLimitsDesc =
|
|
||||||
reinterpret_cast<const ze_relaxed_allocation_limits_exp_desc_t *>(extendedDesc);
|
|
||||||
if (!(relaxedLimitsDesc->flags & ZE_RELAXED_ALLOCATION_LIMITS_EXP_FLAG_MAX_SIZE)) {
|
|
||||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
|
||||||
}
|
|
||||||
relaxedSizeAllowed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (relaxedSizeAllowed == false &&
|
auto parseResult = prepareL0StructuresLookupTable(lookupTable, deviceDesc->pNext);
|
||||||
(size > this->driverHandle->devices[0]->getNEODevice()->getDeviceInfo().maxMemAllocSize)) {
|
|
||||||
*ptr = nullptr;
|
|
||||||
return ZE_RESULT_ERROR_UNSUPPORTED_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (relaxedSizeAllowed &&
|
if (parseResult != ZE_RESULT_SUCCESS) {
|
||||||
(size > this->driverHandle->devices[0]->getNEODevice()->getDeviceInfo().globalMemSize)) {
|
return parseResult;
|
||||||
*ptr = nullptr;
|
|
||||||
return ZE_RESULT_ERROR_UNSUPPORTED_SIZE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto neoDevice = Device::fromHandle(hDevice)->getNEODevice();
|
auto neoDevice = Device::fromHandle(hDevice)->getNEODevice();
|
||||||
@@ -154,8 +117,39 @@ ze_result_t ContextImp::allocDeviceMem(ze_device_handle_t hDevice,
|
|||||||
|
|
||||||
deviceBitfields[rootDeviceIndex] = neoDevice->getDeviceBitfield();
|
deviceBitfields[rootDeviceIndex] = neoDevice->getDeviceBitfield();
|
||||||
|
|
||||||
|
if (lookupTable.isSharedHandle) {
|
||||||
|
if (lookupTable.sharedHandleType.isDMABUFHandle) {
|
||||||
|
ze_ipc_memory_flags_t flags = {};
|
||||||
|
*ptr = this->driverHandle->importFdHandle(hDevice, flags, lookupTable.sharedHandleType.fd, nullptr);
|
||||||
|
if (nullptr == *ptr) {
|
||||||
|
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
UNRECOVERABLE_IF(!lookupTable.sharedHandleType.isNTHandle);
|
||||||
|
*ptr = this->driverHandle->importNTHandle(hDevice, lookupTable.sharedHandleType.ntHnadle);
|
||||||
|
if (*ptr == nullptr) {
|
||||||
|
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ZE_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lookupTable.relaxedSizeAllowed == false &&
|
||||||
|
(size > this->driverHandle->devices[0]->getNEODevice()->getDeviceInfo().maxMemAllocSize)) {
|
||||||
|
*ptr = nullptr;
|
||||||
|
return ZE_RESULT_ERROR_UNSUPPORTED_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lookupTable.relaxedSizeAllowed &&
|
||||||
|
(size > this->driverHandle->devices[0]->getNEODevice()->getDeviceInfo().globalMemSize)) {
|
||||||
|
*ptr = nullptr;
|
||||||
|
return ZE_RESULT_ERROR_UNSUPPORTED_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
deviceBitfields[rootDeviceIndex] = neoDevice->getDeviceBitfield();
|
||||||
|
|
||||||
NEO::SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY, this->driverHandle->rootDeviceIndices, deviceBitfields);
|
NEO::SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY, this->driverHandle->rootDeviceIndices, deviceBitfields);
|
||||||
unifiedMemoryProperties.allocationFlags.flags.shareable = 1u;
|
unifiedMemoryProperties.allocationFlags.flags.shareable = lookupTable.exportMemory;
|
||||||
unifiedMemoryProperties.device = neoDevice;
|
unifiedMemoryProperties.device = neoDevice;
|
||||||
|
|
||||||
if (deviceDesc->flags & ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_UNCACHED) {
|
if (deviceDesc->flags & ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_UNCACHED) {
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ struct DriverHandleImp : public DriverHandle {
|
|||||||
NEO::MemoryManager *getMemoryManager() override;
|
NEO::MemoryManager *getMemoryManager() override;
|
||||||
void setMemoryManager(NEO::MemoryManager *memoryManager) override;
|
void setMemoryManager(NEO::MemoryManager *memoryManager) override;
|
||||||
MOCKABLE_VIRTUAL void *importFdHandle(ze_device_handle_t hDevice, ze_ipc_memory_flags_t flags, uint64_t handle, NEO::GraphicsAllocation **pAlloc);
|
MOCKABLE_VIRTUAL void *importFdHandle(ze_device_handle_t hDevice, ze_ipc_memory_flags_t flags, uint64_t handle, NEO::GraphicsAllocation **pAlloc);
|
||||||
|
MOCKABLE_VIRTUAL void *importNTHandle(ze_device_handle_t hDevice, void *handle);
|
||||||
ze_result_t checkMemoryAccessFromDevice(Device *device, const void *ptr) override;
|
ze_result_t checkMemoryAccessFromDevice(Device *device, const void *ptr) override;
|
||||||
NEO::SVMAllocsManager *getSvmAllocsManager() override;
|
NEO::SVMAllocsManager *getSvmAllocsManager() override;
|
||||||
ze_result_t initialize(std::vector<std::unique_ptr<NEO::Device>> neoDevices);
|
ze_result_t initialize(std::vector<std::unique_ptr<NEO::Device>> neoDevices);
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ inline NEO::ImageDescriptor convertDescriptor(const ze_image_desc_t &imageDesc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct StructuresLookupTable {
|
struct StructuresLookupTable {
|
||||||
|
bool exportMemory;
|
||||||
bool isSharedHandle;
|
bool isSharedHandle;
|
||||||
struct SharedHandleType {
|
struct SharedHandleType {
|
||||||
bool isSupportedHandle;
|
bool isSupportedHandle;
|
||||||
@@ -65,6 +66,7 @@ struct StructuresLookupTable {
|
|||||||
uint32_t planeIndex;
|
uint32_t planeIndex;
|
||||||
NEO::ImageDescriptor imageDescriptor;
|
NEO::ImageDescriptor imageDescriptor;
|
||||||
} imageProperties;
|
} imageProperties;
|
||||||
|
bool relaxedSizeAllowed;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline ze_result_t prepareL0StructuresLookupTable(StructuresLookupTable &lookupTable, const void *desc) {
|
inline ze_result_t prepareL0StructuresLookupTable(StructuresLookupTable &lookupTable, const void *desc) {
|
||||||
@@ -101,6 +103,21 @@ inline ze_result_t prepareL0StructuresLookupTable(StructuresLookupTable &lookupT
|
|||||||
lookupTable.areImageProperties = true;
|
lookupTable.areImageProperties = true;
|
||||||
lookupTable.imageProperties.isPlanarExtension = true;
|
lookupTable.imageProperties.isPlanarExtension = true;
|
||||||
lookupTable.imageProperties.planeIndex = imageViewDesc->planeIndex;
|
lookupTable.imageProperties.planeIndex = imageViewDesc->planeIndex;
|
||||||
|
} else if (extendedDesc->stype == ZE_STRUCTURE_TYPE_RELAXED_ALLOCATION_LIMITS_EXP_DESC) {
|
||||||
|
const ze_relaxed_allocation_limits_exp_desc_t *relaxedLimitsDesc =
|
||||||
|
reinterpret_cast<const ze_relaxed_allocation_limits_exp_desc_t *>(extendedDesc);
|
||||||
|
if (!(relaxedLimitsDesc->flags & ZE_RELAXED_ALLOCATION_LIMITS_EXP_FLAG_MAX_SIZE)) {
|
||||||
|
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
lookupTable.relaxedSizeAllowed = true;
|
||||||
|
} else if (extendedDesc->stype == ZE_STRUCTURE_TYPE_EXTERNAL_MEMORY_EXPORT_DESC) {
|
||||||
|
const ze_external_memory_export_desc_t *externalMemoryExportDesc =
|
||||||
|
reinterpret_cast<const ze_external_memory_export_desc_t *>(extendedDesc);
|
||||||
|
if (externalMemoryExportDesc->flags & ZE_EXTERNAL_MEMORY_TYPE_FLAG_DMA_BUF || externalMemoryExportDesc->flags & ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32) {
|
||||||
|
lookupTable.exportMemory = true;
|
||||||
|
} else {
|
||||||
|
return ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
|
return ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
|
||||||
}
|
}
|
||||||
@@ -108,6 +125,10 @@ inline ze_result_t prepareL0StructuresLookupTable(StructuresLookupTable &lookupT
|
|||||||
extendedDesc = reinterpret_cast<const ze_base_desc_t *>(extendedDesc->pNext);
|
extendedDesc = reinterpret_cast<const ze_base_desc_t *>(extendedDesc->pNext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lookupTable.areImageProperties && lookupTable.exportMemory) {
|
||||||
|
return ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
|
||||||
|
}
|
||||||
|
|
||||||
return ZE_RESULT_SUCCESS;
|
return ZE_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
} // namespace L0
|
} // namespace L0
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ ze_result_t ImageCoreFamily<gfxCoreFamily>::initialize(Device *device, const ze_
|
|||||||
if (!verifyResult) {
|
if (!verifyResult) {
|
||||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
allocation = device->getNEODevice()->getMemoryManager()->createGraphicsAllocationFromNTHandle(lookupTable.sharedHandleType.ntHnadle, device->getNEODevice()->getRootDeviceIndex());
|
allocation = device->getNEODevice()->getMemoryManager()->createGraphicsAllocationFromNTHandle(lookupTable.sharedHandleType.ntHnadle, device->getNEODevice()->getRootDeviceIndex(), NEO::GraphicsAllocation::AllocationType::SHARED_IMAGE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
NEO::AllocationProperties properties(device->getRootDeviceIndex(), true, imgInfo, NEO::GraphicsAllocation::AllocationType::IMAGE, device->getNEODevice()->getDeviceBitfield());
|
NEO::AllocationProperties properties(device->getRootDeviceIndex(), true, imgInfo, NEO::GraphicsAllocation::AllocationType::IMAGE, device->getNEODevice()->getDeviceBitfield());
|
||||||
|
|||||||
@@ -55,6 +55,27 @@ void *DriverHandleImp::importFdHandle(ze_device_handle_t hDevice, ze_ipc_memory_
|
|||||||
return reinterpret_cast<void *>(alloc->getGpuAddress());
|
return reinterpret_cast<void *>(alloc->getGpuAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *DriverHandleImp::importNTHandle(ze_device_handle_t hDevice, void *handle) {
|
||||||
|
auto neoDevice = Device::fromHandle(hDevice)->getNEODevice();
|
||||||
|
|
||||||
|
auto alloc = this->getMemoryManager()->createGraphicsAllocationFromNTHandle(handle, neoDevice->getRootDeviceIndex(), NEO::GraphicsAllocation::AllocationType::SHARED_BUFFER);
|
||||||
|
|
||||||
|
if (alloc == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
NEO::SvmAllocationData allocData(neoDevice->getRootDeviceIndex());
|
||||||
|
allocData.gpuAllocations.addAllocation(alloc);
|
||||||
|
allocData.cpuAllocation = nullptr;
|
||||||
|
allocData.size = alloc->getUnderlyingBufferSize();
|
||||||
|
allocData.memoryType = InternalMemoryType::DEVICE_UNIFIED_MEMORY;
|
||||||
|
allocData.device = neoDevice;
|
||||||
|
|
||||||
|
this->getSvmAllocsManager()->insertSVMAlloc(allocData);
|
||||||
|
|
||||||
|
return reinterpret_cast<void *>(alloc->getGpuAddress());
|
||||||
|
}
|
||||||
|
|
||||||
ze_result_t DriverHandleImp::checkMemoryAccessFromDevice(Device *device, const void *ptr) {
|
ze_result_t DriverHandleImp::checkMemoryAccessFromDevice(Device *device, const void *ptr) {
|
||||||
auto allocation = svmAllocsManager->getSVMAlloc(ptr);
|
auto allocation = svmAllocsManager->getSVMAlloc(ptr);
|
||||||
if (allocation == nullptr) {
|
if (allocation == nullptr) {
|
||||||
|
|||||||
@@ -124,6 +124,84 @@ TEST_F(DriverVersionTest, whenCallingGetDriverPropertiesRepeatedlyThenTheSameUui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using ImportNTHandle = Test<DeviceFixture>;
|
||||||
|
|
||||||
|
class MemoryManagerNTHandleMock : public NEO::OsAgnosticMemoryManager {
|
||||||
|
public:
|
||||||
|
MemoryManagerNTHandleMock(NEO::ExecutionEnvironment &executionEnvironment) : NEO::OsAgnosticMemoryManager(executionEnvironment) {}
|
||||||
|
|
||||||
|
NEO::GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, GraphicsAllocation::AllocationType allocType) override {
|
||||||
|
auto graphicsAllocation = createMemoryAllocation(allocType, nullptr, reinterpret_cast<void *>(1), 1,
|
||||||
|
4096u, reinterpret_cast<uint64_t>(handle), MemoryPool::SystemCpuInaccessible,
|
||||||
|
rootDeviceIndex, false, false, false);
|
||||||
|
graphicsAllocation->setSharedHandle(static_cast<osHandle>(reinterpret_cast<uint64_t>(handle)));
|
||||||
|
graphicsAllocation->set32BitAllocation(false);
|
||||||
|
graphicsAllocation->setDefaultGmm(new Gmm(executionEnvironment.rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, 1, 0, false));
|
||||||
|
return graphicsAllocation;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
HWTEST_F(ImportNTHandle, givenNTHandleWhenCreatingDeviceMemoryThenSuccessIsReturned) {
|
||||||
|
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||||
|
|
||||||
|
ze_device_mem_alloc_desc_t devProperties = {};
|
||||||
|
devProperties.stype = ZE_STRUCTURE_TYPE_DEVICE_MEMORY_PROPERTIES;
|
||||||
|
|
||||||
|
uint64_t imageHandle = 0x1;
|
||||||
|
ze_external_memory_import_win32_handle_t importNTHandle = {};
|
||||||
|
importNTHandle.handle = &imageHandle;
|
||||||
|
importNTHandle.flags = ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32;
|
||||||
|
importNTHandle.stype = ZE_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMPORT_WIN32;
|
||||||
|
devProperties.pNext = &importNTHandle;
|
||||||
|
|
||||||
|
NEO::MockDevice *neoDevice = nullptr;
|
||||||
|
neoDevice = NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(NEO::defaultHwInfo.get());
|
||||||
|
NEO::MemoryManager *prevMemoryManager = driverHandle->getMemoryManager();
|
||||||
|
NEO::MemoryManager *currMemoryManager = new MemoryManagerNTHandleMock(*neoDevice->executionEnvironment);
|
||||||
|
driverHandle->setMemoryManager(currMemoryManager);
|
||||||
|
neoDevice->injectMemoryManager(currMemoryManager);
|
||||||
|
|
||||||
|
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||||
|
auto device = L0::Device::create(driverHandle.get(), neoDevice, 0, false, &result);
|
||||||
|
|
||||||
|
context->addDeviceAndSubDevices(device);
|
||||||
|
|
||||||
|
void *ptr;
|
||||||
|
|
||||||
|
result = context->allocDeviceMem(device, &devProperties, 100, 1, &ptr);
|
||||||
|
|
||||||
|
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
|
||||||
|
|
||||||
|
auto alloc = driverHandle->getSvmAllocsManager()->getSVMAlloc(ptr);
|
||||||
|
|
||||||
|
ASSERT_EQ(alloc->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex())->peekSharedHandle(), NEO::toOsHandle(importNTHandle.handle));
|
||||||
|
result = context->freeMem(ptr);
|
||||||
|
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
|
||||||
|
|
||||||
|
driverHandle->setMemoryManager(prevMemoryManager);
|
||||||
|
delete device;
|
||||||
|
}
|
||||||
|
|
||||||
|
HWTEST_F(ImportNTHandle, givenNotExistingNTHandleWhenCreatingDeviceMemoryThenErrorIsReturned) {
|
||||||
|
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||||
|
|
||||||
|
ze_device_mem_alloc_desc_t devProperties = {};
|
||||||
|
devProperties.stype = ZE_STRUCTURE_TYPE_DEVICE_MEMORY_PROPERTIES;
|
||||||
|
|
||||||
|
uint64_t imageHandle = 0x1;
|
||||||
|
ze_external_memory_import_win32_handle_t importNTHandle = {};
|
||||||
|
importNTHandle.handle = &imageHandle;
|
||||||
|
importNTHandle.flags = ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32;
|
||||||
|
importNTHandle.stype = ZE_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMPORT_WIN32;
|
||||||
|
devProperties.pNext = &importNTHandle;
|
||||||
|
|
||||||
|
void *ptr;
|
||||||
|
|
||||||
|
auto result = context->allocDeviceMem(device, &devProperties, 100, 1, &ptr);
|
||||||
|
|
||||||
|
EXPECT_EQ(result, ZE_RESULT_ERROR_INVALID_ARGUMENT);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(DriverTestFamilySupport, whenInitializingDriverOnSupportedFamilyThenDriverIsCreated) {
|
TEST(DriverTestFamilySupport, whenInitializingDriverOnSupportedFamilyThenDriverIsCreated) {
|
||||||
NEO::MockCompilerEnableGuard mock(true);
|
NEO::MockCompilerEnableGuard mock(true);
|
||||||
ze_result_t returnValue;
|
ze_result_t returnValue;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class MemoryManagerEventPoolFailMock : public NEO::MemoryManager {
|
|||||||
NEO::GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation) override { return nullptr; }
|
NEO::GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation) override { return nullptr; }
|
||||||
void addAllocationToHostPtrManager(NEO::GraphicsAllocation *memory) override{};
|
void addAllocationToHostPtrManager(NEO::GraphicsAllocation *memory) override{};
|
||||||
void removeAllocationFromHostPtrManager(NEO::GraphicsAllocation *memory) override{};
|
void removeAllocationFromHostPtrManager(NEO::GraphicsAllocation *memory) override{};
|
||||||
NEO::GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex) override { return nullptr; };
|
NEO::GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, GraphicsAllocation::AllocationType allocType) override { return nullptr; };
|
||||||
AllocationStatus populateOsHandles(NEO::OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override { return AllocationStatus::Success; };
|
AllocationStatus populateOsHandles(NEO::OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override { return AllocationStatus::Success; };
|
||||||
void cleanOsHandles(NEO::OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override{};
|
void cleanOsHandles(NEO::OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override{};
|
||||||
void freeGraphicsMemoryImpl(NEO::GraphicsAllocation *gfxAllocation) override{};
|
void freeGraphicsMemoryImpl(NEO::GraphicsAllocation *gfxAllocation) override{};
|
||||||
|
|||||||
@@ -119,6 +119,67 @@ TEST(L0StructuresLookupTableTests, givenL0StructuresWithNTHandleWhenPrepareLooku
|
|||||||
EXPECT_EQ(l0LookupTable.sharedHandleType.ntHnadle, importNTHandle.handle);
|
EXPECT_EQ(l0LookupTable.sharedHandleType.ntHnadle, importNTHandle.handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(L0StructuresLookupTableTests, givenL0StructuresWithSupportedExportHandlesWhenPrepareLookupTableThenProperFieldsInLookupTableAreSet) {
|
||||||
|
ze_external_memory_import_win32_handle_t exportStruct = {};
|
||||||
|
exportStruct.stype = ZE_STRUCTURE_TYPE_EXTERNAL_MEMORY_EXPORT_DESC;
|
||||||
|
exportStruct.flags = ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32;
|
||||||
|
|
||||||
|
StructuresLookupTable l0LookupTable = {};
|
||||||
|
auto result = prepareL0StructuresLookupTable(l0LookupTable, &exportStruct);
|
||||||
|
|
||||||
|
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
|
||||||
|
|
||||||
|
EXPECT_TRUE(l0LookupTable.exportMemory);
|
||||||
|
exportStruct.flags = ZE_EXTERNAL_MEMORY_TYPE_FLAG_DMA_BUF;
|
||||||
|
|
||||||
|
l0LookupTable = {};
|
||||||
|
result = prepareL0StructuresLookupTable(l0LookupTable, &exportStruct);
|
||||||
|
|
||||||
|
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
|
||||||
|
|
||||||
|
EXPECT_TRUE(l0LookupTable.exportMemory);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(L0StructuresLookupTableTests, givenL0StructuresWithUnsupportedExportHandlesWhenPrepareLookupTableThenUnsuppoertedErrorIsReturned) {
|
||||||
|
ze_external_memory_import_win32_handle_t exportStruct = {};
|
||||||
|
exportStruct.stype = ZE_STRUCTURE_TYPE_EXTERNAL_MEMORY_EXPORT_DESC;
|
||||||
|
exportStruct.flags = ZE_EXTERNAL_MEMORY_TYPE_FLAG_D3D11_TEXTURE;
|
||||||
|
|
||||||
|
StructuresLookupTable l0LookupTable = {};
|
||||||
|
auto result = prepareL0StructuresLookupTable(l0LookupTable, &exportStruct);
|
||||||
|
|
||||||
|
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION);
|
||||||
|
|
||||||
|
EXPECT_FALSE(l0LookupTable.exportMemory);
|
||||||
|
exportStruct.flags = ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_FD;
|
||||||
|
|
||||||
|
l0LookupTable = {};
|
||||||
|
result = prepareL0StructuresLookupTable(l0LookupTable, &exportStruct);
|
||||||
|
|
||||||
|
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION);
|
||||||
|
|
||||||
|
EXPECT_FALSE(l0LookupTable.exportMemory);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(L0StructuresLookupTableTests, givenL0StructuresWithSupportedExportHandlesAndImageDescWhenPrepareLookupTableThenUnsuppoertedErrorIsReturned) {
|
||||||
|
ze_image_desc_t imageDesc = {};
|
||||||
|
imageDesc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
|
||||||
|
|
||||||
|
ze_external_memory_import_win32_handle_t exportStruct = {};
|
||||||
|
exportStruct.stype = ZE_STRUCTURE_TYPE_EXTERNAL_MEMORY_EXPORT_DESC;
|
||||||
|
exportStruct.flags = ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32;
|
||||||
|
|
||||||
|
exportStruct.pNext = &imageDesc;
|
||||||
|
|
||||||
|
StructuresLookupTable l0LookupTable = {};
|
||||||
|
auto result = prepareL0StructuresLookupTable(l0LookupTable, &exportStruct);
|
||||||
|
|
||||||
|
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION);
|
||||||
|
|
||||||
|
EXPECT_TRUE(l0LookupTable.exportMemory);
|
||||||
|
EXPECT_TRUE(l0LookupTable.areImageProperties);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(L0StructuresLookupTableTests, givenL0StructuresWithUnsuportedOptionsWhenPrepareLookupTableThenProperFieldsInLookupTableAreSet) {
|
TEST(L0StructuresLookupTableTests, givenL0StructuresWithUnsuportedOptionsWhenPrepareLookupTableThenProperFieldsInLookupTableAreSet) {
|
||||||
uint64_t handle = 0x02;
|
uint64_t handle = 0x02;
|
||||||
ze_external_memory_import_win32_handle_t importNTHandle = {};
|
ze_external_memory_import_win32_handle_t importNTHandle = {};
|
||||||
|
|||||||
@@ -322,7 +322,7 @@ HWTEST2_F(ImageCreate, givenOpaqueFdWhenCreatingImageThenUnsuportedErrorIsReturn
|
|||||||
ASSERT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION, ret);
|
ASSERT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
HWTEST2_F(ImageCreate, givenInvalidExensionStructWhenCreatingImageThenUnsuportedErrorIsReturned, ImageSupport) {
|
HWTEST2_F(ImageCreate, givenExportStructWhenCreatingImageThenUnsuportedErrorIsReturned, ImageSupport) {
|
||||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||||
|
|
||||||
ze_image_desc_t desc = {};
|
ze_image_desc_t desc = {};
|
||||||
@@ -343,6 +343,7 @@ HWTEST2_F(ImageCreate, givenInvalidExensionStructWhenCreatingImageThenUnsuported
|
|||||||
ze_external_memory_export_fd_t exportFd = {};
|
ze_external_memory_export_fd_t exportFd = {};
|
||||||
exportFd.fd = 1;
|
exportFd.fd = 1;
|
||||||
exportFd.stype = ZE_STRUCTURE_TYPE_EXTERNAL_MEMORY_EXPORT_DESC;
|
exportFd.stype = ZE_STRUCTURE_TYPE_EXTERNAL_MEMORY_EXPORT_DESC;
|
||||||
|
exportFd.flags = ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32;
|
||||||
desc.pNext = &exportFd;
|
desc.pNext = &exportFd;
|
||||||
|
|
||||||
auto imageHW = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
|
auto imageHW = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
|
||||||
@@ -354,7 +355,7 @@ class MemoryManagerNTHandleMock : public NEO::OsAgnosticMemoryManager {
|
|||||||
public:
|
public:
|
||||||
MemoryManagerNTHandleMock(NEO::ExecutionEnvironment &executionEnvironment) : NEO::OsAgnosticMemoryManager(executionEnvironment) {}
|
MemoryManagerNTHandleMock(NEO::ExecutionEnvironment &executionEnvironment) : NEO::OsAgnosticMemoryManager(executionEnvironment) {}
|
||||||
|
|
||||||
NEO::GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex) override {
|
NEO::GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, GraphicsAllocation::AllocationType allocType) override {
|
||||||
auto graphicsAllocation = createMemoryAllocation(GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, nullptr, reinterpret_cast<void *>(1), 1,
|
auto graphicsAllocation = createMemoryAllocation(GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, nullptr, reinterpret_cast<void *>(1), 1,
|
||||||
4096u, reinterpret_cast<uint64_t>(handle), MemoryPool::SystemCpuInaccessible,
|
4096u, reinterpret_cast<uint64_t>(handle), MemoryPool::SystemCpuInaccessible,
|
||||||
rootDeviceIndex, false, false, false);
|
rootDeviceIndex, false, false, false);
|
||||||
|
|||||||
@@ -451,7 +451,7 @@ TEST_F(MemoryRelaxedSizeTests,
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MemoryRelaxedSizeTests,
|
TEST_F(MemoryRelaxedSizeTests,
|
||||||
givenCallToDeviceAllocWithLargerThanAllowedSizeAndRelaxedDescriptorWithWrongStypeThenUnsupportedSizeIsReturned) {
|
givenCallToDeviceAllocWithLargerThanAllowedSizeAndRelaxedDescriptorWithWrongStypeThenUnsupportedEnumerationIsReturned) {
|
||||||
size_t size = device->getNEODevice()->getDeviceInfo().maxMemAllocSize + 1;
|
size_t size = device->getNEODevice()->getDeviceInfo().maxMemAllocSize + 1;
|
||||||
size_t alignment = 1u;
|
size_t alignment = 1u;
|
||||||
void *ptr = nullptr;
|
void *ptr = nullptr;
|
||||||
@@ -465,7 +465,7 @@ TEST_F(MemoryRelaxedSizeTests,
|
|||||||
ze_result_t result = context->allocDeviceMem(device->toHandle(),
|
ze_result_t result = context->allocDeviceMem(device->toHandle(),
|
||||||
&deviceDesc,
|
&deviceDesc,
|
||||||
size, alignment, &ptr);
|
size, alignment, &ptr);
|
||||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_SIZE, result);
|
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION, result);
|
||||||
EXPECT_EQ(nullptr, ptr);
|
EXPECT_EQ(nullptr, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1227,7 +1227,7 @@ class MemoryManagerIpcMock : public NEO::MemoryManager {
|
|||||||
NEO::GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation) override { return nullptr; }
|
NEO::GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation) override { return nullptr; }
|
||||||
void addAllocationToHostPtrManager(NEO::GraphicsAllocation *memory) override{};
|
void addAllocationToHostPtrManager(NEO::GraphicsAllocation *memory) override{};
|
||||||
void removeAllocationFromHostPtrManager(NEO::GraphicsAllocation *memory) override{};
|
void removeAllocationFromHostPtrManager(NEO::GraphicsAllocation *memory) override{};
|
||||||
NEO::GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex) override { return nullptr; };
|
NEO::GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, GraphicsAllocation::AllocationType allocType) override { return nullptr; };
|
||||||
AllocationStatus populateOsHandles(NEO::OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override { return AllocationStatus::Success; };
|
AllocationStatus populateOsHandles(NEO::OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override { return AllocationStatus::Success; };
|
||||||
void cleanOsHandles(NEO::OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override{};
|
void cleanOsHandles(NEO::OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override{};
|
||||||
void freeGraphicsMemoryImpl(NEO::GraphicsAllocation *gfxAllocation) override{};
|
void freeGraphicsMemoryImpl(NEO::GraphicsAllocation *gfxAllocation) override{};
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ Image *D3DTexture<D3D>::create2d(Context *context, D3DTexture2d *d3dTexture, cl_
|
|||||||
if (textureDesc.MiscFlags & D3DResourceFlags::MISC_SHARED_NTHANDLE) {
|
if (textureDesc.MiscFlags & D3DResourceFlags::MISC_SHARED_NTHANDLE) {
|
||||||
sharingFcns->getSharedNTHandle(textureStaging, &sharedHandle);
|
sharingFcns->getSharedNTHandle(textureStaging, &sharedHandle);
|
||||||
if (memoryManager->verifyHandle(toOsHandle(sharedHandle), rootDeviceIndex, true)) {
|
if (memoryManager->verifyHandle(toOsHandle(sharedHandle), rootDeviceIndex, true)) {
|
||||||
alloc = memoryManager->createGraphicsAllocationFromNTHandle(sharedHandle, rootDeviceIndex);
|
alloc = memoryManager->createGraphicsAllocationFromNTHandle(sharedHandle, rootDeviceIndex, GraphicsAllocation::AllocationType::SHARED_IMAGE);
|
||||||
} else {
|
} else {
|
||||||
err.set(CL_INVALID_D3D11_RESOURCE_KHR);
|
err.set(CL_INVALID_D3D11_RESOURCE_KHR);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -167,7 +167,7 @@ Image *D3DTexture<D3D>::create3d(Context *context, D3DTexture3d *d3dTexture, cl_
|
|||||||
if (textureDesc.MiscFlags & D3DResourceFlags::MISC_SHARED_NTHANDLE) {
|
if (textureDesc.MiscFlags & D3DResourceFlags::MISC_SHARED_NTHANDLE) {
|
||||||
sharingFcns->getSharedNTHandle(textureStaging, &sharedHandle);
|
sharingFcns->getSharedNTHandle(textureStaging, &sharedHandle);
|
||||||
if (memoryManager->verifyHandle(toOsHandle(sharedHandle), rootDeviceIndex, true)) {
|
if (memoryManager->verifyHandle(toOsHandle(sharedHandle), rootDeviceIndex, true)) {
|
||||||
alloc = memoryManager->createGraphicsAllocationFromNTHandle(sharedHandle, rootDeviceIndex);
|
alloc = memoryManager->createGraphicsAllocationFromNTHandle(sharedHandle, rootDeviceIndex, GraphicsAllocation::AllocationType::SHARED_IMAGE);
|
||||||
} else {
|
} else {
|
||||||
err.set(CL_INVALID_D3D11_RESOURCE_KHR);
|
err.set(CL_INVALID_D3D11_RESOURCE_KHR);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ GraphicsAllocation *UnifiedSharing::createGraphicsAllocation(Context *context, U
|
|||||||
auto memoryManager = context->getMemoryManager();
|
auto memoryManager = context->getMemoryManager();
|
||||||
switch (description.type) {
|
switch (description.type) {
|
||||||
case UnifiedSharingHandleType::Win32Nt: {
|
case UnifiedSharingHandleType::Win32Nt: {
|
||||||
return memoryManager->createGraphicsAllocationFromNTHandle(description.handle, context->getDevice(0)->getRootDeviceIndex());
|
return memoryManager->createGraphicsAllocationFromNTHandle(description.handle, context->getDevice(0)->getRootDeviceIndex(), GraphicsAllocation::AllocationType::SHARED_IMAGE);
|
||||||
}
|
}
|
||||||
case UnifiedSharingHandleType::LinuxFd:
|
case UnifiedSharingHandleType::LinuxFd:
|
||||||
case UnifiedSharingHandleType::Win32Shared: {
|
case UnifiedSharingHandleType::Win32Shared: {
|
||||||
|
|||||||
@@ -1367,7 +1367,7 @@ TEST_F(DeviceGetCapsTest, givenFlagEnabled64kbPagesWhenCallConstructorMemoryMana
|
|||||||
void addAllocationToHostPtrManager(GraphicsAllocation *memory) override{};
|
void addAllocationToHostPtrManager(GraphicsAllocation *memory) override{};
|
||||||
void removeAllocationFromHostPtrManager(GraphicsAllocation *memory) override{};
|
void removeAllocationFromHostPtrManager(GraphicsAllocation *memory) override{};
|
||||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation) override { return nullptr; };
|
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation) override { return nullptr; };
|
||||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex) override { return nullptr; };
|
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, GraphicsAllocation::AllocationType allocType) override { return nullptr; };
|
||||||
AllocationStatus populateOsHandles(OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override { return AllocationStatus::Success; };
|
AllocationStatus populateOsHandles(OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override { return AllocationStatus::Success; };
|
||||||
void cleanOsHandles(OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override{};
|
void cleanOsHandles(OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override{};
|
||||||
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override{};
|
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override{};
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class D3DTests : public PlatformFixture, public ::testing::Test {
|
|||||||
gmmOwnershipPassed = true;
|
gmmOwnershipPassed = true;
|
||||||
return alloc;
|
return alloc;
|
||||||
}
|
}
|
||||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex) override {
|
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, GraphicsAllocation::AllocationType allocType) override {
|
||||||
if (failAlloc) {
|
if (failAlloc) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1114,7 +1114,7 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenCreateGraphicsAllocat
|
|||||||
TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenCreateAllocationFromNtHandleIsCalledThenReturnNullptr) {
|
TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenCreateAllocationFromNtHandleIsCalledThenReturnNullptr) {
|
||||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||||
OsAgnosticMemoryManager memoryManager(executionEnvironment);
|
OsAgnosticMemoryManager memoryManager(executionEnvironment);
|
||||||
auto graphicsAllocation = memoryManager.createGraphicsAllocationFromNTHandle((void *)1, 0);
|
auto graphicsAllocation = memoryManager.createGraphicsAllocationFromNTHandle((void *)1, 0, GraphicsAllocation::AllocationType::SHARED_IMAGE);
|
||||||
EXPECT_EQ(nullptr, graphicsAllocation);
|
EXPECT_EQ(nullptr, graphicsAllocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ class FailMemoryManager : public MockMemoryManager {
|
|||||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation) override {
|
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation) override {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex) override {
|
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, GraphicsAllocation::AllocationType allocType) override {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2428,7 +2428,7 @@ TEST_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatDoesnShareTheSameBuf
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDrmMemoryManagerWhenCreateAllocationFromNtHandleIsCalledThenReturnNullptr) {
|
TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDrmMemoryManagerWhenCreateAllocationFromNtHandleIsCalledThenReturnNullptr) {
|
||||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromNTHandle(reinterpret_cast<void *>(1), 0);
|
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromNTHandle(reinterpret_cast<void *>(1), 0, GraphicsAllocation::AllocationType::SHARED_IMAGE);
|
||||||
EXPECT_EQ(nullptr, graphicsAllocation);
|
EXPECT_EQ(nullptr, graphicsAllocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -591,7 +591,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromNTHandleIsCall
|
|||||||
std::unique_ptr<Gmm> gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096u, 0, false));
|
std::unique_ptr<Gmm> gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096u, 0, false));
|
||||||
setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u);
|
setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u);
|
||||||
|
|
||||||
auto *gpuAllocation = memoryManager->createGraphicsAllocationFromNTHandle(reinterpret_cast<void *>(1), 0);
|
auto *gpuAllocation = memoryManager->createGraphicsAllocationFromNTHandle(reinterpret_cast<void *>(1), 0, GraphicsAllocation::AllocationType::SHARED_IMAGE);
|
||||||
auto wddmAlloc = static_cast<WddmAllocation *>(gpuAllocation);
|
auto wddmAlloc = static_cast<WddmAllocation *>(gpuAllocation);
|
||||||
ASSERT_NE(nullptr, gpuAllocation);
|
ASSERT_NE(nullptr, gpuAllocation);
|
||||||
EXPECT_EQ(NT_RESOURCE_HANDLE, wddmAlloc->resourceHandle);
|
EXPECT_EQ(NT_RESOURCE_HANDLE, wddmAlloc->resourceHandle);
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ struct UnifiedSharingContextFixture : ::testing::Test {
|
|||||||
|
|
||||||
template <bool validMemoryManager>
|
template <bool validMemoryManager>
|
||||||
struct UnifiedSharingMockMemoryManager : MockMemoryManager {
|
struct UnifiedSharingMockMemoryManager : MockMemoryManager {
|
||||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex) override {
|
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, GraphicsAllocation::AllocationType allocType) override {
|
||||||
if (!validMemoryManager) {
|
if (!validMemoryManager) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,8 +105,8 @@ class MockHwHelper : public HwHelperHw<GfxFamily> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct MemoryManagerReturningCompressedAllocations : UnifiedSharingMockMemoryManager<true> {
|
struct MemoryManagerReturningCompressedAllocations : UnifiedSharingMockMemoryManager<true> {
|
||||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex) override {
|
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, GraphicsAllocation::AllocationType allocType) override {
|
||||||
auto allocation = UnifiedSharingMockMemoryManager<true>::createGraphicsAllocationFromNTHandle(handle, rootDeviceIndex);
|
auto allocation = UnifiedSharingMockMemoryManager<true>::createGraphicsAllocationFromNTHandle(handle, rootDeviceIndex, GraphicsAllocation::AllocationType::SHARED_IMAGE);
|
||||||
|
|
||||||
auto gmm = allocation->getDefaultGmm();
|
auto gmm = allocation->getDefaultGmm();
|
||||||
auto mockGmmResourceInfo = std::make_unique<MockGmmResourceInfo>(gmm->gmmResourceInfo->peekGmmResourceInfo());
|
auto mockGmmResourceInfo = std::make_unique<MockGmmResourceInfo>(gmm->gmmResourceInfo->peekGmmResourceInfo());
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ struct UnifiedSharingCreateAllocationTests : UnifiedSharingTestsWithMemoryManage
|
|||||||
struct MemoryManagerCheckingAllocationMethod : MockMemoryManager {
|
struct MemoryManagerCheckingAllocationMethod : MockMemoryManager {
|
||||||
using MockMemoryManager::MockMemoryManager;
|
using MockMemoryManager::MockMemoryManager;
|
||||||
|
|
||||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex) override {
|
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, GraphicsAllocation::AllocationType allocType) override {
|
||||||
this->createFromNTHandleCalled = true;
|
this->createFromNTHandleCalled = true;
|
||||||
this->handle = toOsHandle(handle);
|
this->handle = toOsHandle(handle);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class MemoryManager {
|
|||||||
virtual bool verifyHandle(osHandle handle, uint32_t rootDeviceIndex, bool) { return true; }
|
virtual bool verifyHandle(osHandle handle, uint32_t rootDeviceIndex, bool) { return true; }
|
||||||
virtual GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation) = 0;
|
virtual GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation) = 0;
|
||||||
virtual void closeSharedHandle(GraphicsAllocation *graphicsAllocation){};
|
virtual void closeSharedHandle(GraphicsAllocation *graphicsAllocation){};
|
||||||
virtual GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex) = 0;
|
virtual GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, GraphicsAllocation::AllocationType allocType) = 0;
|
||||||
|
|
||||||
virtual bool mapAuxGpuVA(GraphicsAllocation *graphicsAllocation);
|
virtual bool mapAuxGpuVA(GraphicsAllocation *graphicsAllocation);
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class OsAgnosticMemoryManager : public MemoryManager {
|
|||||||
void initialize(bool aubUsage);
|
void initialize(bool aubUsage);
|
||||||
~OsAgnosticMemoryManager() override;
|
~OsAgnosticMemoryManager() override;
|
||||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation) override;
|
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation) override;
|
||||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex) override { return nullptr; }
|
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, GraphicsAllocation::AllocationType allocType) override { return nullptr; }
|
||||||
|
|
||||||
void addAllocationToHostPtrManager(GraphicsAllocation *gfxAllocation) override;
|
void addAllocationToHostPtrManager(GraphicsAllocation *gfxAllocation) override;
|
||||||
void removeAllocationFromHostPtrManager(GraphicsAllocation *gfxAllocation) override;
|
void removeAllocationFromHostPtrManager(GraphicsAllocation *gfxAllocation) override;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class DrmMemoryManager : public MemoryManager {
|
|||||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation) override;
|
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation) override;
|
||||||
void closeSharedHandle(GraphicsAllocation *gfxAllocation) override;
|
void closeSharedHandle(GraphicsAllocation *gfxAllocation) override;
|
||||||
GraphicsAllocation *createPaddedAllocation(GraphicsAllocation *inputGraphicsAllocation, size_t sizeWithPadding) override;
|
GraphicsAllocation *createPaddedAllocation(GraphicsAllocation *inputGraphicsAllocation, size_t sizeWithPadding) override;
|
||||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex) override { return nullptr; }
|
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, GraphicsAllocation::AllocationType allocType) override { return nullptr; }
|
||||||
|
|
||||||
uint64_t getSystemSharedMemory(uint32_t rootDeviceIndex) override;
|
uint64_t getSystemSharedMemory(uint32_t rootDeviceIndex) override;
|
||||||
uint64_t getLocalMemorySize(uint32_t rootDeviceIndex, uint32_t deviceBitfield) override;
|
uint64_t getLocalMemorySize(uint32_t rootDeviceIndex, uint32_t deviceBitfield) override;
|
||||||
|
|||||||
@@ -393,8 +393,8 @@ GraphicsAllocation *WddmMemoryManager::createGraphicsAllocationFromSharedHandle(
|
|||||||
return createAllocationFromHandle(handle, requireSpecificBitness, false, properties.allocationType, properties.rootDeviceIndex);
|
return createAllocationFromHandle(handle, requireSpecificBitness, false, properties.allocationType, properties.rootDeviceIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsAllocation *WddmMemoryManager::createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex) {
|
GraphicsAllocation *WddmMemoryManager::createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, GraphicsAllocation::AllocationType allocType) {
|
||||||
return createAllocationFromHandle(toOsHandle(handle), false, true, GraphicsAllocation::AllocationType::SHARED_IMAGE, rootDeviceIndex);
|
return createAllocationFromHandle(toOsHandle(handle), false, true, allocType, rootDeviceIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WddmMemoryManager::addAllocationToHostPtrManager(GraphicsAllocation *gfxAllocation) {
|
void WddmMemoryManager::addAllocationToHostPtrManager(GraphicsAllocation *gfxAllocation) {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class WddmMemoryManager : public MemoryManager {
|
|||||||
void handleFenceCompletion(GraphicsAllocation *allocation) override;
|
void handleFenceCompletion(GraphicsAllocation *allocation) override;
|
||||||
|
|
||||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation) override;
|
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation) override;
|
||||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex) override;
|
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, GraphicsAllocation::AllocationType allocType) override;
|
||||||
|
|
||||||
void addAllocationToHostPtrManager(GraphicsAllocation *memory) override;
|
void addAllocationToHostPtrManager(GraphicsAllocation *memory) override;
|
||||||
void removeAllocationFromHostPtrManager(GraphicsAllocation *memory) override;
|
void removeAllocationFromHostPtrManager(GraphicsAllocation *memory) override;
|
||||||
|
|||||||
Reference in New Issue
Block a user