Simplify selecting heap in Wddm::mapGpuVirtualAddressImpl method

Change-Id: Id6eb5b0df1c705b5fadde62d20513fe15edf1e27
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2019-01-28 18:12:39 +01:00
committed by sys_ocldev
parent 2e5e785092
commit c04ba163a0
12 changed files with 181 additions and 102 deletions

View File

@@ -24,6 +24,11 @@ namespace OCLRT {
using osHandle = unsigned int;
using DevicesBitfield = uint32_t;
enum class AllocationOrigin {
EXTERNAL_ALLOCATION,
INTERNAL_ALLOCATION
};
namespace Sharing {
constexpr auto nonSharedResource = 0u;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -13,6 +13,12 @@
constexpr bool is32bit = (sizeof(void *) == 4);
constexpr bool is64bit = (sizeof(void *) == 8);
template <uint8_t N>
constexpr uint64_t maxNBitValue = ((1ULL << N) - 1);
static_assert(maxNBitValue<8> == std::numeric_limits<uint8_t>::max(), "");
static_assert(maxNBitValue<16> == std::numeric_limits<uint16_t>::max(), "");
static_assert(maxNBitValue<32> == std::numeric_limits<uint32_t>::max(), "");
namespace MemoryConstants {
static const uint64_t zoneHigh = ~(uint64_t)0xFFFFFFFF;
static const uint64_t kiloByte = 1024;
@@ -29,11 +35,11 @@ static const size_t slmWindowAlignment = 128 * kiloByte;
static const size_t slmWindowSize = 64 * kiloByte;
static const uintptr_t pageMask = (pageSize - 1);
static const uintptr_t page64kMask = (pageSize64k - 1);
static const uint64_t max32BitAppAddress = ((1ULL << 31) - 1);
static const uint64_t max64BitAppAddress = ((1ULL << 47) - 1);
static const uint64_t max32BitAppAddress = maxNBitValue<31>;
static const uint64_t max64BitAppAddress = maxNBitValue<47>;
static const uint32_t sizeOf4GBinPageEntities = (MemoryConstants::gigaByte * 4 - MemoryConstants::pageSize) / MemoryConstants::pageSize;
static const uint64_t max32BitAddress = ((1ULL << 32) - 1);
static const uint64_t max48BitAddress = ((1ULL << 48) - 1);
static const uint64_t max32BitAddress = maxNBitValue<32>;
static const uint64_t max48BitAddress = maxNBitValue<48>;
static const uintptr_t page4kEntryMask = std::numeric_limits<uintptr_t>::max() & ~MemoryConstants::pageMask;
static const uintptr_t page64kEntryMask = std::numeric_limits<uintptr_t>::max() & ~MemoryConstants::page64kMask;
static const int GfxAddressBits = is64bit ? 48 : 32;

View File

@@ -36,11 +36,6 @@ enum AllocationUsage {
REUSABLE_ALLOCATION
};
enum class AllocationOrigin {
EXTERNAL_ALLOCATION,
INTERNAL_ALLOCATION
};
struct AllocationProperties {
union {
struct {

View File

@@ -286,20 +286,21 @@ bool Wddm::makeResident(D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFur
return success;
}
bool Wddm::mapGpuVirtualAddress(WddmAllocation *allocation, void *cpuPtr, bool allocation32bit, bool use64kbPages, bool useHeap1) {
bool Wddm::mapGpuVirtualAddress(WddmAllocation *allocation, void *cpuPtr) {
void *mapPtr = allocation->getReservedAddress() != nullptr ? allocation->getReservedAddress() : cpuPtr;
return mapGpuVirtualAddressImpl(allocation->gmm, allocation->handle, mapPtr, allocation->gpuPtr, allocation32bit, use64kbPages, useHeap1);
return mapGpuVirtualAddressImpl(allocation->gmm, allocation->handle, mapPtr, allocation->gpuPtr,
selectHeap(allocation, mapPtr));
}
bool Wddm::mapGpuVirtualAddress(AllocationStorageData *allocationStorageData, bool allocation32bit, bool use64kbPages) {
bool Wddm::mapGpuVirtualAddress(AllocationStorageData *allocationStorageData) {
return mapGpuVirtualAddressImpl(allocationStorageData->osHandleStorage->gmm,
allocationStorageData->osHandleStorage->handle,
const_cast<void *>(allocationStorageData->cpuPtr),
allocationStorageData->osHandleStorage->gpuPtr,
allocation32bit, use64kbPages, false);
selectHeap(nullptr, allocationStorageData->cpuPtr));
}
bool Wddm::mapGpuVirtualAddressImpl(Gmm *gmm, D3DKMT_HANDLE handle, void *cpuPtr, D3DGPU_VIRTUAL_ADDRESS &gpuPtr, bool allocation32bit, bool use64kbPages, bool useHeap1) {
bool Wddm::mapGpuVirtualAddressImpl(Gmm *gmm, D3DKMT_HANDLE handle, void *cpuPtr, D3DGPU_VIRTUAL_ADDRESS &gpuPtr, HeapIndex heapIndex) {
NTSTATUS status = STATUS_SUCCESS;
D3DDDI_MAPGPUVIRTUALADDRESS MapGPUVA = {0};
D3DDDIGPUVIRTUALADDRESS_PROTECTION_TYPE protectionType = {{{0}}};
@@ -316,35 +317,37 @@ bool Wddm::mapGpuVirtualAddressImpl(Gmm *gmm, D3DKMT_HANDLE handle, void *cpuPtr
auto productFamily = gfxPlatform->eProductFamily;
UNRECOVERABLE_IF(!hardwareInfoTable[productFamily]);
if (useHeap1) {
MapGPUVA.MinimumAddress = gfxPartition.Heap32[1].Base;
MapGPUVA.MaximumAddress = gfxPartition.Heap32[1].Limit;
MapGPUVA.BaseAddress = 0;
} else if (use64kbPages) {
MapGPUVA.BaseAddress = 0;
MapGPUVA.MinimumAddress = 0;
switch (heapIndex) {
case HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY:
case HeapIndex::HEAP_INTERNAL:
case HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY:
case HeapIndex::HEAP_EXTERNAL:
MapGPUVA.MinimumAddress = gfxPartition.Heap32[static_cast<uint32_t>(heapIndex)].Base + MemoryConstants::pageSize;
MapGPUVA.MaximumAddress = gfxPartition.Heap32[static_cast<uint32_t>(heapIndex)].Limit;
break;
case HeapIndex::HEAP_STANDARD:
UNRECOVERABLE_IF(hardwareInfoTable[productFamily]->capabilityTable.gpuAddressSpace != MemoryConstants::max48BitAddress);
MapGPUVA.MinimumAddress = gfxPartition.Standard.Base;
MapGPUVA.MaximumAddress = gfxPartition.Standard.Limit;
break;
case HeapIndex::HEAP_STANDARD64Kb:
UNRECOVERABLE_IF(hardwareInfoTable[productFamily]->capabilityTable.gpuAddressSpace != MemoryConstants::max48BitAddress);
MapGPUVA.MinimumAddress = gfxPartition.Standard64KB.Base;
MapGPUVA.MaximumAddress = gfxPartition.Standard64KB.Limit;
} else {
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[3].Base + MemoryConstants::pageSize;
MapGPUVA.MaximumAddress = gfxPartition.Heap32[3].Limit;
MapGPUVA.BaseAddress = 0;
}
}
break;
case HeapIndex::HEAP_SVM:
UNRECOVERABLE_IF(hardwareInfoTable[productFamily]->capabilityTable.gpuAddressSpace != MemoryConstants::max48BitAddress);
UNRECOVERABLE_IF(!cpuPtr);
MapGPUVA.BaseAddress = reinterpret_cast<D3DGPU_VIRTUAL_ADDRESS>(cpuPtr);
MapGPUVA.MaximumAddress = is64bit ? maxNBitValue<47> : maxNBitValue<32>;
break;
case HeapIndex::HEAP_LIMITED:
UNRECOVERABLE_IF(hardwareInfoTable[productFamily]->capabilityTable.gpuAddressSpace == MemoryConstants::max48BitAddress);
MapGPUVA.MaximumAddress = hardwareInfoTable[productFamily]->capabilityTable.gpuAddressSpace;
break;
};
status = gdi->mapGpuVirtualAddress(&MapGPUVA);
gpuPtr = GmmHelper::canonize(MapGPUVA.VirtualAddress);
@@ -509,7 +512,7 @@ NTSTATUS Wddm::createAllocationsAndMapGpuVa(OsHandleStorage &osHandles) {
allocationIndex++;
}
osHandles.fragmentStorageData[allocationIndex].osHandleStorage->handle = AllocationInfo[i].hAllocation;
bool success = mapGpuVirtualAddress(&osHandles.fragmentStorageData[allocationIndex], false, false);
bool success = mapGpuVirtualAddress(&osHandles.fragmentStorageData[allocationIndex]);
allocationIndex++;
if (!success) {
@@ -800,12 +803,12 @@ PFND3DKMT_ESCAPE Wddm::getEscapeHandle() const {
return gdi->escape;
}
uint64_t Wddm::getHeap32Base() {
return alignUp(gfxPartition.Heap32[3].Base, MemoryConstants::pageSize);
uint64_t Wddm::getExternalHeapBase() const {
return alignUp(gfxPartition.Heap32[static_cast<uint32_t>(HeapIndex::HEAP_EXTERNAL)].Base, MemoryConstants::pageSize);
}
uint64_t Wddm::getHeap32Size() {
return alignDown(gfxPartition.Heap32[3].Limit, MemoryConstants::pageSize);
uint64_t Wddm::getExternalHeapSize() const {
return alignDown(gfxPartition.Heap32[static_cast<uint32_t>(HeapIndex::HEAP_EXTERNAL)].Limit, MemoryConstants::pageSize);
}
VOID *Wddm::registerTrimCallback(PFND3DKMT_TRIMNOTIFICATIONCALLBACK callback, WddmResidencyController &residencyController) {
@@ -993,4 +996,21 @@ std::unique_lock<SpinLock> Wddm::acquireLock(SpinLock &lock) {
return std::unique_lock<SpinLock>{lock};
}
HeapIndex Wddm::selectHeap(const WddmAllocation *allocation, const void *ptr) const {
if (allocation) {
if (allocation->origin == AllocationOrigin::INTERNAL_ALLOCATION) {
return HeapIndex::HEAP_INTERNAL;
} else if (allocation->is32BitAllocation) {
return HeapIndex::HEAP_EXTERNAL;
}
}
if (hardwareInfoTable[gfxPlatform->eProductFamily]->capabilityTable.gpuAddressSpace == MemoryConstants::max48BitAddress) {
if (ptr) {
return HeapIndex::HEAP_SVM;
}
return HeapIndex::HEAP_STANDARD;
}
return HeapIndex::HEAP_LIMITED;
}
} // namespace OCLRT

View File

@@ -41,6 +41,17 @@ enum class EvictionStatus {
UNKNOWN
};
enum class HeapIndex : uint32_t {
HEAP_INTERNAL_DEVICE_MEMORY = 0u,
HEAP_INTERNAL = 1u,
HEAP_EXTERNAL_DEVICE_MEMORY = 2u,
HEAP_EXTERNAL = 3u,
HEAP_STANDARD,
HEAP_STANDARD64Kb,
HEAP_SVM,
HEAP_LIMITED
};
class Wddm {
public:
typedef HRESULT(WINAPI *CreateDXGIFactoryFcn)(REFIID riid, void **ppFactory);
@@ -55,8 +66,8 @@ 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, bool allocation32bit, bool use64kbPages, bool useHeap1);
bool mapGpuVirtualAddress(AllocationStorageData *allocationStorageData, bool allocation32bit, bool use64kbPages);
bool mapGpuVirtualAddress(WddmAllocation *allocation, void *cpuPtr);
bool mapGpuVirtualAddress(AllocationStorageData *allocationStorageData);
MOCKABLE_VIRTUAL bool createContext(D3DKMT_HANDLE &context, EngineInstanceT engineType, PreemptionMode preemptionMode);
MOCKABLE_VIRTUAL void applyAdditionalContextFlags(CREATECONTEXT_PVTDATA &privateData);
MOCKABLE_VIRTUAL bool freeGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t size);
@@ -123,8 +134,8 @@ class Wddm {
return static_cast<uint32_t>(hwContextId);
}
uint64_t getHeap32Base();
uint64_t getHeap32Size();
uint64_t getExternalHeapBase() const;
uint64_t getExternalHeapSize() const;
std::unique_ptr<SettingsReader> registryReader;
@@ -147,6 +158,7 @@ class Wddm {
MOCKABLE_VIRTUAL EvictionStatus evictTemporaryResource(WddmAllocation &allocation);
MOCKABLE_VIRTUAL void applyBlockingMakeResident(WddmAllocation &allocation);
MOCKABLE_VIRTUAL std::unique_lock<SpinLock> acquireLock(SpinLock &lock);
HeapIndex selectHeap(const WddmAllocation *allocation, const void *cpuPtr) const;
protected:
bool initialized = false;
@@ -177,7 +189,7 @@ class Wddm {
uintptr_t minAddress = 0;
Wddm();
MOCKABLE_VIRTUAL bool mapGpuVirtualAddressImpl(Gmm *gmm, D3DKMT_HANDLE handle, void *cpuPtr, 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, HeapIndex heapIndex);
MOCKABLE_VIRTUAL bool openAdapter();
MOCKABLE_VIRTUAL bool waitOnGPU(D3DKMT_HANDLE context);
bool createDevice(PreemptionMode preemptionMode);

View File

@@ -81,6 +81,7 @@ class WddmAllocation : public GraphicsAllocation {
}
void setGpuAddress(uint64_t graphicsAddress) { this->gpuAddress = graphicsAddress; }
bool needsMakeResidentBeforeLock = false;
AllocationOrigin origin = AllocationOrigin::EXTERNAL_ALLOCATION;
std::string getAllocationInfoString() const {
std::stringstream ss;

View File

@@ -33,7 +33,7 @@ WddmMemoryManager::~WddmMemoryManager() {
WddmMemoryManager::WddmMemoryManager(bool enable64kbPages, bool enableLocalMemory, Wddm *wddm, ExecutionEnvironment &executionEnvironment) : MemoryManager(enable64kbPages, enableLocalMemory, executionEnvironment) {
DEBUG_BREAK_IF(wddm == nullptr);
this->wddm = wddm;
allocator32Bit = std::unique_ptr<Allocator32bit>(new Allocator32bit(wddm->getHeap32Base(), wddm->getHeap32Size()));
allocator32Bit = std::unique_ptr<Allocator32bit>(new Allocator32bit(wddm->getExternalHeapBase(), wddm->getExternalHeapSize()));
asyncDeleterEnabled = DebugManager.flags.EnableDeferredDeleter.get();
if (asyncDeleterEnabled)
deferredDeleter = createDeferredDeleter();
@@ -75,7 +75,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory64kb(AllocationData
auto cpuPtr = lockResource(wddmAllocation.get());
// 64kb map is not needed
auto status = wddm->mapGpuVirtualAddress(wddmAllocation.get(), cpuPtr, false, false, false);
auto status = wddm->mapGpuVirtualAddress(wddmAllocation.get(), cpuPtr);
DEBUG_BREAK_IF(!status);
wddmAllocation->setCpuPtrAndGpuAddress(cpuPtr, (uint64_t)wddmAllocation->gpuPtr);
@@ -212,7 +212,6 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemoryImpl(const All
GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(osHandle handle, bool requireSpecificBitness, bool ntHandle) {
auto allocation = std::make_unique<WddmAllocation>(nullptr, 0, handle, MemoryPool::SystemCpuInaccessible, getOsContextCount(), false);
bool is32BitAllocation = false;
bool status = ntHandle ? wddm->openNTHandle((HANDLE)((UINT_PTR)handle), allocation.get())
: wddm->openSharedHandle(handle, allocation.get());
@@ -232,11 +231,10 @@ GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(osHandle handl
}
allocation->setReservedAddress(ptr);
} else if (requireSpecificBitness && this->force32bitAllocations) {
is32BitAllocation = true;
allocation->is32BitAllocation = true;
allocation->gpuBaseAddress = GmmHelper::canonize(allocator32Bit->getBase());
}
status = wddm->mapGpuVirtualAddress(allocation.get(), ptr, is32BitAllocation, false, false);
status = wddm->mapGpuVirtualAddress(allocation.get(), ptr);
DEBUG_BREAK_IF(!status);
allocation->setGpuAddress(allocation->gpuPtr);
@@ -464,17 +462,18 @@ AlignedMallocRestrictions *WddmMemoryManager::getAlignedMallocRestrictions() {
}
bool WddmMemoryManager::createWddmAllocation(WddmAllocation *allocation, AllocationOrigin allocationOrigin) {
bool useHeap1 = (allocationOrigin == AllocationOrigin::INTERNAL_ALLOCATION);
auto wddmSuccess = wddm->createAllocation(allocation);
if (wddmSuccess == STATUS_GRAPHICS_NO_VIDEO_MEMORY && deferredDeleter) {
deferredDeleter->drain(true);
wddmSuccess = wddm->createAllocation(allocation);
}
allocation->origin = allocationOrigin;
if (wddmSuccess == STATUS_SUCCESS) {
bool mapSuccess = wddm->mapGpuVirtualAddress(allocation, allocation->getAlignedCpuPtr(), allocation->is32BitAllocation, false, useHeap1);
bool mapSuccess = wddm->mapGpuVirtualAddress(allocation, allocation->getAlignedCpuPtr());
if (!mapSuccess && deferredDeleter) {
deferredDeleter->drain(true);
mapSuccess = wddm->mapGpuVirtualAddress(allocation, allocation->getAlignedCpuPtr(), allocation->is32BitAllocation, false, useHeap1);
mapSuccess = wddm->mapGpuVirtualAddress(allocation, allocation->getAlignedCpuPtr());
}
if (!mapSuccess) {
wddm->destroyAllocations(&allocation->handle, 1, allocation->resourceHandle);

View File

@@ -34,11 +34,11 @@ bool WddmMock::evict(D3DKMT_HANDLE *handles, uint32_t num, uint64_t &sizeToTrim)
return makeNonResidentResult.success = Wddm::evict(handles, num, sizeToTrim);
}
bool WddmMock::mapGpuVirtualAddressImpl(Gmm *gmm, D3DKMT_HANDLE handle, void *cpuPtr, D3DGPU_VIRTUAL_ADDRESS &gpuPtr, bool allocation32Bit, bool use64kbPages, bool useHeap1) {
bool WddmMock::mapGpuVirtualAddressImpl(Gmm *gmm, D3DKMT_HANDLE handle, void *cpuPtr, D3DGPU_VIRTUAL_ADDRESS &gpuPtr, HeapIndex heapIndex) {
mapGpuVirtualAddressResult.called++;
mapGpuVirtualAddressResult.cpuPtrPassed = cpuPtr;
if (callBaseMapGpuVa) {
return mapGpuVirtualAddressResult.success = Wddm::mapGpuVirtualAddressImpl(gmm, handle, cpuPtr, gpuPtr, allocation32Bit, use64kbPages, useHeap1);
return mapGpuVirtualAddressResult.success = Wddm::mapGpuVirtualAddressImpl(gmm, handle, cpuPtr, gpuPtr, heapIndex);
} else {
gpuPtr = reinterpret_cast<D3DGPU_VIRTUAL_ADDRESS>(cpuPtr);
return mapGpuVaStatus;

View File

@@ -58,7 +58,7 @@ class WddmMock : public Wddm {
bool makeResident(D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim) override;
bool evict(D3DKMT_HANDLE *handles, uint32_t num, uint64_t &sizeToTrim) override;
bool mapGpuVirtualAddressImpl(Gmm *gmm, D3DKMT_HANDLE handle, void *cpuPtr, D3DGPU_VIRTUAL_ADDRESS &gpuPtr, bool allocation32Bit, bool use64kbPages, bool useHeap1) override;
bool mapGpuVirtualAddressImpl(Gmm *gmm, D3DKMT_HANDLE handle, void *cpuPtr, D3DGPU_VIRTUAL_ADDRESS &gpuPtr, HeapIndex heapIndex) override;
bool freeGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t size) override;
NTSTATUS createAllocation(WddmAllocation *alloc) override;
bool createAllocation64k(WddmAllocation *alloc) override;

View File

@@ -82,7 +82,7 @@ TEST_F(Wddm20Tests, givenNullPageTableManagerAndRenderCompressedResourceWhenMapp
allocation.gmm = gmm.get();
allocation.handle = ALLOCATION_HANDLE;
EXPECT_TRUE(wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr(), allocation.is32BitAllocation, false, false));
EXPECT_TRUE(wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr()));
}
TEST(Wddm20EnumAdaptersTest, expectTrue) {
@@ -205,7 +205,7 @@ TEST_F(Wddm20WithMockGdiDllTests, givenAllocationSmallerUnderlyingThanAlignedSiz
EXPECT_EQ(STATUS_SUCCESS, status);
EXPECT_NE(0, allocation.handle);
bool ret = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr(), allocation.is32BitAllocation, false, false);
bool ret = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr());
EXPECT_TRUE(ret);
EXPECT_EQ(alignedPages, getLastCallMapGpuVaArgFcn()->SizeInPages);
@@ -228,7 +228,7 @@ TEST_F(Wddm20WithMockGdiDllTests, givenWddmAllocationWhenMappingGpuVaThenUseGmmS
auto mockResourceInfo = static_cast<MockGmmResourceInfo *>(gmm->gmmResourceInfo.get());
mockResourceInfo->overrideReturnedSize(allocation.getAlignedSize() + (2 * MemoryConstants::pageSize));
wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr(), allocation.is32BitAllocation, false, false);
wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr());
uint64_t expectedSizeInPages = static_cast<uint64_t>(mockResourceInfo->getSizeAllocation() / MemoryConstants::pageSize);
EXPECT_EQ(expectedSizeInPages, getLastCallMapGpuVaArgFcn()->SizeInPages);
@@ -253,7 +253,7 @@ TEST_F(Wddm20Tests, createAllocation32bit) {
EXPECT_EQ(STATUS_SUCCESS, status);
EXPECT_TRUE(allocation.handle != 0);
bool ret = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr(), allocation.is32BitAllocation, false, false);
bool ret = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr());
EXPECT_TRUE(ret);
EXPECT_EQ(1u, wddm->mapGpuVirtualAddressResult.called);
@@ -274,8 +274,9 @@ TEST_F(Wddm20Tests, givenGraphicsAllocationWhenItIsMappedInHeap1ThenItHasGpuAddr
allocation.handle = ALLOCATION_HANDLE;
allocation.gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize());
bool ret = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr(), false, false, true);
allocation.origin = AllocationOrigin::INTERNAL_ALLOCATION;
EXPECT_EQ(HeapIndex::HEAP_INTERNAL, wddm->selectHeap(&allocation, allocation.getAlignedCpuPtr()));
bool ret = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr());
EXPECT_TRUE(ret);
auto cannonizedHeapBase = GmmHelper::canonize(this->wddm->getGfxPartition().Heap32[1].Base);
@@ -329,7 +330,7 @@ TEST_F(Wddm20Tests, mapAndFreeGpuVa) {
EXPECT_EQ(STATUS_SUCCESS, status);
EXPECT_TRUE(allocation.handle != 0);
auto error = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr(), false, false, false);
auto error = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr());
EXPECT_TRUE(error);
EXPECT_TRUE(allocation.gpuPtr != 0);
@@ -353,7 +354,7 @@ TEST_F(Wddm20Tests, givenNullAllocationWhenCreateThenAllocateAndMap) {
auto status = wddm->createAllocation(&allocation);
EXPECT_EQ(STATUS_SUCCESS, status);
bool ret = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr(), allocation.is32BitAllocation, false, false);
bool ret = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr());
EXPECT_TRUE(ret);
EXPECT_NE(0u, allocation.gpuPtr);
@@ -374,7 +375,7 @@ TEST_F(Wddm20Tests, makeResidentNonResident) {
EXPECT_EQ(STATUS_SUCCESS, status);
EXPECT_TRUE(allocation.handle != 0);
auto error = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr(), false, false, false);
auto error = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr());
EXPECT_TRUE(error);
EXPECT_TRUE(allocation.gpuPtr != 0);
@@ -996,3 +997,48 @@ TEST_F(Wddm20Tests, whenEvictingTemporaryResourceThenOtherResourcesRemainOnTheLi
EXPECT_EQ(0x1, wddm->temporaryResources.front());
EXPECT_EQ(0x3, wddm->temporaryResources.back());
}
using WddmHeapSelectorTest = Wddm20Tests;
TEST_F(WddmHeapSelectorTest, given32bitInternalAllocationWhenSelectingHeapThenInternalHeapIsUsed) {
WddmAllocation allocation{nullptr, 0, nullptr, MemoryPool::MemoryNull, 1u, false};
allocation.is32BitAllocation = true;
allocation.origin = AllocationOrigin::INTERNAL_ALLOCATION;
EXPECT_EQ(HeapIndex::HEAP_INTERNAL, wddm->selectHeap(&allocation, nullptr));
}
TEST_F(WddmHeapSelectorTest, givenNon32bitInternalAllocationWhenSelectingHeapThenInternalHeapIsUsed) {
WddmAllocation allocation{nullptr, 0, nullptr, MemoryPool::MemoryNull, 1u, false};
allocation.is32BitAllocation = false;
allocation.origin = AllocationOrigin::INTERNAL_ALLOCATION;
EXPECT_EQ(HeapIndex::HEAP_INTERNAL, wddm->selectHeap(&allocation, nullptr));
}
TEST_F(WddmHeapSelectorTest, given32bitExternalAllocationWhenSelectingHeapThenExternalHeapIsUsed) {
WddmAllocation allocation{nullptr, 0, nullptr, MemoryPool::MemoryNull, 1u, false};
allocation.is32BitAllocation = true;
allocation.origin = AllocationOrigin::EXTERNAL_ALLOCATION;
EXPECT_EQ(HeapIndex::HEAP_EXTERNAL, wddm->selectHeap(&allocation, nullptr));
}
TEST_F(WddmHeapSelectorTest, givenLimitedAddressSpaceWhenSelectingHeapForExternalAllocationThenLimitedHeapIsUsed) {
WddmAllocation allocation{nullptr, 0, nullptr, MemoryPool::MemoryNull, 1u, false};
EXPECT_EQ(AllocationOrigin::EXTERNAL_ALLOCATION, allocation.origin);
if (hardwareInfoTable[wddm->getGfxPlatform()->eProductFamily]->capabilityTable.gpuAddressSpace == MemoryConstants::max48BitAddress) {
return;
}
EXPECT_EQ(HeapIndex::HEAP_LIMITED, wddm->selectHeap(&allocation, nullptr));
}
TEST_F(WddmHeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithPtrThenSvmHeapIsUsed) {
WddmAllocation allocation{nullptr, 0, nullptr, MemoryPool::MemoryNull, 1u, false};
EXPECT_EQ(AllocationOrigin::EXTERNAL_ALLOCATION, allocation.origin);
if (hardwareInfoTable[wddm->getGfxPlatform()->eProductFamily]->capabilityTable.gpuAddressSpace != MemoryConstants::max48BitAddress) {
return;
}
EXPECT_EQ(HeapIndex::HEAP_SVM, wddm->selectHeap(&allocation, &allocation));
}
TEST_F(WddmHeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithoutPtrThenStandardHeapIsUsed) {
WddmAllocation allocation{nullptr, 0, nullptr, MemoryPool::MemoryNull, 1u, false};
EXPECT_EQ(AllocationOrigin::EXTERNAL_ALLOCATION, allocation.origin);
if (hardwareInfoTable[wddm->getGfxPlatform()->eProductFamily]->capabilityTable.gpuAddressSpace != MemoryConstants::max48BitAddress) {
return;
}
EXPECT_EQ(HeapIndex::HEAP_STANDARD, wddm->selectHeap(&allocation, nullptr));
}

View File

@@ -21,7 +21,9 @@ using namespace OCLRT;
class WddmWithKmDafMock : public Wddm {
public:
using Wddm::featureTable;
using Wddm::gdi;
using Wddm::mapGpuVirtualAddressImpl;
WddmWithKmDafMock() : Wddm() {
kmDafListener.reset(new KmDafListenerMock);
@@ -30,14 +32,6 @@ class WddmWithKmDafMock : public Wddm {
KmDafListenerMock &getKmDafListenerMock() {
return static_cast<KmDafListenerMock &>(*this->kmDafListener);
}
FeatureTable *getFeatureTable() {
return featureTable.get();
}
bool mapGpuVirtualAddressImpl(Gmm *gmm, D3DKMT_HANDLE handle, void *cpuPtr, D3DGPU_VIRTUAL_ADDRESS &gpuPtr, bool allocation32bit, bool use64kbPages, bool useHeap1) override {
return Wddm::mapGpuVirtualAddressImpl(gmm, handle, cpuPtr, gpuPtr, allocation32bit, use64kbPages, useHeap1);
};
};
class WddmKmDafListenerTest : public GmmEnvironmentFixture, public ::testing::Test {
@@ -47,7 +41,7 @@ class WddmKmDafListenerTest : public GmmEnvironmentFixture, public ::testing::Te
wddmWithKmDafMock.reset(new WddmWithKmDafMock());
wddmWithKmDafMock->gdi.reset(new MockGdi());
wddmWithKmDafMock->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
wddmWithKmDafMock->getFeatureTable()->ftrKmdDaf = true;
wddmWithKmDafMock->featureTable->ftrKmdDaf = true;
}
void TearDown() {
GmmEnvironmentFixture::TearDown();
@@ -62,7 +56,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenLockResourceIsCalledThenKmDafListener
wddmWithKmDafMock->lockResource(allocation);
EXPECT_EQ(wddmWithKmDafMock->getFeatureTable()->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.ftrKmdDaf);
EXPECT_EQ(wddmWithKmDafMock->featureTable->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.ftrKmdDaf);
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.hAdapter);
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.hDevice);
EXPECT_EQ(allocation.handle, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.hAllocation);
@@ -76,7 +70,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenUnlockResourceIsCalledThenKmDafListen
wddmWithKmDafMock->unlockResource(allocation);
EXPECT_EQ(wddmWithKmDafMock->getFeatureTable()->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyUnlockParametrization.ftrKmdDaf);
EXPECT_EQ(wddmWithKmDafMock->featureTable->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyUnlockParametrization.ftrKmdDaf);
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyUnlockParametrization.hAdapter);
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyUnlockParametrization.hDevice);
EXPECT_EQ(allocation.handle, *wddmWithKmDafMock->getKmDafListenerMock().notifyUnlockParametrization.phAllocation);
@@ -90,9 +84,9 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenMapGpuVirtualAddressIsCalledThenKmDaf
auto gmm = std::unique_ptr<Gmm>(new Gmm(nullptr, 1, false));
allocation.gmm = gmm.get();
wddmWithKmDafMock->mapGpuVirtualAddressImpl(allocation.gmm, allocation.handle, allocation.getUnderlyingBuffer(), allocation.gpuPtr, false, false, false);
wddmWithKmDafMock->mapGpuVirtualAddressImpl(allocation.gmm, allocation.handle, allocation.getUnderlyingBuffer(), allocation.gpuPtr, wddmWithKmDafMock->selectHeap(&allocation, allocation.getUnderlyingBuffer()));
EXPECT_EQ(wddmWithKmDafMock->getFeatureTable()->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.ftrKmdDaf);
EXPECT_EQ(wddmWithKmDafMock->featureTable->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.ftrKmdDaf);
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hAdapter);
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hDevice);
EXPECT_EQ(allocation.handle, wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hAllocation);
@@ -106,7 +100,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenFreeGpuVirtualAddressIsCalledThenKmDa
wddmWithKmDafMock->freeGpuVirtualAddress(allocation.gpuPtr, allocation.getUnderlyingBufferSize());
EXPECT_EQ(wddmWithKmDafMock->getFeatureTable()->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyUnmapGpuVAParametrization.ftrKmdDaf);
EXPECT_EQ(wddmWithKmDafMock->featureTable->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyUnmapGpuVAParametrization.ftrKmdDaf);
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyUnmapGpuVAParametrization.hAdapter);
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyUnmapGpuVAParametrization.hDevice);
EXPECT_EQ(GPUVA, wddmWithKmDafMock->getKmDafListenerMock().notifyUnmapGpuVAParametrization.GpuVirtualAddress);
@@ -118,7 +112,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenMakeResidentIsCalledThenKmDafListener
wddmWithKmDafMock->makeResident(&allocation.handle, 1, false, nullptr);
EXPECT_EQ(wddmWithKmDafMock->getFeatureTable()->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyMakeResidentParametrization.ftrKmdDaf);
EXPECT_EQ(wddmWithKmDafMock->featureTable->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyMakeResidentParametrization.ftrKmdDaf);
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyMakeResidentParametrization.hAdapter);
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyMakeResidentParametrization.hDevice);
EXPECT_EQ(allocation.handle, *wddmWithKmDafMock->getKmDafListenerMock().notifyMakeResidentParametrization.phAllocation);
@@ -132,7 +126,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenEvictIsCalledThenKmDafListenerNotifyE
wddmWithKmDafMock->evict(&allocation.handle, 1, sizeToTrim);
EXPECT_EQ(wddmWithKmDafMock->getFeatureTable()->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyEvictParametrization.ftrKmdDaf);
EXPECT_EQ(wddmWithKmDafMock->featureTable->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyEvictParametrization.ftrKmdDaf);
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyEvictParametrization.hAdapter);
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyEvictParametrization.hDevice);
EXPECT_EQ(allocation.handle, *wddmWithKmDafMock->getKmDafListenerMock().notifyEvictParametrization.phAllocation);
@@ -147,7 +141,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocationIsCalledThenKmDafList
wddmWithKmDafMock->createAllocation(&allocation);
EXPECT_EQ(wddmWithKmDafMock->getFeatureTable()->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.ftrKmdDaf);
EXPECT_EQ(wddmWithKmDafMock->featureTable->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.ftrKmdDaf);
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.hAdapter);
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.hDevice);
EXPECT_EQ(allocation.handle, wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.hAllocation);
@@ -161,7 +155,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocation64IsCalledThenKmDafLi
wddmWithKmDafMock->createAllocation64k(&allocation);
EXPECT_EQ(wddmWithKmDafMock->getFeatureTable()->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.ftrKmdDaf);
EXPECT_EQ(wddmWithKmDafMock->featureTable->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.ftrKmdDaf);
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.hAdapter);
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.hDevice);
EXPECT_EQ(allocation.handle, wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.hAllocation);
@@ -178,13 +172,13 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocationsAndMapGpuVaIsCalledT
wddmWithKmDafMock->createAllocationsAndMapGpuVa(storage);
EXPECT_EQ(wddmWithKmDafMock->getFeatureTable()->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.ftrKmdDaf);
EXPECT_EQ(wddmWithKmDafMock->featureTable->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.ftrKmdDaf);
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.hAdapter);
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.hDevice);
EXPECT_EQ(osHandle.handle, wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.hAllocation);
EXPECT_EQ(wddmWithKmDafMock->getGdi()->escape, wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.pfnEscape);
EXPECT_EQ(wddmWithKmDafMock->getFeatureTable()->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.ftrKmdDaf);
EXPECT_EQ(wddmWithKmDafMock->featureTable->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.ftrKmdDaf);
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hAdapter);
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hDevice);
EXPECT_EQ(osHandle.handle, wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hAllocation);
@@ -198,7 +192,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenKmDafLockIsCalledThenKmDafListenerNot
wddmWithKmDafMock->kmDafLock(&allocation);
EXPECT_EQ(wddmWithKmDafMock->getFeatureTable()->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.ftrKmdDaf);
EXPECT_EQ(wddmWithKmDafMock->featureTable->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.ftrKmdDaf);
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.hAdapter);
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.hDevice);
EXPECT_EQ(allocation.handle, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.hAllocation);

