mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-20 00:24:58 +08:00
Allow to create WddmAllocation with multiple handles
Change-Id: Iac9df91b08a6ce610b985586dfb6b5f63dc668cb Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
7df0be9a13
commit
5b22a50b28
@@ -43,4 +43,5 @@ static constexpr std::array<EngineInstanceT, EngineInstanceConstants::numAllEngi
|
||||
}};
|
||||
|
||||
constexpr uint32_t maxOsContextCount = EngineInstanceConstants::numGpgpuEngineInstances;
|
||||
constexpr uint32_t maxHandleCount = 1u;
|
||||
} // namespace OCLRT
|
||||
|
||||
@@ -290,7 +290,7 @@ bool Wddm::makeResident(const D3DKMT_HANDLE *handles, uint32_t count, bool cantT
|
||||
|
||||
bool Wddm::mapGpuVirtualAddress(WddmAllocation *allocation, void *cpuPtr) {
|
||||
void *mapPtr = allocation->getReservedAddress() != nullptr ? allocation->getReservedAddress() : cpuPtr;
|
||||
return mapGpuVirtualAddressImpl(allocation->gmm, allocation->handle, mapPtr, allocation->getGpuAddressToModify(),
|
||||
return mapGpuVirtualAddressImpl(allocation->gmm, allocation->getDefaultHandle(), mapPtr, allocation->getGpuAddressToModify(),
|
||||
MemoryManager::selectHeap(allocation, mapPtr, *hardwareInfoTable[gfxPlatform->eProductFamily]));
|
||||
}
|
||||
|
||||
@@ -466,8 +466,8 @@ bool Wddm::createAllocation64k(const Gmm *gmm, D3DKMT_HANDLE &outHandle) {
|
||||
}
|
||||
|
||||
outHandle = AllocationInfo.hAllocation;
|
||||
|
||||
kmDafListener->notifyWriteTarget(featureTable->ftrKmdDaf, adapter, device, outHandle, gdi->escape);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -590,7 +590,7 @@ bool Wddm::openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc) {
|
||||
status = gdi->openResource(&OpenResource);
|
||||
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
|
||||
|
||||
alloc->handle = allocationInfo[0].hAllocation;
|
||||
alloc->setDefaultHandle(allocationInfo[0].hAllocation);
|
||||
alloc->resourceHandle = OpenResource.hResource;
|
||||
|
||||
auto resourceInfo = const_cast<void *>(allocationInfo[0].pPrivateDriverData);
|
||||
@@ -627,7 +627,7 @@ bool Wddm::openNTHandle(HANDLE handle, WddmAllocation *alloc) {
|
||||
status = gdi->openResourceFromNtHandle(&openResourceFromNtHandle);
|
||||
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
|
||||
|
||||
alloc->handle = allocationInfo2[0].hAllocation;
|
||||
alloc->setDefaultHandle(allocationInfo2[0].hAllocation);
|
||||
alloc->resourceHandle = openResourceFromNtHandle.hResource;
|
||||
|
||||
auto resourceInfo = const_cast<void *>(allocationInfo2[0].pPrivateDriverData);
|
||||
@@ -652,7 +652,6 @@ void *Wddm::lockResource(const D3DKMT_HANDLE &handle, bool applyMakeResidentPrio
|
||||
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
|
||||
|
||||
kmDafLock(handle);
|
||||
|
||||
return lock2.pData;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
|
||||
namespace OCLRT {
|
||||
std::string WddmAllocation::getAllocationInfoString() const {
|
||||
std::stringstream ss;
|
||||
ss << " Handle: " << handle;
|
||||
return ss.str();
|
||||
return getHandleInfoString();
|
||||
}
|
||||
uint32_t WddmAllocation::getNumHandles() const {
|
||||
return 1u;
|
||||
}
|
||||
} // namespace OCLRT
|
||||
@@ -25,10 +25,6 @@ constexpr size_t trimListUnusedPosition = std::numeric_limits<size_t>::max();
|
||||
|
||||
class WddmAllocation : public GraphicsAllocation {
|
||||
public:
|
||||
// OS assigned fields
|
||||
D3DKMT_HANDLE handle = 0u; // set by createAllocation
|
||||
D3DKMT_HANDLE resourceHandle = 0u; // used by shared resources
|
||||
|
||||
WddmAllocation(AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, void *reservedAddr, MemoryPool::Type pool, bool multiOsContextCapable)
|
||||
: GraphicsAllocation(allocationType, cpuPtrIn, castToUint64(cpuPtrIn), 0llu, sizeIn, pool, multiOsContextCapable), reservedAddressSpace(reservedAddr) {
|
||||
trimCandidateListPositions.fill(trimListUnusedPosition);
|
||||
@@ -50,6 +46,13 @@ class WddmAllocation : public GraphicsAllocation {
|
||||
ResidencyData &getResidencyData() {
|
||||
return residency;
|
||||
}
|
||||
const std::array<D3DKMT_HANDLE, maxHandleCount> &getHandles() const { return handles; }
|
||||
D3DKMT_HANDLE &getHandleToModify(uint32_t handleIndex) { return handles[handleIndex]; }
|
||||
D3DKMT_HANDLE getDefaultHandle() const { return handles[0]; }
|
||||
void setDefaultHandle(D3DKMT_HANDLE handle) {
|
||||
handles[0] = handle;
|
||||
}
|
||||
uint32_t getNumHandles() const;
|
||||
|
||||
void setTrimCandidateListPosition(uint32_t osContextId, size_t position) {
|
||||
trimCandidateListPositions[osContextId] = position;
|
||||
@@ -71,12 +74,23 @@ class WddmAllocation : public GraphicsAllocation {
|
||||
}
|
||||
void setGpuAddress(uint64_t graphicsAddress) { this->gpuAddress = graphicsAddress; }
|
||||
void setCpuAddress(void *cpuPtr) { this->cpuPtr = cpuPtr; }
|
||||
bool needsMakeResidentBeforeLock = false;
|
||||
|
||||
std::string getAllocationInfoString() const override;
|
||||
uint64_t &getGpuAddressToModify() { return gpuAddress; }
|
||||
|
||||
// OS assigned fields
|
||||
D3DKMT_HANDLE resourceHandle = 0u; // used by shared resources
|
||||
bool needsMakeResidentBeforeLock = false;
|
||||
|
||||
protected:
|
||||
std::string getHandleInfoString() const {
|
||||
std::stringstream ss;
|
||||
for (auto &handle : handles) {
|
||||
ss << " Handle: " << handle;
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
std::array<D3DKMT_HANDLE, maxHandleCount> handles{};
|
||||
ResidencyData residency;
|
||||
std::array<size_t, maxOsContextCount> trimCandidateListPositions;
|
||||
void *reservedAddressSpace = nullptr;
|
||||
|
||||
@@ -107,13 +107,13 @@ FlushStamp WddmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchBuffer,
|
||||
|
||||
template <typename GfxFamily>
|
||||
void WddmCommandStreamReceiver<GfxFamily>::makeResident(GraphicsAllocation &gfxAllocation) {
|
||||
DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "allocation =", reinterpret_cast<WddmAllocation *>(&gfxAllocation));
|
||||
DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "allocation =", static_cast<WddmAllocation *>(&gfxAllocation));
|
||||
|
||||
if (gfxAllocation.fragmentsStorage.fragmentCount == 0) {
|
||||
DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "allocation handle =", reinterpret_cast<WddmAllocation *>(&gfxAllocation)->handle);
|
||||
DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "allocation default handle =", static_cast<WddmAllocation *>(&gfxAllocation)->getDefaultHandle());
|
||||
} else {
|
||||
for (uint32_t allocationId = 0; allocationId < reinterpret_cast<WddmAllocation *>(&gfxAllocation)->fragmentsStorage.fragmentCount; allocationId++) {
|
||||
DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "fragment handle =", reinterpret_cast<WddmAllocation *>(&gfxAllocation)->fragmentsStorage.fragmentStorageData[allocationId].osHandleStorage->handle);
|
||||
for (uint32_t allocationId = 0; allocationId < static_cast<WddmAllocation *>(&gfxAllocation)->fragmentsStorage.fragmentCount; allocationId++) {
|
||||
DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "fragment handle =", static_cast<WddmAllocation *>(&gfxAllocation)->fragmentsStorage.fragmentStorageData[allocationId].osHandleStorage->handle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ void WddmCommandStreamReceiver<GfxFamily>::kmDafLockAllocations(ResidencyContain
|
||||
if ((GraphicsAllocation::AllocationType::LINEAR_STREAM == graphicsAllocation->getAllocationType()) ||
|
||||
(GraphicsAllocation::AllocationType::FILL_PATTERN == graphicsAllocation->getAllocationType()) ||
|
||||
(GraphicsAllocation::AllocationType::COMMAND_BUFFER == graphicsAllocation->getAllocationType())) {
|
||||
wddm->kmDafLock(static_cast<WddmAllocation *>(graphicsAllocation)->handle);
|
||||
wddm->kmDafLock(static_cast<WddmAllocation *>(graphicsAllocation)->getDefaultHandle());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory64kb(const Allocati
|
||||
auto gmm = new Gmm(nullptr, sizeAligned, false, allocationData.flags.preferRenderCompressed, true, {});
|
||||
wddmAllocation->gmm = gmm;
|
||||
|
||||
if (!wddm->createAllocation64k(gmm, wddmAllocation->handle)) {
|
||||
if (!wddm->createAllocation64k(gmm, wddmAllocation->getHandleToModify(0u))) {
|
||||
delete gmm;
|
||||
return nullptr;
|
||||
}
|
||||
@@ -257,7 +257,7 @@ void WddmMemoryManager::addAllocationToHostPtrManager(GraphicsAllocation *gfxAll
|
||||
|
||||
fragment.osInternalStorage = new OsHandle();
|
||||
fragment.osInternalStorage->gpuPtr = gfxAllocation->getGpuAddress();
|
||||
fragment.osInternalStorage->handle = wddmMemory->handle;
|
||||
fragment.osInternalStorage->handle = wddmMemory->getDefaultHandle();
|
||||
fragment.osInternalStorage->gmm = gfxAllocation->gmm;
|
||||
fragment.residency = &wddmMemory->getResidencyData();
|
||||
hostPtrManager->storeFragment(fragment);
|
||||
@@ -276,13 +276,13 @@ void WddmMemoryManager::removeAllocationFromHostPtrManager(GraphicsAllocation *g
|
||||
|
||||
void *WddmMemoryManager::lockResourceImpl(GraphicsAllocation &graphicsAllocation) {
|
||||
auto &wddmAllocation = static_cast<WddmAllocation &>(graphicsAllocation);
|
||||
return wddm->lockResource(wddmAllocation.handle, wddmAllocation.needsMakeResidentBeforeLock);
|
||||
return wddm->lockResource(wddmAllocation.getDefaultHandle(), wddmAllocation.needsMakeResidentBeforeLock);
|
||||
}
|
||||
void WddmMemoryManager::unlockResourceImpl(GraphicsAllocation &graphicsAllocation) {
|
||||
auto &wddmAllocation = static_cast<WddmAllocation &>(graphicsAllocation);
|
||||
wddm->unlockResource(wddmAllocation.handle);
|
||||
wddm->unlockResource(wddmAllocation.getDefaultHandle());
|
||||
if (wddmAllocation.needsMakeResidentBeforeLock) {
|
||||
auto evictionStatus = wddm->evictTemporaryResource(wddmAllocation.handle);
|
||||
auto evictionStatus = wddm->evictTemporaryResource(wddmAllocation.getDefaultHandle());
|
||||
DEBUG_BREAK_IF(evictionStatus == EvictionStatus::FAILED);
|
||||
}
|
||||
}
|
||||
@@ -315,14 +315,14 @@ void WddmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation
|
||||
input->fragmentsStorage.fragmentCount > 0) {
|
||||
cleanGraphicsMemoryCreatedFromHostPtr(gfxAllocation);
|
||||
} else {
|
||||
D3DKMT_HANDLE *allocationHandles = nullptr;
|
||||
const D3DKMT_HANDLE *allocationHandles = nullptr;
|
||||
uint32_t allocationCount = 0;
|
||||
D3DKMT_HANDLE resourceHandle = 0;
|
||||
if (input->peekSharedHandle()) {
|
||||
resourceHandle = input->resourceHandle;
|
||||
} else {
|
||||
allocationHandles = &input->handle;
|
||||
allocationCount = 1;
|
||||
allocationHandles = input->getHandles().data();
|
||||
allocationCount = input->getNumHandles();
|
||||
}
|
||||
auto status = tryDeferDeletions(allocationHandles, allocationCount, resourceHandle);
|
||||
DEBUG_BREAK_IF(!status);
|
||||
@@ -355,7 +355,7 @@ bool WddmMemoryManager::validateAllocation(WddmAllocation *alloc) {
|
||||
if (alloc == nullptr)
|
||||
return false;
|
||||
auto size = alloc->getUnderlyingBufferSize();
|
||||
if (alloc->getGpuAddress() == 0u || size == 0 || (alloc->handle == 0 && alloc->fragmentsStorage.fragmentCount == 0))
|
||||
if (alloc->getGpuAddress() == 0u || size == 0 || (alloc->getDefaultHandle() == 0 && alloc->fragmentsStorage.fragmentCount == 0))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@@ -459,10 +459,10 @@ AlignedMallocRestrictions *WddmMemoryManager::getAlignedMallocRestrictions() {
|
||||
}
|
||||
|
||||
bool WddmMemoryManager::createWddmAllocation(WddmAllocation *allocation) {
|
||||
auto wddmSuccess = wddm->createAllocation(allocation->getAlignedCpuPtr(), allocation->gmm, allocation->handle);
|
||||
auto wddmSuccess = wddm->createAllocation(allocation->getAlignedCpuPtr(), allocation->gmm, allocation->getHandleToModify(0u));
|
||||
if (wddmSuccess == STATUS_GRAPHICS_NO_VIDEO_MEMORY && deferredDeleter) {
|
||||
deferredDeleter->drain(true);
|
||||
wddmSuccess = wddm->createAllocation(allocation->getAlignedCpuPtr(), allocation->gmm, allocation->handle);
|
||||
wddmSuccess = wddm->createAllocation(allocation->getAlignedCpuPtr(), allocation->gmm, allocation->getHandleToModify(0u));
|
||||
}
|
||||
|
||||
if (wddmSuccess == STATUS_SUCCESS) {
|
||||
@@ -472,7 +472,7 @@ bool WddmMemoryManager::createWddmAllocation(WddmAllocation *allocation) {
|
||||
mapSuccess = wddm->mapGpuVirtualAddress(allocation, allocation->getAlignedCpuPtr());
|
||||
}
|
||||
if (!mapSuccess) {
|
||||
wddm->destroyAllocations(&allocation->handle, 1, allocation->resourceHandle);
|
||||
wddm->destroyAllocations(allocation->getHandles().data(), allocation->getNumHandles(), allocation->resourceHandle);
|
||||
wddmSuccess = STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ WddmAllocation *WddmResidencyController::getTrimCandidateHead() {
|
||||
while ((trimCandidateList[i] == nullptr) && (i < size))
|
||||
i++;
|
||||
|
||||
return reinterpret_cast<WddmAllocation *>(trimCandidateList[i]);
|
||||
return static_cast<WddmAllocation *>(trimCandidateList[i]);
|
||||
}
|
||||
|
||||
void WddmResidencyController::addToTrimCandidateList(GraphicsAllocation *allocation) {
|
||||
@@ -195,14 +195,13 @@ void WddmResidencyController::trimResidency(D3DDDI_TRIMRESIDENCYSET_FLAGS flags,
|
||||
if (wasAllocationUsedSinceLastTrim(wddmAllocation->getResidencyData().getFenceValueForContextId(osContextId))) {
|
||||
break;
|
||||
}
|
||||
|
||||
DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "allocation: handle =", wddmAllocation->handle, "lastFence =", (wddmAllocation)->getResidencyData().getFenceValueForContextId(osContextId));
|
||||
DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "allocation: default handle =", wddmAllocation->getDefaultHandle(), "lastFence =", (wddmAllocation)->getResidencyData().getFenceValueForContextId(osContextId));
|
||||
|
||||
uint32_t fragmentsToEvict = 0;
|
||||
|
||||
if (wddmAllocation->fragmentsStorage.fragmentCount == 0) {
|
||||
DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "Evict allocation: handle =", wddmAllocation->handle, "lastFence =", (wddmAllocation)->getResidencyData().getFenceValueForContextId(osContextId));
|
||||
this->wddm.evict(&wddmAllocation->handle, 1, sizeToTrim);
|
||||
DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "Evict allocation: default handle =", wddmAllocation->getDefaultHandle(), "lastFence =", (wddmAllocation)->getResidencyData().getFenceValueForContextId(osContextId));
|
||||
this->wddm.evict(wddmAllocation->getHandles().data(), wddmAllocation->getNumHandles(), sizeToTrim);
|
||||
}
|
||||
|
||||
for (uint32_t allocationId = 0; allocationId < wddmAllocation->fragmentsStorage.fragmentCount; allocationId++) {
|
||||
@@ -213,11 +212,9 @@ void WddmResidencyController::trimResidency(D3DDDI_TRIMRESIDENCYSET_FLAGS flags,
|
||||
fragmentStorageData.residency->resident[osContextId] = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (fragmentsToEvict != 0) {
|
||||
this->wddm.evict((D3DKMT_HANDLE *)fragmentEvictHandles, fragmentsToEvict, sizeToTrim);
|
||||
}
|
||||
|
||||
wddmAllocation->getResidencyData().resident[osContextId] = false;
|
||||
|
||||
this->removeFromTrimCandidateList(wddmAllocation, false);
|
||||
@@ -261,7 +258,7 @@ bool WddmResidencyController::trimResidencyToBudget(uint64_t bytes) {
|
||||
}
|
||||
|
||||
if (wddmAllocation->fragmentsStorage.fragmentCount == 0) {
|
||||
this->wddm.evict(&wddmAllocation->handle, 1, sizeToTrim);
|
||||
this->wddm.evict(wddmAllocation->getHandles().data(), wddmAllocation->getNumHandles(), sizeToTrim);
|
||||
sizeEvicted = wddmAllocation->getAlignedSize();
|
||||
} else {
|
||||
auto &fragmentStorageData = wddmAllocation->fragmentsStorage.fragmentStorageData;
|
||||
@@ -310,7 +307,7 @@ bool WddmResidencyController::makeResidentResidencyAllocations(ResidencyContaine
|
||||
DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "currentFenceValue =", this->getMonitoredFence().currentFenceValue);
|
||||
|
||||
for (uint32_t i = 0; i < residencyCount; i++) {
|
||||
WddmAllocation *allocation = reinterpret_cast<WddmAllocation *>(allocationsForResidency[i]);
|
||||
WddmAllocation *allocation = static_cast<WddmAllocation *>(allocationsForResidency[i]);
|
||||
ResidencyData &residencyData = allocation->getResidencyData();
|
||||
bool fragmentResidency[3] = {false, false, false};
|
||||
|
||||
@@ -332,7 +329,8 @@ bool WddmResidencyController::makeResidentResidencyAllocations(ResidencyContaine
|
||||
handlesForResidency[totalHandlesCount++] = allocation->fragmentsStorage.fragmentStorageData[allocationId].osHandleStorage->handle;
|
||||
}
|
||||
} else if (!residencyData.resident[osContextId]) {
|
||||
handlesForResidency[totalHandlesCount++] = allocation->handle;
|
||||
memcpy_s(&handlesForResidency[totalHandlesCount], allocation->getNumHandles() * sizeof(D3DKMT_HANDLE), allocation->getHandles().data(), allocation->getNumHandles() * sizeof(D3DKMT_HANDLE));
|
||||
totalHandlesCount += allocation->getNumHandles();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,7 +354,7 @@ bool WddmResidencyController::makeResidentResidencyAllocations(ResidencyContaine
|
||||
|
||||
if (result == true) {
|
||||
for (uint32_t i = 0; i < residencyCount; i++) {
|
||||
WddmAllocation *allocation = reinterpret_cast<WddmAllocation *>(allocationsForResidency[i]);
|
||||
WddmAllocation *allocation = static_cast<WddmAllocation *>(allocationsForResidency[i]);
|
||||
// Update fence value not to early destroy / evict allocation
|
||||
const auto currentFence = this->getMonitoredFence().currentFenceValue;
|
||||
allocation->getResidencyData().updateCompletionData(currentFence, this->osContextId);
|
||||
@@ -379,7 +377,7 @@ void WddmResidencyController::makeNonResidentEvictionAllocations(ResidencyContai
|
||||
const size_t residencyCount = evictionAllocations.size();
|
||||
|
||||
for (uint32_t i = 0; i < residencyCount; i++) {
|
||||
WddmAllocation *allocation = reinterpret_cast<WddmAllocation *>(evictionAllocations[i]);
|
||||
WddmAllocation *allocation = static_cast<WddmAllocation *>(evictionAllocations[i]);
|
||||
this->addToTrimCandidateList(allocation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ bool WddmMock::freeGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t si
|
||||
}
|
||||
NTSTATUS WddmMock::createAllocation(WddmAllocation *wddmAllocation) {
|
||||
if (wddmAllocation) {
|
||||
return createAllocation(wddmAllocation->getAlignedCpuPtr(), wddmAllocation->gmm, wddmAllocation->handle);
|
||||
return createAllocation(wddmAllocation->getAlignedCpuPtr(), wddmAllocation->gmm, wddmAllocation->getHandleToModify(0u));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -71,7 +71,7 @@ NTSTATUS WddmMock::createAllocation(const void *alignedCpuPtr, const Gmm *gmm, D
|
||||
|
||||
bool WddmMock::createAllocation64k(WddmAllocation *wddmAllocation) {
|
||||
if (wddmAllocation) {
|
||||
return createAllocation64k(wddmAllocation->gmm, wddmAllocation->handle);
|
||||
return createAllocation64k(wddmAllocation->gmm, wddmAllocation->getHandleToModify(0u));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -90,14 +90,14 @@ bool WddmMock::destroyAllocations(const D3DKMT_HANDLE *handles, uint32_t allocat
|
||||
}
|
||||
|
||||
bool WddmMock::destroyAllocation(WddmAllocation *alloc, OsContextWin *osContext) {
|
||||
D3DKMT_HANDLE *allocationHandles = nullptr;
|
||||
const D3DKMT_HANDLE *allocationHandles = nullptr;
|
||||
uint32_t allocationCount = 0;
|
||||
D3DKMT_HANDLE resourceHandle = 0;
|
||||
void *reserveAddress = alloc->getReservedAddress();
|
||||
if (alloc->peekSharedHandle()) {
|
||||
resourceHandle = alloc->resourceHandle;
|
||||
} else {
|
||||
allocationHandles = &alloc->handle;
|
||||
allocationHandles = alloc->getHandles().data();
|
||||
allocationCount = 1;
|
||||
}
|
||||
auto success = destroyAllocations(allocationHandles, allocationCount, resourceHandle);
|
||||
|
||||
@@ -415,7 +415,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithResi
|
||||
|
||||
EXPECT_EQ(1u, wddm->kmDafLockResult.called);
|
||||
EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size());
|
||||
EXPECT_EQ(linearStreamAllocation->handle, wddm->kmDafLockResult.lockedAllocations[0]);
|
||||
EXPECT_EQ(linearStreamAllocation->getDefaultHandle(), wddm->kmDafLockResult.lockedAllocations[0]);
|
||||
|
||||
memoryManager->freeGraphicsMemory(commandBuffer);
|
||||
memoryManager->freeGraphicsMemory(linearStreamAllocation);
|
||||
@@ -436,7 +436,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllo
|
||||
|
||||
EXPECT_EQ(1u, wddm->kmDafLockResult.called);
|
||||
EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size());
|
||||
EXPECT_EQ(linearStreamAllocation->handle, wddm->kmDafLockResult.lockedAllocations[0]);
|
||||
EXPECT_EQ(linearStreamAllocation->getDefaultHandle(), wddm->kmDafLockResult.lockedAllocations[0]);
|
||||
|
||||
memoryManager->freeGraphicsMemory(commandBuffer);
|
||||
memoryManager->freeGraphicsMemory(linearStreamAllocation);
|
||||
@@ -457,7 +457,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllo
|
||||
|
||||
EXPECT_EQ(1u, wddm->kmDafLockResult.called);
|
||||
EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size());
|
||||
EXPECT_EQ(fillPatternAllocation->handle, wddm->kmDafLockResult.lockedAllocations[0]);
|
||||
EXPECT_EQ(fillPatternAllocation->getDefaultHandle(), wddm->kmDafLockResult.lockedAllocations[0]);
|
||||
|
||||
memoryManager->freeGraphicsMemory(commandBuffer);
|
||||
memoryManager->freeGraphicsMemory(fillPatternAllocation);
|
||||
@@ -478,7 +478,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllo
|
||||
|
||||
EXPECT_EQ(1u, wddm->kmDafLockResult.called);
|
||||
EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size());
|
||||
EXPECT_EQ(commandBufferAllocation->handle, wddm->kmDafLockResult.lockedAllocations[0]);
|
||||
EXPECT_EQ(commandBufferAllocation->getDefaultHandle(), wddm->kmDafLockResult.lockedAllocations[0]);
|
||||
|
||||
memoryManager->freeGraphicsMemory(commandBuffer);
|
||||
memoryManager->freeGraphicsMemory(commandBufferAllocation);
|
||||
@@ -679,7 +679,7 @@ TEST_F(WddmCommandStreamMockGdiTest, makeResidentClearsResidencyAllocations) {
|
||||
EXPECT_EQ(1u, csr->getResidencyAllocations().size());
|
||||
EXPECT_EQ(0u, csr->getEvictionAllocations().size());
|
||||
|
||||
EXPECT_EQ(trimListUnusedPosition, ((WddmAllocation *)commandBuffer)->getTrimCandidateListPosition(csr->getOsContext().getContextId()));
|
||||
EXPECT_EQ(trimListUnusedPosition, static_cast<WddmAllocation *>(commandBuffer)->getTrimCandidateListPosition(csr->getOsContext().getContextId()));
|
||||
|
||||
csr->processResidency(csr->getResidencyAllocations());
|
||||
|
||||
@@ -688,7 +688,7 @@ TEST_F(WddmCommandStreamMockGdiTest, makeResidentClearsResidencyAllocations) {
|
||||
EXPECT_EQ(0u, csr->getResidencyAllocations().size());
|
||||
EXPECT_EQ(0u, csr->getEvictionAllocations().size());
|
||||
|
||||
EXPECT_EQ(0u, ((WddmAllocation *)commandBuffer)->getTrimCandidateListPosition(csr->getOsContext().getContextId()));
|
||||
EXPECT_EQ(0u, static_cast<WddmAllocation *>(commandBuffer)->getTrimCandidateListPosition(csr->getOsContext().getContextId()));
|
||||
|
||||
memoryManager->freeGraphicsMemory(commandBuffer);
|
||||
}
|
||||
@@ -744,12 +744,12 @@ HWTEST_F(WddmCommandStreamMockGdiTest, givenRecordedCommandBufferWhenItIsSubmitt
|
||||
EXPECT_EQ(6u + csrSurfaceCount, wddm->makeResidentResult.handleCount);
|
||||
|
||||
std::vector<D3DKMT_HANDLE> expectedHandles;
|
||||
expectedHandles.push_back(((WddmAllocation *)tagAllocation)->handle);
|
||||
expectedHandles.push_back(((WddmAllocation *)commandBuffer)->handle);
|
||||
expectedHandles.push_back(((WddmAllocation *)dshAlloc)->handle);
|
||||
expectedHandles.push_back(((WddmAllocation *)iohAlloc)->handle);
|
||||
expectedHandles.push_back(((WddmAllocation *)sshAlloc)->handle);
|
||||
expectedHandles.push_back(((WddmAllocation *)csrCommandStream)->handle);
|
||||
expectedHandles.push_back(static_cast<WddmAllocation *>(tagAllocation)->getDefaultHandle());
|
||||
expectedHandles.push_back(static_cast<WddmAllocation *>(commandBuffer)->getDefaultHandle());
|
||||
expectedHandles.push_back(static_cast<WddmAllocation *>(dshAlloc)->getDefaultHandle());
|
||||
expectedHandles.push_back(static_cast<WddmAllocation *>(iohAlloc)->getDefaultHandle());
|
||||
expectedHandles.push_back(static_cast<WddmAllocation *>(sshAlloc)->getDefaultHandle());
|
||||
expectedHandles.push_back(static_cast<WddmAllocation *>(csrCommandStream)->getDefaultHandle());
|
||||
|
||||
for (auto i = 0u; i < wddm->makeResidentResult.handleCount; i++) {
|
||||
auto handle = wddm->makeResidentResult.handlePack[i];
|
||||
@@ -762,12 +762,12 @@ HWTEST_F(WddmCommandStreamMockGdiTest, givenRecordedCommandBufferWhenItIsSubmitt
|
||||
EXPECT_TRUE(found);
|
||||
}
|
||||
|
||||
EXPECT_NE(trimListUnusedPosition, ((WddmAllocation *)tagAllocation)->getTrimCandidateListPosition(csr->getOsContext().getContextId()));
|
||||
EXPECT_NE(trimListUnusedPosition, ((WddmAllocation *)commandBuffer)->getTrimCandidateListPosition(csr->getOsContext().getContextId()));
|
||||
EXPECT_EQ(trimListUnusedPosition, ((WddmAllocation *)dshAlloc)->getTrimCandidateListPosition(csr->getOsContext().getContextId()));
|
||||
EXPECT_EQ(trimListUnusedPosition, ((WddmAllocation *)iohAlloc)->getTrimCandidateListPosition(csr->getOsContext().getContextId()));
|
||||
EXPECT_NE(trimListUnusedPosition, ((WddmAllocation *)sshAlloc)->getTrimCandidateListPosition(csr->getOsContext().getContextId()));
|
||||
EXPECT_NE(trimListUnusedPosition, ((WddmAllocation *)csrCommandStream)->getTrimCandidateListPosition(csr->getOsContext().getContextId()));
|
||||
EXPECT_NE(trimListUnusedPosition, static_cast<WddmAllocation *>(tagAllocation)->getTrimCandidateListPosition(csr->getOsContext().getContextId()));
|
||||
EXPECT_NE(trimListUnusedPosition, static_cast<WddmAllocation *>(commandBuffer)->getTrimCandidateListPosition(csr->getOsContext().getContextId()));
|
||||
EXPECT_EQ(trimListUnusedPosition, static_cast<WddmAllocation *>(dshAlloc)->getTrimCandidateListPosition(csr->getOsContext().getContextId()));
|
||||
EXPECT_EQ(trimListUnusedPosition, static_cast<WddmAllocation *>(iohAlloc)->getTrimCandidateListPosition(csr->getOsContext().getContextId()));
|
||||
EXPECT_NE(trimListUnusedPosition, static_cast<WddmAllocation *>(sshAlloc)->getTrimCandidateListPosition(csr->getOsContext().getContextId()));
|
||||
EXPECT_NE(trimListUnusedPosition, static_cast<WddmAllocation *>(csrCommandStream)->getTrimCandidateListPosition(csr->getOsContext().getContextId()));
|
||||
|
||||
memoryManager->freeGraphicsMemory(dshAlloc);
|
||||
memoryManager->freeGraphicsMemory(iohAlloc);
|
||||
|
||||
@@ -12,11 +12,14 @@ namespace OCLRT {
|
||||
|
||||
class MockWddmAllocation : public WddmAllocation {
|
||||
public:
|
||||
MockWddmAllocation() : WddmAllocation(GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false), gpuPtr(gpuAddress) {
|
||||
MockWddmAllocation() : WddmAllocation(GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false), gpuPtr(gpuAddress), handle(handles[0]) {
|
||||
}
|
||||
using WddmAllocation::cpuPtr;
|
||||
using WddmAllocation::memoryPool;
|
||||
using WddmAllocation::size;
|
||||
|
||||
D3DGPU_VIRTUAL_ADDRESS &gpuPtr;
|
||||
D3DKMT_HANDLE &handle;
|
||||
};
|
||||
|
||||
} // namespace OCLRT
|
||||
|
||||
@@ -79,7 +79,7 @@ TEST_F(Wddm20Tests, givenNullPageTableManagerAndRenderCompressedResourceWhenMapp
|
||||
void *fakePtr = reinterpret_cast<void *>(0x100);
|
||||
WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, fakePtr, 0x2100, nullptr, MemoryPool::MemoryNull, false);
|
||||
allocation.gmm = gmm.get();
|
||||
allocation.handle = ALLOCATION_HANDLE;
|
||||
allocation.getHandleToModify(0u) = ALLOCATION_HANDLE;
|
||||
|
||||
EXPECT_TRUE(wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr()));
|
||||
}
|
||||
@@ -178,7 +178,7 @@ TEST_F(Wddm20Tests, allocation) {
|
||||
auto status = wddm->createAllocation(&allocation);
|
||||
|
||||
EXPECT_EQ(STATUS_SUCCESS, status);
|
||||
EXPECT_TRUE(allocation.handle != 0);
|
||||
EXPECT_TRUE(allocation.getDefaultHandle() != 0);
|
||||
|
||||
auto error = wddm->destroyAllocation(&allocation, osContext.get());
|
||||
EXPECT_TRUE(error);
|
||||
@@ -202,7 +202,7 @@ TEST_F(Wddm20WithMockGdiDllTests, givenAllocationSmallerUnderlyingThanAlignedSiz
|
||||
auto status = wddm->createAllocation(&allocation);
|
||||
|
||||
EXPECT_EQ(STATUS_SUCCESS, status);
|
||||
EXPECT_NE(0, allocation.handle);
|
||||
EXPECT_NE(0, allocation.getDefaultHandle());
|
||||
|
||||
bool ret = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr());
|
||||
EXPECT_TRUE(ret);
|
||||
@@ -257,10 +257,7 @@ TEST_F(Wddm20Tests, createAllocation32bit) {
|
||||
uint64_t heap32Size = 0x40000;
|
||||
wddm->setHeap32(heap32baseAddress, heap32Size);
|
||||
|
||||
void *alignedPtr = (void *)0x12000;
|
||||
size_t alignedSize = 0x2000;
|
||||
|
||||
WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, alignedPtr, alignedSize, nullptr, MemoryPool::MemoryNull, false);
|
||||
MockWddmAllocation allocation;
|
||||
Gmm *gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize());
|
||||
|
||||
allocation.gmm = gmm;
|
||||
@@ -290,7 +287,7 @@ TEST_F(Wddm20Tests, givenGraphicsAllocationWhenItIsMappedInHeap0ThenItHasGpuAddr
|
||||
size_t alignedSize = 0x2000;
|
||||
WddmAllocation allocation(GraphicsAllocation::AllocationType::KERNEL_ISA, alignedPtr, alignedSize, nullptr, MemoryPool::MemoryNull, false);
|
||||
|
||||
allocation.handle = ALLOCATION_HANDLE;
|
||||
allocation.getHandleToModify(0u) = ALLOCATION_HANDLE;
|
||||
allocation.gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize());
|
||||
EXPECT_EQ(internalHeapIndex, MemoryManager::selectHeap(&allocation, allocation.getAlignedCpuPtr(), *hardwareInfoTable[wddm->getGfxPlatform()->eProductFamily]));
|
||||
bool ret = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr());
|
||||
@@ -345,7 +342,7 @@ TEST_F(Wddm20Tests, mapAndFreeGpuVa) {
|
||||
auto status = wddm->createAllocation(&allocation);
|
||||
|
||||
EXPECT_EQ(STATUS_SUCCESS, status);
|
||||
EXPECT_TRUE(allocation.handle != 0);
|
||||
EXPECT_TRUE(allocation.getDefaultHandle() != 0);
|
||||
|
||||
auto error = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr());
|
||||
EXPECT_TRUE(error);
|
||||
@@ -390,17 +387,17 @@ TEST_F(Wddm20Tests, makeResidentNonResident) {
|
||||
auto status = wddm->createAllocation(&allocation);
|
||||
|
||||
EXPECT_EQ(STATUS_SUCCESS, status);
|
||||
EXPECT_TRUE(allocation.handle != 0);
|
||||
EXPECT_TRUE(allocation.getDefaultHandle() != 0);
|
||||
|
||||
auto error = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr());
|
||||
EXPECT_TRUE(error);
|
||||
EXPECT_TRUE(allocation.getGpuAddress() != 0);
|
||||
|
||||
error = wddm->makeResident(&allocation.handle, 1, false, nullptr);
|
||||
error = wddm->makeResident(allocation.getHandles().data(), allocation.getNumHandles(), false, nullptr);
|
||||
EXPECT_TRUE(error);
|
||||
|
||||
uint64_t sizeToTrim;
|
||||
error = wddm->evict(&allocation.handle, 1, sizeToTrim);
|
||||
error = wddm->evict(allocation.getHandles().data(), allocation.getNumHandles(), sizeToTrim);
|
||||
EXPECT_TRUE(error);
|
||||
|
||||
auto monitoredFence = osContext->getResidencyController().getMonitoredFence();
|
||||
@@ -429,8 +426,8 @@ TEST_F(Wddm20WithMockGdiDllTests, givenSharedHandleWhenCreateGraphicsAllocationF
|
||||
|
||||
EXPECT_EQ(ALLOCATION_HANDLE, wddmAllocation->peekSharedHandle());
|
||||
EXPECT_EQ(RESOURCE_HANDLE, wddmAllocation->resourceHandle);
|
||||
EXPECT_NE(0u, wddmAllocation->handle);
|
||||
EXPECT_EQ(ALLOCATION_HANDLE, wddmAllocation->handle);
|
||||
EXPECT_NE(0u, wddmAllocation->getDefaultHandle());
|
||||
EXPECT_EQ(ALLOCATION_HANDLE, wddmAllocation->getDefaultHandle());
|
||||
EXPECT_NE(0u, wddmAllocation->getGpuAddress());
|
||||
EXPECT_EQ(4096u, wddmAllocation->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(nullptr, wddmAllocation->getAlignedCpuPtr());
|
||||
@@ -593,15 +590,8 @@ TEST(DebugFlagTest, givenDebugManagerWhenGetForUseNoRingFlushesKmdModeIsCalledTh
|
||||
}
|
||||
|
||||
TEST_F(Wddm20Tests, makeResidentMultipleHandles) {
|
||||
OsAgnosticMemoryManager mm(false, false, executionEnvironment);
|
||||
WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, mm.allocateSystemMemory(100, 0), 100, nullptr, MemoryPool::MemoryNull, false);
|
||||
allocation.handle = ALLOCATION_HANDLE;
|
||||
|
||||
D3DKMT_HANDLE handles[2] = {0};
|
||||
|
||||
handles[0] = allocation.handle;
|
||||
handles[1] = allocation.handle;
|
||||
|
||||
D3DKMT_HANDLE handles[2] = {ALLOCATION_HANDLE, ALLOCATION_HANDLE};
|
||||
gdi->getMakeResidentArg().NumAllocations = 0;
|
||||
gdi->getMakeResidentArg().AllocationList = nullptr;
|
||||
|
||||
@@ -610,19 +600,10 @@ TEST_F(Wddm20Tests, makeResidentMultipleHandles) {
|
||||
|
||||
EXPECT_EQ(2u, gdi->getMakeResidentArg().NumAllocations);
|
||||
EXPECT_EQ(handles, gdi->getMakeResidentArg().AllocationList);
|
||||
|
||||
mm.freeSystemMemory(allocation.getUnderlyingBuffer());
|
||||
}
|
||||
|
||||
TEST_F(Wddm20Tests, makeResidentMultipleHandlesWithReturnBytesToTrim) {
|
||||
OsAgnosticMemoryManager mm(false, false, executionEnvironment);
|
||||
WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, mm.allocateSystemMemory(100, 0), 100, nullptr, MemoryPool::MemoryNull, false);
|
||||
allocation.handle = ALLOCATION_HANDLE;
|
||||
|
||||
D3DKMT_HANDLE handles[2] = {0};
|
||||
|
||||
handles[0] = allocation.handle;
|
||||
handles[1] = allocation.handle;
|
||||
D3DKMT_HANDLE handles[2] = {ALLOCATION_HANDLE, ALLOCATION_HANDLE};
|
||||
|
||||
gdi->getMakeResidentArg().NumAllocations = 0;
|
||||
gdi->getMakeResidentArg().AllocationList = nullptr;
|
||||
@@ -633,8 +614,6 @@ TEST_F(Wddm20Tests, makeResidentMultipleHandlesWithReturnBytesToTrim) {
|
||||
EXPECT_TRUE(success);
|
||||
|
||||
EXPECT_EQ(gdi->getMakeResidentArg().NumBytesToTrim, bytesToTrim);
|
||||
|
||||
mm.freeSystemMemory(allocation.getUnderlyingBuffer());
|
||||
}
|
||||
|
||||
TEST_F(Wddm20Tests, makeNonResidentCallsEvict) {
|
||||
@@ -656,7 +635,7 @@ TEST_F(Wddm20Tests, makeNonResidentCallsEvict) {
|
||||
}
|
||||
|
||||
TEST_F(Wddm20Tests, givenDestroyAllocationWhenItIsCalledThenAllocationIsPassedToDestroyAllocation) {
|
||||
WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, (void *)0x23000, 0x1000, nullptr, MemoryPool::MemoryNull, false);
|
||||
MockWddmAllocation allocation;
|
||||
allocation.getResidencyData().updateCompletionData(10, osContext->getContextId());
|
||||
allocation.handle = ALLOCATION_HANDLE;
|
||||
|
||||
@@ -682,7 +661,7 @@ TEST_F(Wddm20Tests, givenDestroyAllocationWhenItIsCalledThenAllocationIsPassedTo
|
||||
}
|
||||
|
||||
TEST_F(Wddm20Tests, WhenLastFenceLessEqualThanMonitoredThenWaitFromCpuIsNotCalled) {
|
||||
WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, (void *)0x23000, 0x1000, nullptr, MemoryPool::MemoryNull, false);
|
||||
MockWddmAllocation allocation;
|
||||
allocation.getResidencyData().updateCompletionData(10, osContext->getContextId());
|
||||
allocation.handle = ALLOCATION_HANDLE;
|
||||
|
||||
@@ -705,7 +684,7 @@ TEST_F(Wddm20Tests, WhenLastFenceLessEqualThanMonitoredThenWaitFromCpuIsNotCalle
|
||||
}
|
||||
|
||||
TEST_F(Wddm20Tests, WhenLastFenceGreaterThanMonitoredThenWaitFromCpuIsCalled) {
|
||||
WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, (void *)0x23000, 0x1000, nullptr, MemoryPool::MemoryNull, false);
|
||||
MockWddmAllocation allocation;
|
||||
allocation.getResidencyData().updateCompletionData(10, osContext->getContextId());
|
||||
allocation.handle = ALLOCATION_HANDLE;
|
||||
|
||||
@@ -869,14 +848,14 @@ TEST_F(WddmLockWithMakeResidentTests, givenAllocationWhenApplyBlockingMakeReside
|
||||
EXPECT_EQ(3u, wddm->getPagingFenceAddressResult.called);
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, givenAllocationWhenApplyBlockingMakeResidentAndMakeResidentCallFailsThenEvictTemporaryResourcesAndRetry) {
|
||||
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
||||
MockWddmAllocation allocation;
|
||||
GmockWddm gmockWddm;
|
||||
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_)).Times(2).WillRepeatedly(::testing::Return(false));
|
||||
gmockWddm.applyBlockingMakeResident(allocation.handle);
|
||||
EXPECT_EQ(1u, gmockWddm.evictAllTemporaryResourcesResult.called);
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndTemporaryResourcesAreEvictedSuccessfullyThenCallMakeResidentOneMoreTime) {
|
||||
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
||||
MockWddmAllocation allocation;
|
||||
GmockWddm gmockWddm;
|
||||
gmockWddm.temporaryResources.push_back(allocation.handle);
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillRepeatedly(::testing::Return(true));
|
||||
@@ -885,7 +864,7 @@ TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndTemporaryR
|
||||
EXPECT_EQ(2u, gmockWddm.evictAllTemporaryResourcesResult.called);
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeResidentStillFailsThenDontStoreTemporaryResource) {
|
||||
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
||||
MockWddmAllocation allocation;
|
||||
allocation.handle = 0x2;
|
||||
GmockWddm gmockWddm;
|
||||
gmockWddm.temporaryResources.push_back(0x1);
|
||||
@@ -896,7 +875,7 @@ TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeReside
|
||||
EXPECT_EQ(0u, gmockWddm.temporaryResources.size());
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeResidentPassesAfterEvictThenStoreTemporaryResource) {
|
||||
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
||||
MockWddmAllocation allocation;
|
||||
allocation.handle = 0x2;
|
||||
GmockWddm gmockWddm;
|
||||
gmockWddm.temporaryResources.push_back(0x1);
|
||||
@@ -908,7 +887,7 @@ TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeReside
|
||||
EXPECT_EQ(0x2, gmockWddm.temporaryResources.back());
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeResidentPassesThenStoreTemporaryResource) {
|
||||
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
||||
MockWddmAllocation allocation;
|
||||
allocation.handle = 0x2;
|
||||
GmockWddm gmockWddm;
|
||||
gmockWddm.temporaryResources.push_back(0x1);
|
||||
@@ -927,7 +906,7 @@ TEST_F(WddmLockWithMakeResidentTests, whenEvictingAllTemporaryResourcesThenAcqui
|
||||
EXPECT_EQ(reinterpret_cast<uint64_t>(&wddm->temporaryResourcesLock), wddm->acquireLockResult.uint64ParamPassed);
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenEvictingAllTemporaryResourcesAndAllEvictionsSucceedThenReturnSuccess) {
|
||||
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
||||
MockWddmAllocation allocation;
|
||||
GmockWddm gmockWddm;
|
||||
gmockWddm.temporaryResources.push_back(allocation.handle);
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillOnce(::testing::Return(true));
|
||||
|
||||
@@ -75,17 +75,17 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenUnlockResourceIsCalledThenKmDafListen
|
||||
|
||||
TEST_F(WddmKmDafListenerTest, givenWddmWhenMapGpuVirtualAddressIsCalledThenKmDafListenerNotifyMapGpuVAIsFedWithCorrectParams) {
|
||||
WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, (void *)0x23000, 0x1000, nullptr, MemoryPool::MemoryNull, false);
|
||||
allocation.handle = ALLOCATION_HANDLE;
|
||||
allocation.setDefaultHandle(ALLOCATION_HANDLE);
|
||||
auto gmm = std::unique_ptr<Gmm>(new Gmm(nullptr, 1, false));
|
||||
allocation.gmm = gmm.get();
|
||||
|
||||
auto heapIndex = MemoryManager::selectHeap(&allocation, allocation.getUnderlyingBuffer(), *platformDevices[0]);
|
||||
wddmWithKmDafMock->mapGpuVirtualAddressImpl(allocation.gmm, allocation.handle, allocation.getUnderlyingBuffer(), allocation.getGpuAddressToModify(), heapIndex);
|
||||
wddmWithKmDafMock->mapGpuVirtualAddressImpl(allocation.gmm, allocation.getDefaultHandle(), allocation.getUnderlyingBuffer(), allocation.getGpuAddressToModify(), heapIndex);
|
||||
|
||||
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);
|
||||
EXPECT_EQ(allocation.getDefaultHandle(), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hAllocation);
|
||||
EXPECT_EQ(GmmHelper::decanonize(allocation.getGpuAddress()), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.GpuVirtualAddress);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getGdi()->escape, wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.pfnEscape);
|
||||
}
|
||||
@@ -135,13 +135,14 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocationIsCalledThenKmDafList
|
||||
WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, (void *)0x23000, 0x1000, nullptr, MemoryPool::MemoryNull, false);
|
||||
auto gmm = std::unique_ptr<Gmm>(new Gmm(nullptr, 1, false));
|
||||
allocation.gmm = gmm.get();
|
||||
auto &handle = allocation.getHandleToModify(0u);
|
||||
|
||||
wddmWithKmDafMock->createAllocation(allocation.getAlignedCpuPtr(), gmm.get(), allocation.handle);
|
||||
wddmWithKmDafMock->createAllocation(allocation.getAlignedCpuPtr(), gmm.get(), handle);
|
||||
|
||||
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);
|
||||
EXPECT_EQ(handle, wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.hAllocation);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getGdi()->escape, wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.pfnEscape);
|
||||
}
|
||||
|
||||
@@ -149,13 +150,14 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocation64IsCalledThenKmDafLi
|
||||
WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, (void *)0x23000, 0x1000, nullptr, MemoryPool::MemoryNull, false);
|
||||
auto gmm = std::unique_ptr<Gmm>(new Gmm(nullptr, 1, false));
|
||||
allocation.gmm = gmm.get();
|
||||
auto &handle = allocation.getHandleToModify(0u);
|
||||
|
||||
wddmWithKmDafMock->createAllocation64k(gmm.get(), allocation.handle);
|
||||
wddmWithKmDafMock->createAllocation64k(gmm.get(), handle);
|
||||
|
||||
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);
|
||||
EXPECT_EQ(handle, wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.hAllocation);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getGdi()->escape, wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.pfnEscape);
|
||||
}
|
||||
|
||||
|
||||
@@ -268,8 +268,12 @@ TEST_F(WddmMemoryManagerTest, givenAllocationPropertiesWithMultiOsContextCapable
|
||||
TEST_F(WddmMemoryManagerTest, GivenGraphicsAllocationWhenAddAndRemoveAllocationToHostPtrManagerThenfragmentHasCorrectValues) {
|
||||
void *cpuPtr = (void *)0x30000;
|
||||
size_t size = 0x1000;
|
||||
uint64_t gpuPtr = 0x123;
|
||||
|
||||
WddmAllocation gfxAllocation(GraphicsAllocation::AllocationType::UNDECIDED, cpuPtr, size, nullptr, MemoryPool::MemoryNull, false);
|
||||
MockWddmAllocation gfxAllocation;
|
||||
gfxAllocation.cpuPtr = cpuPtr;
|
||||
gfxAllocation.size = size;
|
||||
gfxAllocation.gpuPtr = gpuPtr;
|
||||
memoryManager->addAllocationToHostPtrManager(&gfxAllocation);
|
||||
auto fragment = memoryManager->getHostPtrManager()->getFragment(gfxAllocation.getUnderlyingBuffer());
|
||||
EXPECT_NE(fragment, nullptr);
|
||||
@@ -279,7 +283,7 @@ TEST_F(WddmMemoryManagerTest, GivenGraphicsAllocationWhenAddAndRemoveAllocationT
|
||||
EXPECT_EQ(fragment->fragmentSize, size);
|
||||
EXPECT_NE(fragment->osInternalStorage, nullptr);
|
||||
EXPECT_EQ(fragment->osInternalStorage->gmm, gfxAllocation.gmm);
|
||||
EXPECT_NE(fragment->osInternalStorage->gpuPtr, 0ULL);
|
||||
EXPECT_EQ(fragment->osInternalStorage->gpuPtr, gpuPtr);
|
||||
EXPECT_EQ(fragment->osInternalStorage->handle, gfxAllocation.handle);
|
||||
EXPECT_NE(fragment->residency, nullptr);
|
||||
|
||||
@@ -338,7 +342,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromSharedHandleIs
|
||||
auto wddmAlloc = static_cast<WddmAllocation *>(gpuAllocation);
|
||||
ASSERT_NE(nullptr, gpuAllocation);
|
||||
EXPECT_EQ(RESOURCE_HANDLE, wddmAlloc->resourceHandle);
|
||||
EXPECT_EQ(ALLOCATION_HANDLE, wddmAlloc->handle);
|
||||
EXPECT_EQ(ALLOCATION_HANDLE, wddmAlloc->getDefaultHandle());
|
||||
|
||||
memoryManager->freeGraphicsMemory(gpuAllocation);
|
||||
}
|
||||
@@ -353,7 +357,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromNTHandleIsCall
|
||||
auto wddmAlloc = static_cast<WddmAllocation *>(gpuAllocation);
|
||||
ASSERT_NE(nullptr, gpuAllocation);
|
||||
EXPECT_EQ(NT_RESOURCE_HANDLE, wddmAlloc->resourceHandle);
|
||||
EXPECT_EQ(NT_ALLOCATION_HANDLE, wddmAlloc->handle);
|
||||
EXPECT_EQ(NT_ALLOCATION_HANDLE, wddmAlloc->getDefaultHandle());
|
||||
|
||||
memoryManager->freeGraphicsMemory(gpuAllocation);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user