Add support for reduced GPU address space

Change-Id: I9ebbc8c51039bb533b44c6b80e717e1489a20a43
Signed-off-by: Pawel Wilma <pawel.wilma@intel.com>
This commit is contained in:
Pawel Wilma
2018-08-24 15:23:45 +02:00
committed by sys_ocldev
parent f6743ced2a
commit 4a12deea2b
44 changed files with 473 additions and 270 deletions

View File

@@ -336,6 +336,9 @@ bool Wddm::mapGpuVirtualAddressImpl(Gmm *gmm, D3DKMT_HANDLE handle, void *cpuPtr
MapGPUVA.SizeInPages = size / MemoryConstants::pageSize;
MapGPUVA.OffsetInPages = 0;
auto productFamily = gfxPlatform->eProductFamily;
UNRECOVERABLE_IF(!hardwareInfoTable[productFamily]);
if (useHeap1) {
MapGPUVA.MinimumAddress = gfxPartition.Heap32[1].Base;
MapGPUVA.MaximumAddress = gfxPartition.Heap32[1].Limit;
@@ -344,14 +347,21 @@ bool Wddm::mapGpuVirtualAddressImpl(Gmm *gmm, D3DKMT_HANDLE handle, void *cpuPtr
MapGPUVA.MinimumAddress = gfxPartition.Standard64KB.Base;
MapGPUVA.MaximumAddress = gfxPartition.Standard64KB.Limit;
} else {
MapGPUVA.BaseAddress = reinterpret_cast<D3DGPU_VIRTUAL_ADDRESS>(cpuPtr);
MapGPUVA.MinimumAddress = static_cast<D3DGPU_VIRTUAL_ADDRESS>(0x0);
MapGPUVA.MaximumAddress = static_cast<D3DGPU_VIRTUAL_ADDRESS>((sizeof(size_t) == 8) ? 0x7fffffffffff : (D3DGPU_VIRTUAL_ADDRESS)0xffffffff);
if (!cpuPtr) {
MapGPUVA.MinimumAddress = gfxPartition.Standard.Base;
MapGPUVA.MaximumAddress = gfxPartition.Standard.Limit;
if (hardwareInfoTable[productFamily]->capabilityTable.gpuAddressSpace == MemoryConstants::max48BitAddress) {
MapGPUVA.BaseAddress = reinterpret_cast<D3DGPU_VIRTUAL_ADDRESS>(cpuPtr);
MapGPUVA.MinimumAddress = static_cast<D3DGPU_VIRTUAL_ADDRESS>(0x0);
MapGPUVA.MaximumAddress =
static_cast<D3DGPU_VIRTUAL_ADDRESS>((sizeof(size_t) == 8) ? 0x7fffffffffff : (D3DGPU_VIRTUAL_ADDRESS)0xffffffff);
if (!cpuPtr) {
MapGPUVA.MinimumAddress = gfxPartition.Standard.Base;
MapGPUVA.MaximumAddress = gfxPartition.Standard.Limit;
}
} else {
MapGPUVA.BaseAddress = 0;
MapGPUVA.MinimumAddress = 0x0;
MapGPUVA.MaximumAddress = hardwareInfoTable[productFamily]->capabilityTable.gpuAddressSpace;
}
if (allocation32bit) {
MapGPUVA.MinimumAddress = gfxPartition.Heap32[0].Base;
MapGPUVA.MaximumAddress = gfxPartition.Heap32[0].Limit;
@@ -891,11 +901,15 @@ bool Wddm::configureDeviceAddressSpace() {
SYSTEM_INFO sysInfo;
Wddm::getSystemInfo(&sysInfo);
maximumApplicationAddress = reinterpret_cast<uintptr_t>(sysInfo.lpMaximumApplicationAddress);
auto productFamily = gfxPlatform->eProductFamily;
if (!hardwareInfoTable[productFamily]) {
return false;
}
auto svmSize = hardwareInfoTable[productFamily]->capabilityTable.gpuAddressSpace == MemoryConstants::max48BitAddress
? maximumApplicationAddress + 1u
: 0u;
return gmmMemory->configureDevice(adapter, device, gdi->escape,
maximumApplicationAddress + 1u,
featureTable->ftrL3IACoherency,
gfxPartition, minAddress);
return gmmMemory->configureDevice(adapter, device, gdi->escape, svmSize, featureTable->ftrL3IACoherency, gfxPartition, minAddress);
}
bool Wddm::init() {

View File

@@ -129,6 +129,26 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory(size_t size, size_
return wddmAllocation;
}
GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForNonSvmHostPtr(size_t size, void *cpuPtr) {
auto alignedPtr = alignDown(reinterpret_cast<char *>(cpuPtr), MemoryConstants::pageSize);
auto offsetInPage = reinterpret_cast<char *>(cpuPtr) - alignedPtr;
auto alignedSize = alignSizeWholePage(cpuPtr, size);
auto wddmAllocation = new WddmAllocation(cpuPtr, size, alignedPtr, alignedSize, nullptr, MemoryPool::System4KBPages);
wddmAllocation->allocationOffset = offsetInPage;
auto gmm = new Gmm(alignedPtr, alignedSize, false);
wddmAllocation->gmm = gmm;
if (!createWddmAllocation(wddmAllocation, AllocationOrigin::EXTERNAL_ALLOCATION)) {
delete gmm;
delete wddmAllocation;
return nullptr;
}
return wddmAllocation;
}
GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory(size_t size, const void *ptrArg) {
void *ptr = const_cast<void *>(ptrArg);

View File

@@ -52,6 +52,7 @@ class WddmMemoryManager : public MemoryManager {
GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin, bool preferRenderCompressed) override;
GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) override;
GraphicsAllocation *allocateGraphicsMemory(size_t size, const void *ptr) override;
GraphicsAllocation *allocateGraphicsMemoryForNonSvmHostPtr(size_t size, void *cpuPtr) override;
GraphicsAllocation *allocate32BitGraphicsMemory(size_t size, const void *ptr, AllocationOrigin allocationOrigin) override;
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, bool requireSpecificBitness) override;
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle) override;