mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-19 16:24:18 +08:00
refactor: pass arrayIndex to Wddm::openNTHandle function
Related-To: NEO-11498 Signed-off-by: Jaroslaw Warchulski <jaroslaw.warchulski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
f8994aacb6
commit
76a05c1cab
@@ -885,7 +885,8 @@ void *DriverHandleImp::importNTHandle(ze_device_handle_t hDevice, void *handle,
|
||||
|
||||
bool isHostIpcAllocation = (allocationType == NEO::AllocationType::bufferHostMemory) ? true : false;
|
||||
|
||||
auto alloc = this->getMemoryManager()->createGraphicsAllocationFromNTHandle(handle, neoDevice->getRootDeviceIndex(), NEO::AllocationType::sharedBuffer);
|
||||
NEO::MemoryManager::OsHandleData osHandleData{handle};
|
||||
auto alloc = this->getMemoryManager()->createGraphicsAllocationFromNTHandle(osHandleData, neoDevice->getRootDeviceIndex(), NEO::AllocationType::sharedBuffer);
|
||||
|
||||
if (alloc == nullptr) {
|
||||
return nullptr;
|
||||
|
||||
@@ -114,7 +114,7 @@ ze_result_t ImageCoreFamily<gfxCoreFamily>::initialize(Device *device, const ze_
|
||||
}
|
||||
if (lookupTable.sharedHandleType.isDMABUFHandle) {
|
||||
NEO::AllocationProperties properties(device->getRootDeviceIndex(), true, &imgInfo, NEO::AllocationType::sharedImage, device->getNEODevice()->getDeviceBitfield());
|
||||
NEO::MemoryManager::OsHandleData osHandleData{static_cast<NEO::osHandle>(lookupTable.sharedHandleType.fd)};
|
||||
NEO::MemoryManager::ExtendedOsHandleData osHandleData{static_cast<NEO::osHandle>(lookupTable.sharedHandleType.fd)};
|
||||
allocation = device->getNEODevice()->getMemoryManager()->createGraphicsAllocationFromSharedHandle(osHandleData, properties, false, false, true, nullptr);
|
||||
device->getNEODevice()->getMemoryManager()->closeSharedHandle(allocation);
|
||||
} else if (lookupTable.sharedHandleType.isNTHandle) {
|
||||
@@ -122,7 +122,8 @@ ze_result_t ImageCoreFamily<gfxCoreFamily>::initialize(Device *device, const ze_
|
||||
if (!verifyResult) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
allocation = device->getNEODevice()->getMemoryManager()->createGraphicsAllocationFromNTHandle(lookupTable.sharedHandleType.ntHnadle, device->getNEODevice()->getRootDeviceIndex(), NEO::AllocationType::sharedImage);
|
||||
NEO::MemoryManager::ExtendedOsHandleData osHandleData{lookupTable.sharedHandleType.ntHnadle};
|
||||
allocation = device->getNEODevice()->getMemoryManager()->createGraphicsAllocationFromNTHandle(osHandleData, device->getNEODevice()->getRootDeviceIndex(), NEO::AllocationType::sharedImage);
|
||||
allocation->getDefaultGmm()->queryImageParams(imgInfo);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -379,7 +379,7 @@ NEO::GraphicsAllocation *MemoryManagerOpenIpcMock::createGraphicsAllocationFromM
|
||||
alloc->setGpuBaseAddress(0xabcd);
|
||||
return alloc;
|
||||
}
|
||||
NEO::GraphicsAllocation *MemoryManagerOpenIpcMock::createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) {
|
||||
NEO::GraphicsAllocation *MemoryManagerOpenIpcMock::createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) {
|
||||
auto ptr = reinterpret_cast<void *>(sharedHandleAddress);
|
||||
sharedHandleAddress += 0x1000;
|
||||
auto gmmHelper = getGmmHelper(0);
|
||||
@@ -493,7 +493,7 @@ NEO::GraphicsAllocation *MemoryManagerIpcImplicitScalingMock::createGraphicsAllo
|
||||
return alloc;
|
||||
}
|
||||
|
||||
NEO::GraphicsAllocation *MemoryManagerIpcImplicitScalingMock::createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) {
|
||||
NEO::GraphicsAllocation *MemoryManagerIpcImplicitScalingMock::createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) {
|
||||
if (failOnCreateGraphicsAllocationFromNTHandle) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ 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(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override { return nullptr; };
|
||||
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 +279,7 @@ class MemoryManagerOpenIpcMock : public MemoryManagerIpcMock {
|
||||
bool reuseSharedAllocation, void *mapPointer) override;
|
||||
NEO::GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &handles,
|
||||
AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override;
|
||||
NEO::GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override;
|
||||
NEO::GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override;
|
||||
|
||||
void freeGraphicsMemory(GraphicsAllocation *gfxAllocation) override {
|
||||
delete gfxAllocation;
|
||||
@@ -365,7 +365,7 @@ class MemoryManagerIpcImplicitScalingMock : public NEO::MemoryManager {
|
||||
NEO::GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &handles,
|
||||
AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override;
|
||||
|
||||
NEO::GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) 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;
|
||||
|
||||
|
||||
@@ -1387,7 +1387,7 @@ 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(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override { return nullptr; };
|
||||
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{};
|
||||
|
||||
@@ -275,11 +275,11 @@ class MemoryManagerNTHandleMock : public NEO::OsAgnosticMemoryManager {
|
||||
public:
|
||||
MemoryManagerNTHandleMock(NEO::ExecutionEnvironment &executionEnvironment) : NEO::OsAgnosticMemoryManager(executionEnvironment) {}
|
||||
|
||||
NEO::GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override {
|
||||
NEO::GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override {
|
||||
auto graphicsAllocation = createMemoryAllocation(allocType, nullptr, reinterpret_cast<void *>(1), 1,
|
||||
4096u, reinterpret_cast<uint64_t>(handle), MemoryPool::systemCpuInaccessible,
|
||||
4096u, osHandleData.handle, MemoryPool::systemCpuInaccessible,
|
||||
rootDeviceIndex, false, false, false);
|
||||
graphicsAllocation->setSharedHandle(static_cast<osHandle>(reinterpret_cast<uint64_t>(handle)));
|
||||
graphicsAllocation->setSharedHandle(osHandleData.handle);
|
||||
graphicsAllocation->set32BitAllocation(false);
|
||||
GmmRequirements gmmRequirements{};
|
||||
gmmRequirements.allowLargePages = true;
|
||||
|
||||
@@ -70,7 +70,7 @@ 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(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override { return nullptr; };
|
||||
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{};
|
||||
|
||||
@@ -486,11 +486,11 @@ class MemoryManagerNTHandleMock : public NEO::OsAgnosticMemoryManager {
|
||||
public:
|
||||
MemoryManagerNTHandleMock(NEO::ExecutionEnvironment &executionEnvironment) : NEO::OsAgnosticMemoryManager(executionEnvironment) {}
|
||||
|
||||
NEO::GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override {
|
||||
NEO::GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override {
|
||||
auto graphicsAllocation = createMemoryAllocation(AllocationType::internalHostMemory, nullptr, reinterpret_cast<void *>(1), 1,
|
||||
4096u, reinterpret_cast<uint64_t>(handle), MemoryPool::systemCpuInaccessible,
|
||||
4096u, osHandleData.handle, MemoryPool::systemCpuInaccessible,
|
||||
rootDeviceIndex, false, false, false);
|
||||
graphicsAllocation->setSharedHandle(static_cast<osHandle>(reinterpret_cast<uint64_t>(handle)));
|
||||
graphicsAllocation->setSharedHandle(osHandleData.handle);
|
||||
graphicsAllocation->set32BitAllocation(false);
|
||||
GmmRequirements gmmRequirements{};
|
||||
gmmRequirements.allowLargePages = true;
|
||||
|
||||
@@ -67,7 +67,7 @@ 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(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override { return nullptr; };
|
||||
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 +484,7 @@ 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(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override { return nullptr; };
|
||||
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{};
|
||||
|
||||
@@ -76,7 +76,8 @@ Image *D3DTexture<D3D>::create2d(Context *context, D3DTexture2d *d3dTexture, cl_
|
||||
if (textureDesc.MiscFlags & D3DResourceFlags::MISC_SHARED_NTHANDLE) {
|
||||
sharingFcns->getSharedNTHandle(textureStaging, &sharedHandle);
|
||||
if (memoryManager->verifyHandle(toOsHandle(sharedHandle), rootDeviceIndex, true)) {
|
||||
alloc = memoryManager->createGraphicsAllocationFromNTHandle(sharedHandle, rootDeviceIndex, AllocationType::sharedImage);
|
||||
MemoryManager::ExtendedOsHandleData osHandleData{sharedHandle, arrayIndex};
|
||||
alloc = memoryManager->createGraphicsAllocationFromNTHandle(osHandleData, rootDeviceIndex, AllocationType::sharedImage);
|
||||
} else {
|
||||
err.set(CL_INVALID_D3D11_RESOURCE_KHR);
|
||||
return nullptr;
|
||||
@@ -170,7 +171,8 @@ Image *D3DTexture<D3D>::create3d(Context *context, D3DTexture3d *d3dTexture, cl_
|
||||
if (textureDesc.MiscFlags & D3DResourceFlags::MISC_SHARED_NTHANDLE) {
|
||||
sharingFcns->getSharedNTHandle(textureStaging, &sharedHandle);
|
||||
if (memoryManager->verifyHandle(toOsHandle(sharedHandle), rootDeviceIndex, true)) {
|
||||
alloc = memoryManager->createGraphicsAllocationFromNTHandle(sharedHandle, rootDeviceIndex, AllocationType::sharedImage);
|
||||
MemoryManager::ExtendedOsHandleData osHandleData{sharedHandle};
|
||||
alloc = memoryManager->createGraphicsAllocationFromNTHandle(osHandleData, rootDeviceIndex, AllocationType::sharedImage);
|
||||
} else {
|
||||
err.set(CL_INVALID_D3D11_RESOURCE_KHR);
|
||||
return nullptr;
|
||||
|
||||
@@ -42,7 +42,8 @@ GraphicsAllocation *UnifiedSharing::createGraphicsAllocation(Context *context, U
|
||||
auto memoryManager = context->getMemoryManager();
|
||||
switch (description.type) {
|
||||
case UnifiedSharingHandleType::win32Nt: {
|
||||
return memoryManager->createGraphicsAllocationFromNTHandle(description.handle, context->getDevice(0)->getRootDeviceIndex(), allocationType);
|
||||
MemoryManager::OsHandleData osHandleData{description.handle};
|
||||
return memoryManager->createGraphicsAllocationFromNTHandle(osHandleData, context->getDevice(0)->getRootDeviceIndex(), allocationType);
|
||||
}
|
||||
case UnifiedSharingHandleType::linuxFd:
|
||||
case UnifiedSharingHandleType::win32Shared: {
|
||||
|
||||
@@ -59,12 +59,11 @@ class D3DTests : public PlatformFixture, public ::testing::Test {
|
||||
gmmOwnershipPassed = true;
|
||||
return alloc;
|
||||
}
|
||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override {
|
||||
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);
|
||||
OsAgnosticMemoryManager::OsHandleData osHandleData{handle};
|
||||
auto alloc = OsAgnosticMemoryManager::createGraphicsAllocationFromSharedHandle(osHandleData, properties, false, false, true, nullptr);
|
||||
alloc->setDefaultGmm(forceGmm);
|
||||
gmmOwnershipPassed = true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Intel Corporation
|
||||
* Copyright (C) 2023-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -14,10 +14,10 @@ using namespace NEO;
|
||||
|
||||
struct ImageWindowsTestsMockMemoryManager : MockMemoryManager {
|
||||
using MockMemoryManager::MockMemoryManager;
|
||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override {
|
||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override {
|
||||
|
||||
auto graphicsAllocation = createMemoryAllocation(allocType, nullptr, reinterpret_cast<void *>(1), 1,
|
||||
4096u, reinterpret_cast<uint64_t>(handle), MemoryPool::systemCpuInaccessible,
|
||||
4096u, osHandleData.handle, MemoryPool::systemCpuInaccessible,
|
||||
rootDeviceIndex, false, false, false);
|
||||
|
||||
graphicsAllocation->setDefaultGmm(new MockGmm(executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getGmmHelper()));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2023 Intel Corporation
|
||||
* Copyright (C) 2019-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -60,15 +60,15 @@ struct UnifiedSharingContextFixture : ::testing::Test {
|
||||
template <bool validMemoryManager>
|
||||
struct UnifiedSharingMockMemoryManager : MockMemoryManager {
|
||||
using MockMemoryManager::MockMemoryManager;
|
||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override {
|
||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override {
|
||||
if (!validMemoryManager) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto graphicsAllocation = createMemoryAllocation(AllocationType::internalHostMemory, nullptr, reinterpret_cast<void *>(1), 1,
|
||||
4096u, reinterpret_cast<uint64_t>(handle), MemoryPool::systemCpuInaccessible,
|
||||
4096u, osHandleData.handle, MemoryPool::systemCpuInaccessible,
|
||||
rootDeviceIndex, false, false, false);
|
||||
graphicsAllocation->setSharedHandle(static_cast<osHandle>(reinterpret_cast<uint64_t>(handle)));
|
||||
graphicsAllocation->setSharedHandle(osHandleData.handle);
|
||||
graphicsAllocation->set32BitAllocation(false);
|
||||
graphicsAllocation->setDefaultGmm(new MockGmm(executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getGmmHelper()));
|
||||
return graphicsAllocation;
|
||||
|
||||
@@ -110,8 +110,8 @@ class MockProductHelper : public ProductHelperHw<IGFX_UNKNOWN> {
|
||||
};
|
||||
|
||||
struct MemoryManagerReturningCompressedAllocations : UnifiedSharingMockMemoryManager<true> {
|
||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override {
|
||||
auto allocation = UnifiedSharingMockMemoryManager<true>::createGraphicsAllocationFromNTHandle(handle, rootDeviceIndex, AllocationType::sharedImage);
|
||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override {
|
||||
auto allocation = UnifiedSharingMockMemoryManager<true>::createGraphicsAllocationFromNTHandle(osHandleData, rootDeviceIndex, AllocationType::sharedImage);
|
||||
|
||||
auto gmm = allocation->getDefaultGmm();
|
||||
auto mockGmmResourceInfo = std::make_unique<MockGmmResourceInfo>(gmm->gmmResourceInfo->peekGmmResourceInfo());
|
||||
|
||||
@@ -164,9 +164,9 @@ struct UnifiedSharingCreateAllocationTests : UnifiedSharingTestsWithMemoryManage
|
||||
struct MemoryManagerCheckingAllocationMethod : MockMemoryManager {
|
||||
using MockMemoryManager::MockMemoryManager;
|
||||
|
||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override {
|
||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override {
|
||||
this->createFromNTHandleCalled = true;
|
||||
this->handle = toOsHandle(handle);
|
||||
this->handle = osHandleData.handle;
|
||||
return nullptr;
|
||||
}
|
||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(const OsHandleData &osHandleData, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override {
|
||||
|
||||
@@ -139,7 +139,7 @@ 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(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) = 0;
|
||||
virtual GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) = 0;
|
||||
|
||||
virtual bool mapAuxGpuVA(GraphicsAllocation *graphicsAllocation);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class OsAgnosticMemoryManager : public MemoryManager {
|
||||
~OsAgnosticMemoryManager() override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &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(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override { return nullptr; }
|
||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override { return nullptr; }
|
||||
|
||||
void addAllocationToHostPtrManager(GraphicsAllocation *gfxAllocation) override;
|
||||
void removeAllocationFromHostPtrManager(GraphicsAllocation *gfxAllocation) override;
|
||||
|
||||
@@ -44,7 +44,7 @@ class DrmMemoryManager : public MemoryManager {
|
||||
void closeSharedHandle(GraphicsAllocation *gfxAllocation) override;
|
||||
void closeInternalHandle(uint64_t &handle, uint32_t handleId, GraphicsAllocation *graphicsAllocation) override;
|
||||
|
||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override { return nullptr; }
|
||||
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;
|
||||
|
||||
@@ -877,10 +877,10 @@ bool Wddm::verifyNTHandle(HANDLE handle) {
|
||||
return status == STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
bool Wddm::openNTHandle(HANDLE handle, WddmAllocation *alloc) {
|
||||
bool Wddm::openNTHandle(const MemoryManager::ExtendedOsHandleData &osHandleData, WddmAllocation *alloc) {
|
||||
D3DKMT_QUERYRESOURCEINFOFROMNTHANDLE queryResourceInfoFromNtHandle = {};
|
||||
queryResourceInfoFromNtHandle.hDevice = device;
|
||||
queryResourceInfoFromNtHandle.hNtHandle = handle;
|
||||
queryResourceInfoFromNtHandle.hNtHandle = reinterpret_cast<HANDLE>(static_cast<uintptr_t>(osHandleData.handle));
|
||||
[[maybe_unused]] auto status = getGdi()->queryResourceInfoFromNtHandle(&queryResourceInfoFromNtHandle);
|
||||
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
|
||||
|
||||
@@ -892,7 +892,7 @@ bool Wddm::openNTHandle(HANDLE handle, WddmAllocation *alloc) {
|
||||
D3DKMT_OPENRESOURCEFROMNTHANDLE openResourceFromNtHandle = {};
|
||||
|
||||
openResourceFromNtHandle.hDevice = device;
|
||||
openResourceFromNtHandle.hNtHandle = handle;
|
||||
openResourceFromNtHandle.hNtHandle = reinterpret_cast<HANDLE>(static_cast<uintptr_t>(osHandleData.handle));
|
||||
openResourceFromNtHandle.NumAllocations = queryResourceInfoFromNtHandle.NumAllocations;
|
||||
openResourceFromNtHandle.pOpenAllocationInfo2 = allocationInfo2.get();
|
||||
openResourceFromNtHandle.pTotalPrivateDriverDataBuffer = allocPrivateData.get();
|
||||
|
||||
@@ -81,7 +81,7 @@ class Wddm : public DriverModel {
|
||||
MOCKABLE_VIRTUAL bool verifySharedHandle(D3DKMT_HANDLE osHandle);
|
||||
MOCKABLE_VIRTUAL bool openSharedHandle(const MemoryManager::ExtendedOsHandleData &osHandleData, WddmAllocation *alloc);
|
||||
MOCKABLE_VIRTUAL bool verifyNTHandle(HANDLE handle);
|
||||
bool openNTHandle(HANDLE handle, WddmAllocation *alloc);
|
||||
bool openNTHandle(const MemoryManager::ExtendedOsHandleData &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);
|
||||
|
||||
@@ -603,13 +603,11 @@ GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(const OsHandle
|
||||
auto allocation = std::make_unique<WddmAllocation>(rootDeviceIndex, allocationType, nullptr, 0, osHandleData.handle, MemoryPool::systemCpuInaccessible, maxOsContextCount, 0llu);
|
||||
|
||||
bool status = false;
|
||||
if (ntHandle) {
|
||||
status = getWddm(rootDeviceIndex).openNTHandle(reinterpret_cast<HANDLE>(static_cast<uintptr_t>(osHandleData.handle)), allocation.get());
|
||||
} else if (allocationType == AllocationType::sharedImage) {
|
||||
status = getWddm(rootDeviceIndex).openSharedHandle(static_cast<const ExtendedOsHandleData &>(osHandleData), allocation.get());
|
||||
if (allocationType == AllocationType::sharedImage) {
|
||||
status = ntHandle ? getWddm(rootDeviceIndex).openNTHandle(static_cast<const ExtendedOsHandleData &>(osHandleData), allocation.get()) : getWddm(rootDeviceIndex).openSharedHandle(static_cast<const ExtendedOsHandleData &>(osHandleData), allocation.get());
|
||||
} else {
|
||||
MemoryManager::ExtendedOsHandleData extendedOsHandleData{osHandleData.handle};
|
||||
status = getWddm(rootDeviceIndex).openSharedHandle(extendedOsHandleData, allocation.get());
|
||||
status = ntHandle ? getWddm(rootDeviceIndex).openNTHandle(extendedOsHandleData, allocation.get()) : getWddm(rootDeviceIndex).openSharedHandle(extendedOsHandleData, allocation.get());
|
||||
}
|
||||
|
||||
if (!status) {
|
||||
@@ -654,8 +652,7 @@ GraphicsAllocation *WddmMemoryManager::createGraphicsAllocationFromSharedHandle(
|
||||
return createAllocationFromHandle(osHandleData, requireSpecificBitness, false, properties.allocationType, properties.rootDeviceIndex, mapPointer);
|
||||
}
|
||||
|
||||
GraphicsAllocation *WddmMemoryManager::createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) {
|
||||
ExtendedOsHandleData osHandleData{handle};
|
||||
GraphicsAllocation *WddmMemoryManager::createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) {
|
||||
return createAllocationFromHandle(osHandleData, false, true, allocType, rootDeviceIndex, nullptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class WddmMemoryManager : public MemoryManager {
|
||||
|
||||
GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &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(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override;
|
||||
|
||||
void addAllocationToHostPtrManager(GraphicsAllocation *memory) override;
|
||||
void removeAllocationFromHostPtrManager(GraphicsAllocation *memory) override;
|
||||
|
||||
@@ -232,16 +232,16 @@ GraphicsAllocation *MockMemoryManager::createGraphicsAllocationFromSharedHandle(
|
||||
}
|
||||
}
|
||||
|
||||
GraphicsAllocation *MockMemoryManager::createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) {
|
||||
if (toOsHandle(handle) != invalidSharedHandle) {
|
||||
GraphicsAllocation *MockMemoryManager::createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) {
|
||||
if (osHandleData.handle != invalidSharedHandle) {
|
||||
auto graphicsAllocation = createMemoryAllocation(NEO::AllocationType::sharedBuffer, nullptr, reinterpret_cast<void *>(1), 1,
|
||||
ipcAllocationSize, toOsHandle(handle), MemoryPool::systemCpuInaccessible, rootDeviceIndex,
|
||||
ipcAllocationSize, osHandleData.handle, MemoryPool::systemCpuInaccessible, rootDeviceIndex,
|
||||
false, false, false);
|
||||
graphicsAllocation->setSharedHandle(toOsHandle(handle));
|
||||
this->capturedSharedHandle = toOsHandle(handle);
|
||||
graphicsAllocation->setSharedHandle(osHandleData.handle);
|
||||
this->capturedSharedHandle = osHandleData.handle;
|
||||
return graphicsAllocation;
|
||||
} else {
|
||||
this->capturedSharedHandle = toOsHandle(handle);
|
||||
this->capturedSharedHandle = osHandleData.handle;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class MockMemoryManager : public MemoryManagerCreate<OsAgnosticMemoryManager> {
|
||||
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(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override;
|
||||
|
||||
void *allocateSystemMemory(size_t size, size_t alignment) override;
|
||||
|
||||
@@ -329,7 +329,7 @@ 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(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override {
|
||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(const OsHandleData &osHandleData, uint32_t rootDeviceIndex, AllocationType allocType) override {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -509,7 +509,7 @@ TEST_F(DeviceGetCapsTest, givenFlagEnabled64kbPagesWhenCallConstructorMemoryMana
|
||||
void removeAllocationFromHostPtrManager(GraphicsAllocation *memory) override{};
|
||||
GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &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(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) 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{};
|
||||
|
||||
@@ -1360,7 +1360,8 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenCreateGraphicsAllocat
|
||||
TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenCreateAllocationFromNtHandleIsCalledThenReturnNullptr) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
OsAgnosticMemoryManager memoryManager(executionEnvironment);
|
||||
auto graphicsAllocation = memoryManager.createGraphicsAllocationFromNTHandle((void *)1, 0, AllocationType::sharedImage);
|
||||
OsAgnosticMemoryManager::ExtendedOsHandleData osHandleData{(void *)1};
|
||||
auto graphicsAllocation = memoryManager.createGraphicsAllocationFromNTHandle(osHandleData, 0, AllocationType::sharedImage);
|
||||
EXPECT_EQ(nullptr, graphicsAllocation);
|
||||
}
|
||||
|
||||
|
||||
@@ -2305,7 +2305,8 @@ TEST_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatDoesnShareTheSameBuf
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDrmMemoryManagerWhenCreateAllocationFromNtHandleIsCalledThenReturnNullptr) {
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromNTHandle(reinterpret_cast<void *>(1), 0, AllocationType::sharedImage);
|
||||
TestedDrmMemoryManager::ExtendedOsHandleData osHandleData{1u};
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromNTHandle(osHandleData, 0, AllocationType::sharedImage);
|
||||
EXPECT_EQ(nullptr, graphicsAllocation);
|
||||
}
|
||||
|
||||
|
||||
@@ -2662,7 +2662,8 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromNTHandleIsCall
|
||||
std::unique_ptr<Gmm> gmm(new Gmm(rootDeviceEnvironment->getGmmHelper(), pSysMem, 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, {}, gmmRequirements));
|
||||
setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u);
|
||||
|
||||
auto *gpuAllocation = memoryManager->createGraphicsAllocationFromNTHandle(reinterpret_cast<void *>(1), 0, AllocationType::sharedImage);
|
||||
MockWddmMemoryManager::ExtendedOsHandleData osHandleData{1u};
|
||||
auto *gpuAllocation = memoryManager->createGraphicsAllocationFromNTHandle(osHandleData, 0, AllocationType::sharedImage);
|
||||
auto wddmAlloc = static_cast<WddmAllocation *>(gpuAllocation);
|
||||
ASSERT_NE(nullptr, gpuAllocation);
|
||||
EXPECT_EQ(NT_RESOURCE_HANDLE, wddmAlloc->getResourceHandle());
|
||||
@@ -2693,7 +2694,8 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromNTHandleIsCall
|
||||
std::unique_ptr<Gmm> gmm(new Gmm(rootDeviceEnvironment->getGmmHelper(), pSysMem, 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, {}, gmmRequirements));
|
||||
setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u);
|
||||
|
||||
auto *gpuAllocation = memoryManager->createGraphicsAllocationFromNTHandle(reinterpret_cast<void *>(1), 0, AllocationType::sharedImage);
|
||||
MockWddmMemoryManager::ExtendedOsHandleData osHandleData{1u};
|
||||
auto *gpuAllocation = memoryManager->createGraphicsAllocationFromNTHandle(osHandleData, 0, AllocationType::sharedImage);
|
||||
auto wddmAlloc = static_cast<WddmAllocation *>(gpuAllocation);
|
||||
ASSERT_NE(nullptr, gpuAllocation);
|
||||
EXPECT_EQ(NT_RESOURCE_HANDLE, wddmAlloc->getResourceHandle());
|
||||
|
||||
Reference in New Issue
Block a user