mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-25 13:33:02 +08:00
refactor: pass arrayIndex to Wddm::openSharedHandle 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
89a8623933
commit
0ac1be7669
@@ -1015,21 +1015,21 @@ void DrmMemoryManager::eraseSharedBoHandleWrapper(int boHandle) {
|
||||
}
|
||||
}
|
||||
|
||||
GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(osHandle handle,
|
||||
GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(const OsHandleData &osHandleData,
|
||||
const AllocationProperties &properties,
|
||||
bool requireSpecificBitness,
|
||||
bool isHostIpcAllocation,
|
||||
bool reuseSharedAllocation,
|
||||
void *mapPointer) {
|
||||
if (isHostIpcAllocation) {
|
||||
return createUSMHostAllocationFromSharedHandle(handle, properties, nullptr, reuseSharedAllocation);
|
||||
return createUSMHostAllocationFromSharedHandle(osHandleData.handle, properties, nullptr, reuseSharedAllocation);
|
||||
}
|
||||
|
||||
std::unique_lock<std::mutex> lock(mtx);
|
||||
|
||||
PrimeHandle openFd{};
|
||||
uint64_t gpuRange = 0;
|
||||
openFd.fileDescriptor = handle;
|
||||
openFd.fileDescriptor = osHandleData.handle;
|
||||
|
||||
auto &drm = this->getDrm(properties.rootDeviceIndex);
|
||||
auto ioctlHelper = drm.getIoctlHelper();
|
||||
@@ -1052,7 +1052,7 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o
|
||||
const auto memoryPool = MemoryPool::systemCpuInaccessible;
|
||||
|
||||
if (bo == nullptr) {
|
||||
size_t size = SysCalls::lseek(handle, 0, SEEK_END);
|
||||
size_t size = SysCalls::lseek(osHandleData.handle, 0, SEEK_END);
|
||||
UNRECOVERABLE_IF(size == std::numeric_limits<size_t>::max());
|
||||
|
||||
auto patIndex = drm.getPatIndex(nullptr, properties.allocationType, CacheRegion::defaultRegion, CachePolicy::writeBack, false, MemoryPoolHelper::isSystemMemoryPool(memoryPool));
|
||||
@@ -1112,7 +1112,7 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o
|
||||
auto gmmHelper = getGmmHelper(properties.rootDeviceIndex);
|
||||
auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(reinterpret_cast<void *>(bo->peekAddress())));
|
||||
auto drmAllocation = new DrmAllocation(properties.rootDeviceIndex, 1u /*num gmms*/, properties.allocationType, bo, reinterpret_cast<void *>(bo->peekAddress()), bo->peekSize(),
|
||||
handle, memoryPool, canonizedGpuAddress);
|
||||
osHandleData.handle, memoryPool, canonizedGpuAddress);
|
||||
|
||||
if (requireSpecificBitness && this->force32bitAllocations) {
|
||||
drmAllocation->set32BitAllocation(true);
|
||||
|
||||
@@ -40,7 +40,7 @@ class DrmMemoryManager : public MemoryManager {
|
||||
void handleFenceCompletion(GraphicsAllocation *allocation) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromExistingStorage(AllocationProperties &properties, void *ptr, MultiGraphicsAllocation &multiGraphicsAllocation) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const 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;
|
||||
void closeSharedHandle(GraphicsAllocation *gfxAllocation) override;
|
||||
void closeInternalHandle(uint64_t &handle, uint32_t handleId, GraphicsAllocation *graphicsAllocation) override;
|
||||
|
||||
|
||||
@@ -828,10 +828,10 @@ bool Wddm::verifySharedHandle(D3DKMT_HANDLE osHandle) {
|
||||
return status == STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
bool Wddm::openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc) {
|
||||
bool Wddm::openSharedHandle(const MemoryManager::ExtendedOsHandleData &osHandleData, WddmAllocation *alloc) {
|
||||
D3DKMT_QUERYRESOURCEINFO queryResourceInfo = {};
|
||||
queryResourceInfo.hDevice = device;
|
||||
queryResourceInfo.hGlobalShare = handle;
|
||||
queryResourceInfo.hGlobalShare = osHandleData.handle;
|
||||
[[maybe_unused]] auto status = getGdi()->queryResourceInfo(&queryResourceInfo);
|
||||
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
|
||||
|
||||
@@ -847,7 +847,7 @@ bool Wddm::openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc) {
|
||||
D3DKMT_OPENRESOURCE openResource = {};
|
||||
|
||||
openResource.hDevice = device;
|
||||
openResource.hGlobalShare = handle;
|
||||
openResource.hGlobalShare = osHandleData.handle;
|
||||
openResource.NumAllocations = queryResourceInfo.NumAllocations;
|
||||
openResource.pOpenAllocationInfo2 = allocationInfo.get();
|
||||
openResource.pTotalPrivateDriverDataBuffer = allocPrivateData.get();
|
||||
|
||||
@@ -79,7 +79,7 @@ class Wddm : public DriverModel {
|
||||
MOCKABLE_VIRTUAL NTSTATUS createAllocationsAndMapGpuVa(OsHandleStorage &osHandles);
|
||||
MOCKABLE_VIRTUAL bool destroyAllocations(const D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle);
|
||||
MOCKABLE_VIRTUAL bool verifySharedHandle(D3DKMT_HANDLE osHandle);
|
||||
MOCKABLE_VIRTUAL bool openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc);
|
||||
MOCKABLE_VIRTUAL bool openSharedHandle(const MemoryManager::ExtendedOsHandleData &osHandleData, WddmAllocation *alloc);
|
||||
MOCKABLE_VIRTUAL bool verifyNTHandle(HANDLE handle);
|
||||
bool openNTHandle(HANDLE handle, WddmAllocation *alloc);
|
||||
MOCKABLE_VIRTUAL void *lockResource(const D3DKMT_HANDLE &handle, bool applyMakeResidentPriorToLock, size_t size);
|
||||
|
||||
@@ -599,11 +599,18 @@ bool WddmMemoryManager::isNTHandle(osHandle handle, uint32_t rootDeviceIndex) {
|
||||
return status;
|
||||
}
|
||||
|
||||
GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(osHandle handle, bool requireSpecificBitness, bool ntHandle, AllocationType allocationType, uint32_t rootDeviceIndex, void *mapPointer) {
|
||||
auto allocation = std::make_unique<WddmAllocation>(rootDeviceIndex, allocationType, nullptr, 0, handle, MemoryPool::systemCpuInaccessible, maxOsContextCount, 0llu);
|
||||
GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(const OsHandleData &osHandleData, bool requireSpecificBitness, bool ntHandle, AllocationType allocationType, uint32_t rootDeviceIndex, void *mapPointer) {
|
||||
auto allocation = std::make_unique<WddmAllocation>(rootDeviceIndex, allocationType, nullptr, 0, osHandleData.handle, MemoryPool::systemCpuInaccessible, maxOsContextCount, 0llu);
|
||||
|
||||
bool status = ntHandle ? getWddm(rootDeviceIndex).openNTHandle(reinterpret_cast<HANDLE>(static_cast<uintptr_t>(handle)), allocation.get())
|
||||
: getWddm(rootDeviceIndex).openSharedHandle(handle, allocation.get());
|
||||
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());
|
||||
} else {
|
||||
MemoryManager::ExtendedOsHandleData extendedOsHandleData{osHandleData.handle};
|
||||
status = getWddm(rootDeviceIndex).openSharedHandle(extendedOsHandleData, allocation.get());
|
||||
}
|
||||
|
||||
if (!status) {
|
||||
return nullptr;
|
||||
@@ -643,12 +650,13 @@ GraphicsAllocation *WddmMemoryManager::createGraphicsAllocationFromMultipleShare
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GraphicsAllocation *WddmMemoryManager::createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) {
|
||||
return createAllocationFromHandle(handle, requireSpecificBitness, false, properties.allocationType, properties.rootDeviceIndex, mapPointer);
|
||||
GraphicsAllocation *WddmMemoryManager::createGraphicsAllocationFromSharedHandle(const OsHandleData &osHandleData, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) {
|
||||
return createAllocationFromHandle(osHandleData, requireSpecificBitness, false, properties.allocationType, properties.rootDeviceIndex, mapPointer);
|
||||
}
|
||||
|
||||
GraphicsAllocation *WddmMemoryManager::createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) {
|
||||
return createAllocationFromHandle(toOsHandle(handle), false, true, allocType, rootDeviceIndex, nullptr);
|
||||
ExtendedOsHandleData osHandleData{handle};
|
||||
return createAllocationFromHandle(osHandleData, false, true, allocType, rootDeviceIndex, nullptr);
|
||||
}
|
||||
|
||||
void WddmMemoryManager::addAllocationToHostPtrManager(GraphicsAllocation *gfxAllocation) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -36,7 +36,7 @@ class WddmMemoryManager : public MemoryManager {
|
||||
void handleFenceCompletion(GraphicsAllocation *allocation) override;
|
||||
|
||||
GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const 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;
|
||||
|
||||
void addAllocationToHostPtrManager(GraphicsAllocation *memory) override;
|
||||
@@ -104,7 +104,7 @@ class WddmMemoryManager : public MemoryManager {
|
||||
MOCKABLE_VIRTUAL size_t getHugeGfxMemoryChunkSize(GfxMemoryAllocationMethod allocationMethod) const;
|
||||
MOCKABLE_VIRTUAL GraphicsAllocation *allocateHugeGraphicsMemory(const AllocationData &allocationData, bool sharedVirtualAddress);
|
||||
|
||||
GraphicsAllocation *createAllocationFromHandle(osHandle handle, bool requireSpecificBitness, bool ntHandle, AllocationType allocationType, uint32_t rootDeviceIndex, void *mapPointer);
|
||||
GraphicsAllocation *createAllocationFromHandle(const OsHandleData &osHandleData, bool requireSpecificBitness, bool ntHandle, AllocationType allocationType, uint32_t rootDeviceIndex, void *mapPointer);
|
||||
static bool validateAllocation(WddmAllocation *alloc);
|
||||
MOCKABLE_VIRTUAL bool createWddmAllocation(WddmAllocation *allocation, void *requiredGpuPtr);
|
||||
MOCKABLE_VIRTUAL bool mapGpuVirtualAddress(WddmAllocation *graphicsAllocation, const void *requiredGpuPtr);
|
||||
|
||||
Reference in New Issue
Block a user