Wddm: Use GMM allocation size during map GPU VA

Change-Id: Ie10898db7c539ce5025ab4a6d658d6e593e94c50
This commit is contained in:
Dunajski, Bartosz
2018-07-12 15:42:46 +02:00
committed by sys_ocldev
parent c19918920d
commit a8ce3ca00a
9 changed files with 48 additions and 27 deletions

View File

@@ -344,26 +344,27 @@ bool Wddm::makeResident(D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFur
return success;
}
bool Wddm::mapGpuVirtualAddress(WddmAllocation *allocation, void *cpuPtr, uint64_t size, bool allocation32bit, bool use64kbPages, bool useHeap1) {
bool Wddm::mapGpuVirtualAddress(WddmAllocation *allocation, void *cpuPtr, bool allocation32bit, bool use64kbPages, bool useHeap1) {
void *mapPtr = allocation->getReservedAddress() != nullptr ? allocation->getReservedAddress() : cpuPtr;
return mapGpuVirtualAddressImpl(allocation->gmm, allocation->handle, mapPtr, size, allocation->gpuPtr, allocation32bit, use64kbPages, useHeap1);
return mapGpuVirtualAddressImpl(allocation->gmm, allocation->handle, mapPtr, allocation->gpuPtr, allocation32bit, use64kbPages, useHeap1);
}
bool Wddm::mapGpuVirtualAddress(AllocationStorageData *allocationStorageData, bool allocation32bit, bool use64kbPages) {
return mapGpuVirtualAddressImpl(allocationStorageData->osHandleStorage->gmm,
allocationStorageData->osHandleStorage->handle,
const_cast<void *>(allocationStorageData->cpuPtr),
allocationStorageData->fragmentSize,
allocationStorageData->osHandleStorage->gpuPtr,
allocation32bit, use64kbPages, false);
}
bool Wddm::mapGpuVirtualAddressImpl(Gmm *gmm, D3DKMT_HANDLE handle, void *cpuPtr, uint64_t size, D3DGPU_VIRTUAL_ADDRESS &gpuPtr, bool allocation32bit, bool use64kbPages, bool useHeap1) {
bool Wddm::mapGpuVirtualAddressImpl(Gmm *gmm, D3DKMT_HANDLE handle, void *cpuPtr, D3DGPU_VIRTUAL_ADDRESS &gpuPtr, bool allocation32bit, bool use64kbPages, bool useHeap1) {
NTSTATUS status = STATUS_SUCCESS;
D3DDDI_MAPGPUVIRTUALADDRESS MapGPUVA = {0};
D3DDDIGPUVIRTUALADDRESS_PROTECTION_TYPE protectionType = {{{0}}};
protectionType.Write = TRUE;
uint64_t size = static_cast<uint64_t>(gmm->gmmResourceInfo->getSizeAllocation());
MapGPUVA.hPagingQueue = pagingQueue;
MapGPUVA.hAllocation = handle;
MapGPUVA.Protection = protectionType;

View File

@@ -68,7 +68,7 @@ class Wddm {
MOCKABLE_VIRTUAL bool evict(D3DKMT_HANDLE *handleList, uint32_t numOfHandles, uint64_t &sizeToTrim);
MOCKABLE_VIRTUAL bool makeResident(D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim);
bool mapGpuVirtualAddress(WddmAllocation *allocation, void *cpuPtr, uint64_t size, bool allocation32bit, bool use64kbPages, bool useHeap1);
bool mapGpuVirtualAddress(WddmAllocation *allocation, void *cpuPtr, bool allocation32bit, bool use64kbPages, bool useHeap1);
bool mapGpuVirtualAddress(AllocationStorageData *allocationStorageData, bool allocation32bit, bool use64kbPages);
MOCKABLE_VIRTUAL bool createContext();
virtual bool createHwQueue() { return false; }
@@ -200,7 +200,7 @@ class Wddm {
uintptr_t minAddress;
Wddm();
MOCKABLE_VIRTUAL bool mapGpuVirtualAddressImpl(Gmm *gmm, D3DKMT_HANDLE handle, void *cpuPtr, uint64_t size, D3DGPU_VIRTUAL_ADDRESS &gpuPtr, bool allocation32bit, bool use64kbPages, bool useHeap1);
MOCKABLE_VIRTUAL bool mapGpuVirtualAddressImpl(Gmm *gmm, D3DKMT_HANDLE handle, void *cpuPtr, D3DGPU_VIRTUAL_ADDRESS &gpuPtr, bool allocation32bit, bool use64kbPages, bool useHeap1);
MOCKABLE_VIRTUAL bool openAdapter();
bool createDevice();
bool createPagingQueue();

View File

@@ -95,7 +95,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory64kb(size_t size, s
wddmAllocation->setAlignedCpuPtr(cpuPtr);
// 64kb map is not needed
auto status = wddm->mapGpuVirtualAddress(wddmAllocation, cpuPtr, sizeAligned, false, false, false);
auto status = wddm->mapGpuVirtualAddress(wddmAllocation, cpuPtr, false, false, false);
DEBUG_BREAK_IF(!status);
wddmAllocation->setCpuPtrAndGpuAddress(cpuPtr, (uint64_t)wddmAllocation->gpuPtr);
@@ -234,7 +234,7 @@ GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(osHandle handl
allocation->is32BitAllocation = true;
allocation->gpuBaseAddress = GmmHelper::canonize(allocator32Bit->getBase());
}
status = wddm->mapGpuVirtualAddress(allocation, ptr, size, is32BitAllocation, false, false);
status = wddm->mapGpuVirtualAddress(allocation, ptr, is32BitAllocation, false, false);
DEBUG_BREAK_IF(!status);
allocation->setGpuAddress(allocation->gpuPtr);
@@ -812,10 +812,10 @@ bool WddmMemoryManager::createWddmAllocation(WddmAllocation *allocation, Allocat
wddmSuccess = wddm->createAllocation(allocation);
}
if (wddmSuccess == STATUS_SUCCESS) {
bool mapSuccess = wddm->mapGpuVirtualAddress(allocation, allocation->getAlignedCpuPtr(), allocation->getAlignedSize(), allocation->is32BitAllocation, false, useHeap1);
bool mapSuccess = wddm->mapGpuVirtualAddress(allocation, allocation->getAlignedCpuPtr(), allocation->is32BitAllocation, false, useHeap1);
if (!mapSuccess && deferredDeleter) {
deferredDeleter->drain(true);
mapSuccess = wddm->mapGpuVirtualAddress(allocation, allocation->getAlignedCpuPtr(), allocation->getAlignedSize(), allocation->is32BitAllocation, false, useHeap1);
mapSuccess = wddm->mapGpuVirtualAddress(allocation, allocation->getAlignedCpuPtr(), allocation->is32BitAllocation, false, useHeap1);
}
if (!mapSuccess) {
wddm->destroyAllocations(&allocation->handle, 1, 0, allocation->resourceHandle);