View File

@@ -709,8 +709,8 @@ TEST_F(WddmMemoryManagerTest, Allocate32BitMemoryWithNullptr) {
auto *gpuAllocation = memoryManager->allocate32BitGraphicsMemory(3 * MemoryConstants::pageSize, nullptr, AllocationOrigin::EXTERNAL_ALLOCATION);
ASSERT_NE(nullptr, gpuAllocation);
EXPECT_LE(GmmHelper::canonize(wddm->getHeap32Base()), gpuAllocation->getGpuAddress());
EXPECT_GT(GmmHelper::canonize(wddm->getHeap32Base()) + wddm->getHeap32Size() - 1, gpuAllocation->getGpuAddress());
EXPECT_LE(GmmHelper::canonize(wddm->getExternalHeapBase()), gpuAllocation->getGpuAddress());
EXPECT_GT(GmmHelper::canonize(wddm->getExternalHeapBase()) + wddm->getExternalHeapSize() - 1, gpuAllocation->getGpuAddress());
EXPECT_EQ(0u, gpuAllocation->fragmentsStorage.fragmentCount);
memoryManager->freeGraphicsMemory(gpuAllocation);
@@ -734,8 +734,8 @@ TEST_F(WddmMemoryManagerTest, Allocate32BitMemoryWithMisalignedHostPtrDoesNotDoT
EXPECT_EQ(alignSizeWholePage(misalignedPtr, misalignedSize), gpuAllocation->getUnderlyingBufferSize());
EXPECT_LE(GmmHelper::canonize(wddm->getHeap32Base()), gpuAllocation->getGpuAddress());
EXPECT_GT(GmmHelper::canonize(wddm->getHeap32Base()) + wddm->getHeap32Size() - 1, gpuAllocation->getGpuAddress());
EXPECT_LE(GmmHelper::canonize(wddm->getExternalHeapBase()), gpuAllocation->getGpuAddress());
EXPECT_GT(GmmHelper::canonize(wddm->getExternalHeapBase()) + wddm->getExternalHeapSize() - 1, gpuAllocation->getGpuAddress());
EXPECT_EQ(0u, gpuAllocation->fragmentsStorage.fragmentCount);
@@ -751,7 +751,7 @@ TEST_F(WddmMemoryManagerTest, Allocate32BitMemorySetsCannonizedGpuBaseAddress) {
ASSERT_NE(nullptr, gpuAllocation);
uint64_t cannonizedAddress = GmmHelper::canonize(wddm->getHeap32Base());
uint64_t cannonizedAddress = GmmHelper::canonize(wddm->getExternalHeapBase());
EXPECT_EQ(cannonizedAddress, gpuAllocation->gpuBaseAddress);
memoryManager->freeGraphicsMemory(gpuAllocation);
@@ -1072,6 +1072,7 @@ struct WddmMemoryManagerWithAsyncDeleterTest : ::testing::Test {
wddm = std::make_unique<WddmMock>();
wddm->gdi.reset(new MockGdi());
wddm->callBaseDestroyAllocations = false;
wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
deleter = new MockDeferredDeleter;
memoryManager = std::make_unique<MockWddmMemoryManager>(wddm.get(), executionEnvironment);
memoryManager->setDeferredDeleter(deleter);
@@ -1318,7 +1319,7 @@ TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedAllocationWhenMappedGpuVa
EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(1).WillOnce(Invoke([&](const GMM_DDI_UPDATEAUXTABLE *arg) {givenDdiUpdateAuxTable = *arg; return GMM_SUCCESS; }));
auto result = wddm.mapGpuVirtualAddressImpl(gmm.get(), ALLOCATION_HANDLE, nullptr, gpuVa, false, false, false);
auto result = wddm.mapGpuVirtualAddressImpl(gmm.get(), ALLOCATION_HANDLE, nullptr, gpuVa, wddm.selectHeap(nullptr, nullptr));
ASSERT_TRUE(result);
auto productFamily = wddm.getGfxPlatform()->eProductFamily;
@@ -1388,7 +1389,7 @@ TEST_F(MockWddmMemoryManagerTest, givenNonRenderCompressedAllocationWhenMappedGp
EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(0);
auto result = wddm.mapGpuVirtualAddressImpl(gmm.get(), ALLOCATION_HANDLE, nullptr, gpuVa, false, false, false);
auto result = wddm.mapGpuVirtualAddressImpl(gmm.get(), ALLOCATION_HANDLE, nullptr, gpuVa, wddm.selectHeap(nullptr, nullptr));
ASSERT_TRUE(result);
}
@@ -1399,7 +1400,7 @@ TEST_F(MockWddmMemoryManagerTest, givenFailingAllocationWhenMappedGpuVaThenRetur
WddmMock wddm;
EXPECT_TRUE(wddm.init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])));
auto result = wddm.mapGpuVirtualAddressImpl(gmm.get(), 0, nullptr, gpuVa, false, false, false);
auto result = wddm.mapGpuVirtualAddressImpl(gmm.get(), 0, nullptr, gpuVa, wddm.selectHeap(nullptr, nullptr));
ASSERT_FALSE(result);
}
@@ -1422,7 +1423,7 @@ TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedFlagSetWhenInternalIsUnse
EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(0);
auto result = wddm->mapGpuVirtualAddressImpl(myGmm, ALLOCATION_HANDLE, nullptr, gpuVa, false, false, false);
auto result = wddm->mapGpuVirtualAddressImpl(myGmm, ALLOCATION_HANDLE, nullptr, gpuVa, wddm->selectHeap(nullptr, nullptr));
EXPECT_TRUE(result);
memoryManager.freeGraphicsMemory(wddmAlloc);
}