Ensure that allocations in 4GB heap have non 0 GPU address to patch.

- That address is used later to deduce that allocation is non null
- If we have address 0 it is incorrectly detected as null ptr on the GPU.

Change-Id: I45e1bb31f1788528327da35bfdcc13f3fa6beec2
This commit is contained in:
Mrozek, Michal 2018-12-05 16:19:12 +01:00 committed by sys_ocldev
parent bb7f8d9b88
commit 2ca3e4c4e5
2 changed files with 9 additions and 1 deletions

View File

@ -349,7 +349,7 @@ bool Wddm::mapGpuVirtualAddressImpl(Gmm *gmm, D3DKMT_HANDLE handle, void *cpuPtr
}
if (allocation32bit) {
MapGPUVA.MinimumAddress = gfxPartition.Heap32[3].Base;
MapGPUVA.MinimumAddress = gfxPartition.Heap32[3].Base + MemoryConstants::pageSize;
MapGPUVA.MaximumAddress = gfxPartition.Heap32[3].Limit;
MapGPUVA.BaseAddress = 0;
}

View File

@ -706,6 +706,14 @@ TEST_F(WddmMemoryManagerTest, Allocate32BitMemoryWithNullptr) {
memoryManager->freeGraphicsMemory(gpuAllocation);
}
TEST_F(WddmMemoryManagerTest, given32BitAllocationWhenItIsCreatedThenItHasNonZeroGpuAddressToPatch) {
auto *gpuAllocation = memoryManager->allocate32BitGraphicsMemory(3 * MemoryConstants::pageSize, nullptr, AllocationOrigin::EXTERNAL_ALLOCATION);
ASSERT_NE(nullptr, gpuAllocation);
EXPECT_NE(0llu, gpuAllocation->getGpuAddressToPatch());
memoryManager->freeGraphicsMemory(gpuAllocation);
}
TEST_F(WddmMemoryManagerTest, Allocate32BitMemoryWithMisalignedHostPtrDoesNotDoTripleAlloc) {
size_t misalignedSize = 0x2500;
void *misalignedPtr = reinterpret_cast<void *>(0x12500);