Refactor Graphics Allocation paths for Images

Change-Id: Ifa3084b18cac95289bbceeaf3669dd31567fbd3e
This commit is contained in:
Hoppe, Mateusz
2018-12-14 11:24:45 +01:00
committed by sys_ocldev
parent 3dca095ccf
commit f6790c42cf
20 changed files with 452 additions and 82 deletions

View File

@@ -40,17 +40,26 @@ WddmMemoryManager::WddmMemoryManager(bool enable64kbPages, bool enableLocalMemor
mallocRestrictions.minAddress = wddm->getWddmMinAddress();
}
GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForImage(ImageInfo &imgInfo, Gmm *gmm) {
GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForImage(ImageInfo &imgInfo, const void *hostPtr) {
auto gmm = std::make_unique<Gmm>(imgInfo);
auto hostPtrAllocation = allocateGraphicsMemoryForImageFromHostPtr(imgInfo, hostPtr);
if (hostPtrAllocation) {
hostPtrAllocation->gmm = gmm.release();
return hostPtrAllocation;
}
if (!GmmHelper::allowTiling(*imgInfo.imgDesc) && imgInfo.mipCount == 0) {
delete gmm;
return allocateGraphicsMemoryWithProperties({imgInfo.size, GraphicsAllocation::AllocationType::UNDECIDED});
}
auto allocation = std::make_unique<WddmAllocation>(nullptr, imgInfo.size, nullptr, MemoryPool::SystemCpuInaccessible, getOsContextCount(), false);
allocation->gmm = gmm;
allocation->gmm = gmm.get();
if (!WddmMemoryManager::createWddmAllocation(allocation.get(), AllocationOrigin::EXTERNAL_ALLOCATION)) {
return nullptr;
}
gmm.release();
return allocation.release();
}

View File

@@ -39,7 +39,7 @@ class WddmMemoryManager : public MemoryManager {
GraphicsAllocation *allocate32BitGraphicsMemory(size_t size, const void *ptr, AllocationOrigin allocationOrigin) override;
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, bool requireSpecificBitness) override;
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle) override;
GraphicsAllocation *allocateGraphicsMemoryForImage(ImageInfo &imgInfo, Gmm *gmm) override;
GraphicsAllocation *allocateGraphicsMemoryForImage(ImageInfo &imgInfo, const void *hostPtr) override;
GraphicsAllocation *allocateGraphicsMemoryInDevicePool(const AllocationData &allocationData, AllocationStatus &status) override;
void addAllocationToHostPtrManager(GraphicsAllocation *memory) override;