mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
Refactor Wddm interface of mapping GPU VA
Change-Id: Ic807dfb17fd0ab664af281db757e48b0cc424fcb Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
16e1a05375
commit
8e743cc1bd
@@ -288,10 +288,9 @@ bool Wddm::makeResident(const D3DKMT_HANDLE *handles, uint32_t count, bool cantT
|
||||
return success;
|
||||
}
|
||||
|
||||
bool Wddm::mapGpuVirtualAddress(WddmAllocation *allocation, void *cpuPtr) {
|
||||
void *mapPtr = allocation->getReservedAddressPtr() != nullptr ? allocation->getReservedAddressPtr() : cpuPtr;
|
||||
return mapGpuVirtualAddressImpl(allocation->getDefaultGmm(), allocation->getDefaultHandle(), mapPtr, allocation->getGpuAddressToModify(),
|
||||
MemoryManager::selectHeap(allocation, mapPtr, *hardwareInfoTable[gfxPlatform->eProductFamily]));
|
||||
bool Wddm::mapGpuVirtualAddress(WddmAllocation *allocation, void *requiredGpuPtr) {
|
||||
return mapGpuVirtualAddressImpl(allocation->getDefaultGmm(), allocation->getDefaultHandle(), requiredGpuPtr, allocation->getGpuAddressToModify(),
|
||||
MemoryManager::selectHeap(allocation, requiredGpuPtr, *hardwareInfoTable[gfxPlatform->eProductFamily]));
|
||||
}
|
||||
|
||||
bool Wddm::mapGpuVirtualAddress(AllocationStorageData *allocationStorageData) {
|
||||
|
||||
@@ -58,7 +58,7 @@ class Wddm {
|
||||
|
||||
MOCKABLE_VIRTUAL bool evict(const D3DKMT_HANDLE *handleList, uint32_t numOfHandles, uint64_t &sizeToTrim);
|
||||
MOCKABLE_VIRTUAL bool makeResident(const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim);
|
||||
bool mapGpuVirtualAddress(WddmAllocation *allocation, void *cpuPtr);
|
||||
bool mapGpuVirtualAddress(WddmAllocation *allocation, void *requiredGpuPtr);
|
||||
bool mapGpuVirtualAddress(AllocationStorageData *allocationStorageData);
|
||||
D3DGPU_VIRTUAL_ADDRESS reserveGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS minimumAddress, D3DGPU_VIRTUAL_ADDRESS maximumAddress, D3DGPU_SIZE_T size);
|
||||
MOCKABLE_VIRTUAL bool createContext(OsContextWin &osContext);
|
||||
|
||||
@@ -50,7 +50,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForImageImpl(const
|
||||
|
||||
auto allocation = std::make_unique<WddmAllocation>(allocationData.type, nullptr, allocationData.imgInfo->size, nullptr, MemoryPool::SystemCpuInaccessible, false);
|
||||
allocation->setDefaultGmm(gmm.get());
|
||||
if (!createWddmAllocation(allocation.get())) {
|
||||
if (!createWddmAllocation(allocation.get(), nullptr)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryWithAlignment(const
|
||||
|
||||
wddmAllocation->setDefaultGmm(gmm);
|
||||
|
||||
if (!createWddmAllocation(wddmAllocation.get())) {
|
||||
if (!createWddmAllocation(wddmAllocation.get(), wddmAllocation->getAlignedCpuPtr())) {
|
||||
delete gmm;
|
||||
freeSystemMemory(pSysMem);
|
||||
return nullptr;
|
||||
@@ -124,7 +124,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForNonSvmHostPtr(co
|
||||
|
||||
wddmAllocation->setDefaultGmm(gmm);
|
||||
|
||||
if (!createWddmAllocation(wddmAllocation.get())) {
|
||||
if (!createWddmAllocation(wddmAllocation.get(), wddmAllocation->getAlignedCpuPtr())) {
|
||||
delete gmm;
|
||||
return nullptr;
|
||||
}
|
||||
@@ -156,7 +156,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryWithProperties(cons
|
||||
|
||||
Gmm *gmm = new Gmm(ptrAligned, sizeAligned, false);
|
||||
allocation->setDefaultGmm(gmm);
|
||||
if (createWddmAllocation(allocation)) {
|
||||
if (createWddmAllocation(allocation, reserve)) {
|
||||
DebugManager.logAllocation(allocation);
|
||||
return allocation;
|
||||
}
|
||||
@@ -198,7 +198,7 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemoryImpl(const All
|
||||
gmm = new Gmm(ptrAligned, sizeAligned, false);
|
||||
wddmAllocation->setDefaultGmm(gmm);
|
||||
|
||||
if (!createWddmAllocation(wddmAllocation.get())) {
|
||||
if (!createWddmAllocation(wddmAllocation.get(), wddmAllocation->getAlignedCpuPtr())) {
|
||||
delete gmm;
|
||||
freeSystemMemory(pSysMem);
|
||||
return nullptr;
|
||||
@@ -483,7 +483,7 @@ AlignedMallocRestrictions *WddmMemoryManager::getAlignedMallocRestrictions() {
|
||||
return &mallocRestrictions;
|
||||
}
|
||||
|
||||
bool WddmMemoryManager::createWddmAllocation(WddmAllocation *allocation) {
|
||||
bool WddmMemoryManager::createWddmAllocation(WddmAllocation *allocation, void *requiredGpuPtr) {
|
||||
auto wddmSuccess = wddm->createAllocation(allocation->getAlignedCpuPtr(), allocation->getDefaultGmm(), allocation->getHandleToModify(0u));
|
||||
if (wddmSuccess == STATUS_GRAPHICS_NO_VIDEO_MEMORY && deferredDeleter) {
|
||||
deferredDeleter->drain(true);
|
||||
@@ -491,10 +491,10 @@ bool WddmMemoryManager::createWddmAllocation(WddmAllocation *allocation) {
|
||||
}
|
||||
|
||||
if (wddmSuccess == STATUS_SUCCESS) {
|
||||
bool mapSuccess = wddm->mapGpuVirtualAddress(allocation, allocation->getAlignedCpuPtr());
|
||||
bool mapSuccess = wddm->mapGpuVirtualAddress(allocation, requiredGpuPtr);
|
||||
if (!mapSuccess && deferredDeleter) {
|
||||
deferredDeleter->drain(true);
|
||||
mapSuccess = wddm->mapGpuVirtualAddress(allocation, allocation->getAlignedCpuPtr());
|
||||
mapSuccess = wddm->mapGpuVirtualAddress(allocation, requiredGpuPtr);
|
||||
}
|
||||
if (!mapSuccess) {
|
||||
wddm->destroyAllocations(allocation->getHandles().data(), allocation->getNumHandles(), allocation->resourceHandle);
|
||||
|
||||
@@ -82,7 +82,7 @@ class WddmMemoryManager : public MemoryManager {
|
||||
|
||||
GraphicsAllocation *createAllocationFromHandle(osHandle handle, bool requireSpecificBitness, bool ntHandle);
|
||||
static bool validateAllocation(WddmAllocation *alloc);
|
||||
bool createWddmAllocation(WddmAllocation *allocation);
|
||||
bool createWddmAllocation(WddmAllocation *allocation, void *requiredGpuPtr);
|
||||
AlignedMallocRestrictions mallocRestrictions;
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user