mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 23:56:39 +08:00
Cleanup Wddm interface 3/3
don't pass the entire WddmAllocation when only handle is needed Change-Id: I208a64c81767589a2ac8aba0e717d54426209ecd Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
@@ -636,41 +636,41 @@ bool Wddm::openNTHandle(HANDLE handle, WddmAllocation *alloc) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *Wddm::lockResource(WddmAllocation &wddmAllocation) {
|
void *Wddm::lockResource(const D3DKMT_HANDLE &handle, bool applyMakeResidentPriorToLock) {
|
||||||
|
|
||||||
if (wddmAllocation.needsMakeResidentBeforeLock) {
|
if (applyMakeResidentPriorToLock) {
|
||||||
applyBlockingMakeResident(wddmAllocation);
|
applyBlockingMakeResident(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS status = STATUS_UNSUCCESSFUL;
|
NTSTATUS status = STATUS_UNSUCCESSFUL;
|
||||||
D3DKMT_LOCK2 lock2 = {};
|
D3DKMT_LOCK2 lock2 = {};
|
||||||
|
|
||||||
lock2.hAllocation = wddmAllocation.handle;
|
lock2.hAllocation = handle;
|
||||||
lock2.hDevice = this->device;
|
lock2.hDevice = this->device;
|
||||||
|
|
||||||
status = gdi->lock2(&lock2);
|
status = gdi->lock2(&lock2);
|
||||||
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
|
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
|
||||||
|
|
||||||
kmDafListener->notifyLock(featureTable->ftrKmdDaf, adapter, device, wddmAllocation.handle, 0, gdi->escape);
|
kmDafLock(handle);
|
||||||
|
|
||||||
return lock2.pData;
|
return lock2.pData;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wddm::unlockResource(WddmAllocation &wddmAllocation) {
|
void Wddm::unlockResource(const D3DKMT_HANDLE &handle) {
|
||||||
NTSTATUS status = STATUS_UNSUCCESSFUL;
|
NTSTATUS status = STATUS_UNSUCCESSFUL;
|
||||||
D3DKMT_UNLOCK2 unlock2 = {};
|
D3DKMT_UNLOCK2 unlock2 = {};
|
||||||
|
|
||||||
unlock2.hAllocation = wddmAllocation.handle;
|
unlock2.hAllocation = handle;
|
||||||
unlock2.hDevice = this->device;
|
unlock2.hDevice = this->device;
|
||||||
|
|
||||||
status = gdi->unlock2(&unlock2);
|
status = gdi->unlock2(&unlock2);
|
||||||
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
|
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
|
||||||
|
|
||||||
kmDafListener->notifyUnlock(featureTable->ftrKmdDaf, adapter, device, &wddmAllocation.handle, 1, gdi->escape);
|
kmDafListener->notifyUnlock(featureTable->ftrKmdDaf, adapter, device, &handle, 1, gdi->escape);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wddm::kmDafLock(WddmAllocation *wddmAllocation) {
|
void Wddm::kmDafLock(D3DKMT_HANDLE handle) {
|
||||||
kmDafListener->notifyLock(featureTable->ftrKmdDaf, adapter, device, wddmAllocation->handle, 0, gdi->escape);
|
kmDafListener->notifyLock(featureTable->ftrKmdDaf, adapter, device, handle, 0, gdi->escape);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Wddm::createContext(OsContextWin &osContext) {
|
bool Wddm::createContext(OsContextWin &osContext) {
|
||||||
@@ -970,27 +970,27 @@ EvictionStatus Wddm::evictAllTemporaryResources() {
|
|||||||
return error ? EvictionStatus::FAILED : EvictionStatus::SUCCESS;
|
return error ? EvictionStatus::FAILED : EvictionStatus::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
EvictionStatus Wddm::evictTemporaryResource(WddmAllocation &allocation) {
|
EvictionStatus Wddm::evictTemporaryResource(const D3DKMT_HANDLE &handle) {
|
||||||
auto lock = acquireLock(temporaryResourcesLock);
|
auto lock = acquireLock(temporaryResourcesLock);
|
||||||
auto position = std::find(temporaryResources.begin(), temporaryResources.end(), allocation.handle);
|
auto position = std::find(temporaryResources.begin(), temporaryResources.end(), handle);
|
||||||
if (position == temporaryResources.end()) {
|
if (position == temporaryResources.end()) {
|
||||||
return EvictionStatus::NOT_APPLIED;
|
return EvictionStatus::NOT_APPLIED;
|
||||||
}
|
}
|
||||||
*position = temporaryResources.back();
|
*position = temporaryResources.back();
|
||||||
temporaryResources.pop_back();
|
temporaryResources.pop_back();
|
||||||
uint64_t sizeToTrim = 0;
|
uint64_t sizeToTrim = 0;
|
||||||
if (!evict(&allocation.handle, 1, sizeToTrim)) {
|
if (!evict(&handle, 1, sizeToTrim)) {
|
||||||
return EvictionStatus::FAILED;
|
return EvictionStatus::FAILED;
|
||||||
}
|
}
|
||||||
return EvictionStatus::SUCCESS;
|
return EvictionStatus::SUCCESS;
|
||||||
}
|
}
|
||||||
void Wddm::applyBlockingMakeResident(WddmAllocation &allocation) {
|
void Wddm::applyBlockingMakeResident(const D3DKMT_HANDLE &handle) {
|
||||||
bool madeResident = false;
|
bool madeResident = false;
|
||||||
while (!(madeResident = makeResident(&allocation.handle, 1, false, nullptr))) {
|
while (!(madeResident = makeResident(&handle, 1, false, nullptr))) {
|
||||||
if (evictAllTemporaryResources() == EvictionStatus::SUCCESS) {
|
if (evictAllTemporaryResources() == EvictionStatus::SUCCESS) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!makeResident(&allocation.handle, 1, false, nullptr)) {
|
if (!makeResident(&handle, 1, false, nullptr)) {
|
||||||
DEBUG_BREAK_IF(true);
|
DEBUG_BREAK_IF(true);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
@@ -998,7 +998,7 @@ void Wddm::applyBlockingMakeResident(WddmAllocation &allocation) {
|
|||||||
}
|
}
|
||||||
DEBUG_BREAK_IF(!madeResident);
|
DEBUG_BREAK_IF(!madeResident);
|
||||||
auto lock = acquireLock(temporaryResourcesLock);
|
auto lock = acquireLock(temporaryResourcesLock);
|
||||||
temporaryResources.push_back(allocation.handle);
|
temporaryResources.push_back(handle);
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
while (currentPagingFenceValue > *getPagingFenceAddress())
|
while (currentPagingFenceValue > *getPagingFenceAddress())
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -69,9 +69,9 @@ class Wddm {
|
|||||||
MOCKABLE_VIRTUAL bool destroyAllocations(const D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle);
|
MOCKABLE_VIRTUAL bool destroyAllocations(const D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle);
|
||||||
MOCKABLE_VIRTUAL bool openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc);
|
MOCKABLE_VIRTUAL bool openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc);
|
||||||
bool openNTHandle(HANDLE handle, WddmAllocation *alloc);
|
bool openNTHandle(HANDLE handle, WddmAllocation *alloc);
|
||||||
MOCKABLE_VIRTUAL void *lockResource(WddmAllocation &wddmAllocation);
|
MOCKABLE_VIRTUAL void *lockResource(const D3DKMT_HANDLE &handle, bool applyMakeResidentPriorToLock);
|
||||||
MOCKABLE_VIRTUAL void unlockResource(WddmAllocation &wddmAllocation);
|
MOCKABLE_VIRTUAL void unlockResource(const D3DKMT_HANDLE &handle);
|
||||||
MOCKABLE_VIRTUAL void kmDafLock(WddmAllocation *wddmAllocation);
|
MOCKABLE_VIRTUAL void kmDafLock(D3DKMT_HANDLE handle);
|
||||||
MOCKABLE_VIRTUAL bool isKmDafEnabled() const { return featureTable->ftrKmdDaf; }
|
MOCKABLE_VIRTUAL bool isKmDafEnabled() const { return featureTable->ftrKmdDaf; }
|
||||||
|
|
||||||
MOCKABLE_VIRTUAL bool destroyContext(D3DKMT_HANDLE context);
|
MOCKABLE_VIRTUAL bool destroyContext(D3DKMT_HANDLE context);
|
||||||
@@ -147,8 +147,8 @@ class Wddm {
|
|||||||
return pagingFenceAddress;
|
return pagingFenceAddress;
|
||||||
}
|
}
|
||||||
MOCKABLE_VIRTUAL EvictionStatus evictAllTemporaryResources();
|
MOCKABLE_VIRTUAL EvictionStatus evictAllTemporaryResources();
|
||||||
MOCKABLE_VIRTUAL EvictionStatus evictTemporaryResource(WddmAllocation &allocation);
|
MOCKABLE_VIRTUAL EvictionStatus evictTemporaryResource(const D3DKMT_HANDLE &handle);
|
||||||
MOCKABLE_VIRTUAL void applyBlockingMakeResident(WddmAllocation &allocation);
|
MOCKABLE_VIRTUAL void applyBlockingMakeResident(const D3DKMT_HANDLE &handle);
|
||||||
MOCKABLE_VIRTUAL std::unique_lock<SpinLock> acquireLock(SpinLock &lock);
|
MOCKABLE_VIRTUAL std::unique_lock<SpinLock> acquireLock(SpinLock &lock);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ void WddmCommandStreamReceiver<GfxFamily>::kmDafLockAllocations(ResidencyContain
|
|||||||
if ((GraphicsAllocation::AllocationType::LINEAR_STREAM == graphicsAllocation->getAllocationType()) ||
|
if ((GraphicsAllocation::AllocationType::LINEAR_STREAM == graphicsAllocation->getAllocationType()) ||
|
||||||
(GraphicsAllocation::AllocationType::FILL_PATTERN == graphicsAllocation->getAllocationType()) ||
|
(GraphicsAllocation::AllocationType::FILL_PATTERN == graphicsAllocation->getAllocationType()) ||
|
||||||
(GraphicsAllocation::AllocationType::COMMAND_BUFFER == graphicsAllocation->getAllocationType())) {
|
(GraphicsAllocation::AllocationType::COMMAND_BUFFER == graphicsAllocation->getAllocationType())) {
|
||||||
wddm->kmDafLock(static_cast<WddmAllocation *>(graphicsAllocation));
|
wddm->kmDafLock(static_cast<WddmAllocation *>(graphicsAllocation)->handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -276,13 +276,14 @@ void WddmMemoryManager::removeAllocationFromHostPtrManager(GraphicsAllocation *g
|
|||||||
}
|
}
|
||||||
|
|
||||||
void *WddmMemoryManager::lockResourceImpl(GraphicsAllocation &graphicsAllocation) {
|
void *WddmMemoryManager::lockResourceImpl(GraphicsAllocation &graphicsAllocation) {
|
||||||
return wddm->lockResource(static_cast<WddmAllocation &>(graphicsAllocation));
|
auto &wddmAllocation = static_cast<WddmAllocation &>(graphicsAllocation);
|
||||||
|
return wddm->lockResource(wddmAllocation.handle, wddmAllocation.needsMakeResidentBeforeLock);
|
||||||
}
|
}
|
||||||
void WddmMemoryManager::unlockResourceImpl(GraphicsAllocation &graphicsAllocation) {
|
void WddmMemoryManager::unlockResourceImpl(GraphicsAllocation &graphicsAllocation) {
|
||||||
auto &wddmAllocation = static_cast<WddmAllocation &>(graphicsAllocation);
|
auto &wddmAllocation = static_cast<WddmAllocation &>(graphicsAllocation);
|
||||||
wddm->unlockResource(wddmAllocation);
|
wddm->unlockResource(wddmAllocation.handle);
|
||||||
if (wddmAllocation.needsMakeResidentBeforeLock) {
|
if (wddmAllocation.needsMakeResidentBeforeLock) {
|
||||||
auto evictionStatus = wddm->evictTemporaryResource(wddmAllocation);
|
auto evictionStatus = wddm->evictTemporaryResource(wddmAllocation.handle);
|
||||||
DEBUG_BREAK_IF(evictionStatus == EvictionStatus::FAILED);
|
DEBUG_BREAK_IF(evictionStatus == EvictionStatus::FAILED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,24 +146,25 @@ bool WddmMock::waitOnGPU(D3DKMT_HANDLE context) {
|
|||||||
return waitOnGPUResult.success = Wddm::waitOnGPU(context);
|
return waitOnGPUResult.success = Wddm::waitOnGPU(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *WddmMock::lockResource(WddmAllocation &allocation) {
|
void *WddmMock::lockResource(const D3DKMT_HANDLE &handle, bool applyMakeResidentPriorToLock) {
|
||||||
lockResult.called++;
|
lockResult.called++;
|
||||||
auto ptr = Wddm::lockResource(allocation);
|
auto ptr = Wddm::lockResource(handle, applyMakeResidentPriorToLock);
|
||||||
lockResult.success = ptr != nullptr;
|
lockResult.success = ptr != nullptr;
|
||||||
|
lockResult.uint64ParamPassed = applyMakeResidentPriorToLock;
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WddmMock::unlockResource(WddmAllocation &allocation) {
|
void WddmMock::unlockResource(const D3DKMT_HANDLE &handle) {
|
||||||
unlockResult.called++;
|
unlockResult.called++;
|
||||||
unlockResult.success = true;
|
unlockResult.success = true;
|
||||||
Wddm::unlockResource(allocation);
|
Wddm::unlockResource(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WddmMock::kmDafLock(WddmAllocation *allocation) {
|
void WddmMock::kmDafLock(D3DKMT_HANDLE handle) {
|
||||||
kmDafLockResult.called++;
|
kmDafLockResult.called++;
|
||||||
kmDafLockResult.success = true;
|
kmDafLockResult.success = true;
|
||||||
kmDafLockResult.lockedAllocations.push_back(allocation);
|
kmDafLockResult.lockedAllocations.push_back(handle);
|
||||||
Wddm::kmDafLock(allocation);
|
Wddm::kmDafLock(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WddmMock::isKmDafEnabled() const {
|
bool WddmMock::isKmDafEnabled() const {
|
||||||
@@ -242,15 +243,15 @@ EvictionStatus WddmMock::evictAllTemporaryResources() {
|
|||||||
return evictAllTemporaryResourcesResult.status;
|
return evictAllTemporaryResourcesResult.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
EvictionStatus WddmMock::evictTemporaryResource(WddmAllocation &allocation) {
|
EvictionStatus WddmMock::evictTemporaryResource(const D3DKMT_HANDLE &handle) {
|
||||||
evictTemporaryResourceResult.called++;
|
evictTemporaryResourceResult.called++;
|
||||||
evictTemporaryResourceResult.status = Wddm::evictTemporaryResource(allocation);
|
evictTemporaryResourceResult.status = Wddm::evictTemporaryResource(handle);
|
||||||
return evictTemporaryResourceResult.status;
|
return evictTemporaryResourceResult.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WddmMock::applyBlockingMakeResident(WddmAllocation &allocation) {
|
void WddmMock::applyBlockingMakeResident(const D3DKMT_HANDLE &handle) {
|
||||||
applyBlockingMakeResidentResult.called++;
|
applyBlockingMakeResidentResult.called++;
|
||||||
return Wddm::applyBlockingMakeResident(allocation);
|
return Wddm::applyBlockingMakeResident(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_lock<SpinLock> WddmMock::acquireLock(SpinLock &lock) {
|
std::unique_lock<SpinLock> WddmMock::acquireLock(SpinLock &lock) {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ struct EvictCallResult : public CallResult {
|
|||||||
EvictionStatus status = EvictionStatus::UNKNOWN;
|
EvictionStatus status = EvictionStatus::UNKNOWN;
|
||||||
};
|
};
|
||||||
struct KmDafLockCall : public CallResult {
|
struct KmDafLockCall : public CallResult {
|
||||||
std::vector<GraphicsAllocation *> lockedAllocations;
|
std::vector<D3DKMT_HANDLE> lockedAllocations;
|
||||||
};
|
};
|
||||||
} // namespace WddmMockHelpers
|
} // namespace WddmMockHelpers
|
||||||
|
|
||||||
@@ -76,9 +76,9 @@ class WddmMock : public Wddm {
|
|||||||
bool queryAdapterInfo() override;
|
bool queryAdapterInfo() override;
|
||||||
bool submit(uint64_t commandBuffer, size_t size, void *commandHeader, OsContextWin &osContext) override;
|
bool submit(uint64_t commandBuffer, size_t size, void *commandHeader, OsContextWin &osContext) override;
|
||||||
bool waitOnGPU(D3DKMT_HANDLE context) override;
|
bool waitOnGPU(D3DKMT_HANDLE context) override;
|
||||||
void *lockResource(WddmAllocation &allocation) override;
|
void *lockResource(const D3DKMT_HANDLE &handle, bool applyMakeResidentPriorToLock) override;
|
||||||
void unlockResource(WddmAllocation &allocation) override;
|
void unlockResource(const D3DKMT_HANDLE &handle) override;
|
||||||
void kmDafLock(WddmAllocation *allocation) override;
|
void kmDafLock(D3DKMT_HANDLE handle) override;
|
||||||
bool isKmDafEnabled() const override;
|
bool isKmDafEnabled() const override;
|
||||||
void setKmDafEnabled(bool state);
|
void setKmDafEnabled(bool state);
|
||||||
void setHwContextId(unsigned long hwContextId);
|
void setHwContextId(unsigned long hwContextId);
|
||||||
@@ -91,8 +91,8 @@ class WddmMock : public Wddm {
|
|||||||
void releaseReservedAddress(void *reservedAddress) override;
|
void releaseReservedAddress(void *reservedAddress) override;
|
||||||
VOID *registerTrimCallback(PFND3DKMT_TRIMNOTIFICATIONCALLBACK callback, WddmResidencyController &residencyController) override;
|
VOID *registerTrimCallback(PFND3DKMT_TRIMNOTIFICATIONCALLBACK callback, WddmResidencyController &residencyController) override;
|
||||||
EvictionStatus evictAllTemporaryResources() override;
|
EvictionStatus evictAllTemporaryResources() override;
|
||||||
EvictionStatus evictTemporaryResource(WddmAllocation &allocation) override;
|
EvictionStatus evictTemporaryResource(const D3DKMT_HANDLE &handle) override;
|
||||||
void applyBlockingMakeResident(WddmAllocation &allocation) override;
|
void applyBlockingMakeResident(const D3DKMT_HANDLE &handle) override;
|
||||||
std::unique_lock<SpinLock> acquireLock(SpinLock &lock) override;
|
std::unique_lock<SpinLock> acquireLock(SpinLock &lock) override;
|
||||||
bool reserveValidAddressRange(size_t size, void *&reservedMem);
|
bool reserveValidAddressRange(size_t size, void *&reservedMem);
|
||||||
GmmMemory *getGmmMemory() const;
|
GmmMemory *getGmmMemory() const;
|
||||||
|
|||||||
@@ -404,7 +404,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithResi
|
|||||||
LinearStream cs(commandBuffer);
|
LinearStream cs(commandBuffer);
|
||||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||||
|
|
||||||
auto linearStreamAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
auto linearStreamAllocation = static_cast<WddmAllocation *>(memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}));
|
||||||
ASSERT_NE(nullptr, linearStreamAllocation);
|
ASSERT_NE(nullptr, linearStreamAllocation);
|
||||||
linearStreamAllocation->setAllocationType(GraphicsAllocation::AllocationType::LINEAR_STREAM);
|
linearStreamAllocation->setAllocationType(GraphicsAllocation::AllocationType::LINEAR_STREAM);
|
||||||
|
|
||||||
@@ -417,7 +417,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithResi
|
|||||||
|
|
||||||
EXPECT_EQ(1u, wddm->kmDafLockResult.called);
|
EXPECT_EQ(1u, wddm->kmDafLockResult.called);
|
||||||
EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size());
|
EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size());
|
||||||
EXPECT_EQ(linearStreamAllocation, wddm->kmDafLockResult.lockedAllocations[0]);
|
EXPECT_EQ(linearStreamAllocation->handle, wddm->kmDafLockResult.lockedAllocations[0]);
|
||||||
|
|
||||||
memoryManager->freeGraphicsMemory(commandBuffer);
|
memoryManager->freeGraphicsMemory(commandBuffer);
|
||||||
memoryManager->freeGraphicsMemory(linearStreamAllocation);
|
memoryManager->freeGraphicsMemory(linearStreamAllocation);
|
||||||
@@ -429,7 +429,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllo
|
|||||||
LinearStream cs(commandBuffer);
|
LinearStream cs(commandBuffer);
|
||||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||||
|
|
||||||
auto linearStreamAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
auto linearStreamAllocation = static_cast<WddmAllocation *>(memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}));
|
||||||
ASSERT_NE(nullptr, linearStreamAllocation);
|
ASSERT_NE(nullptr, linearStreamAllocation);
|
||||||
linearStreamAllocation->setAllocationType(GraphicsAllocation::AllocationType::LINEAR_STREAM);
|
linearStreamAllocation->setAllocationType(GraphicsAllocation::AllocationType::LINEAR_STREAM);
|
||||||
ResidencyContainer allocationsForResidency = {linearStreamAllocation};
|
ResidencyContainer allocationsForResidency = {linearStreamAllocation};
|
||||||
@@ -439,7 +439,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllo
|
|||||||
|
|
||||||
EXPECT_EQ(1u, wddm->kmDafLockResult.called);
|
EXPECT_EQ(1u, wddm->kmDafLockResult.called);
|
||||||
EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size());
|
EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size());
|
||||||
EXPECT_EQ(linearStreamAllocation, wddm->kmDafLockResult.lockedAllocations[0]);
|
EXPECT_EQ(linearStreamAllocation->handle, wddm->kmDafLockResult.lockedAllocations[0]);
|
||||||
|
|
||||||
memoryManager->freeGraphicsMemory(commandBuffer);
|
memoryManager->freeGraphicsMemory(commandBuffer);
|
||||||
memoryManager->freeGraphicsMemory(linearStreamAllocation);
|
memoryManager->freeGraphicsMemory(linearStreamAllocation);
|
||||||
@@ -451,7 +451,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllo
|
|||||||
LinearStream cs(commandBuffer);
|
LinearStream cs(commandBuffer);
|
||||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||||
|
|
||||||
auto fillPatternAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
auto fillPatternAllocation = static_cast<WddmAllocation *>(memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}));
|
||||||
ASSERT_NE(nullptr, fillPatternAllocation);
|
ASSERT_NE(nullptr, fillPatternAllocation);
|
||||||
fillPatternAllocation->setAllocationType(GraphicsAllocation::AllocationType::FILL_PATTERN);
|
fillPatternAllocation->setAllocationType(GraphicsAllocation::AllocationType::FILL_PATTERN);
|
||||||
ResidencyContainer allocationsForResidency = {fillPatternAllocation};
|
ResidencyContainer allocationsForResidency = {fillPatternAllocation};
|
||||||
@@ -461,7 +461,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllo
|
|||||||
|
|
||||||
EXPECT_EQ(1u, wddm->kmDafLockResult.called);
|
EXPECT_EQ(1u, wddm->kmDafLockResult.called);
|
||||||
EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size());
|
EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size());
|
||||||
EXPECT_EQ(fillPatternAllocation, wddm->kmDafLockResult.lockedAllocations[0]);
|
EXPECT_EQ(fillPatternAllocation->handle, wddm->kmDafLockResult.lockedAllocations[0]);
|
||||||
|
|
||||||
memoryManager->freeGraphicsMemory(commandBuffer);
|
memoryManager->freeGraphicsMemory(commandBuffer);
|
||||||
memoryManager->freeGraphicsMemory(fillPatternAllocation);
|
memoryManager->freeGraphicsMemory(fillPatternAllocation);
|
||||||
@@ -473,7 +473,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllo
|
|||||||
LinearStream cs(commandBuffer);
|
LinearStream cs(commandBuffer);
|
||||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||||
|
|
||||||
auto commandBufferAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
auto commandBufferAllocation = static_cast<WddmAllocation *>(memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}));
|
||||||
ASSERT_NE(nullptr, commandBufferAllocation);
|
ASSERT_NE(nullptr, commandBufferAllocation);
|
||||||
commandBufferAllocation->setAllocationType(GraphicsAllocation::AllocationType::COMMAND_BUFFER);
|
commandBufferAllocation->setAllocationType(GraphicsAllocation::AllocationType::COMMAND_BUFFER);
|
||||||
ResidencyContainer allocationsForResidency = {commandBufferAllocation};
|
ResidencyContainer allocationsForResidency = {commandBufferAllocation};
|
||||||
@@ -483,7 +483,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllo
|
|||||||
|
|
||||||
EXPECT_EQ(1u, wddm->kmDafLockResult.called);
|
EXPECT_EQ(1u, wddm->kmDafLockResult.called);
|
||||||
EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size());
|
EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size());
|
||||||
EXPECT_EQ(commandBufferAllocation, wddm->kmDafLockResult.lockedAllocations[0]);
|
EXPECT_EQ(commandBufferAllocation->handle, wddm->kmDafLockResult.lockedAllocations[0]);
|
||||||
|
|
||||||
memoryManager->freeGraphicsMemory(commandBuffer);
|
memoryManager->freeGraphicsMemory(commandBuffer);
|
||||||
memoryManager->freeGraphicsMemory(commandBufferAllocation);
|
memoryManager->freeGraphicsMemory(commandBufferAllocation);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "runtime/os_interface/windows/wddm_memory_manager.h"
|
#include "runtime/os_interface/windows/wddm_memory_manager.h"
|
||||||
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
||||||
#include "unit_tests/mocks/mock_gmm_resource_info.h"
|
#include "unit_tests/mocks/mock_gmm_resource_info.h"
|
||||||
|
#include "unit_tests/os_interface/windows/mock_wddm_allocation.h"
|
||||||
#include "unit_tests/os_interface/windows/wddm_fixture.h"
|
#include "unit_tests/os_interface/windows/wddm_fixture.h"
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
@@ -835,60 +836,55 @@ TEST_F(Wddm20Tests, givenNullTrimCallbackHandleWhenUnregisteringTrimCallbackThen
|
|||||||
EXPECT_EQ(trimCallbackHandleBefore, gdi->getUnregisterTrimNotificationArg().Handle);
|
EXPECT_EQ(trimCallbackHandleBefore, gdi->getUnregisterTrimNotificationArg().Handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(Wddm20Tests, givenAllocationThatDoesntNeedMakeResidentBeforeLockWhenLockThenDontStoreItOrCallMakeResident) {
|
using WddmLockWithMakeResidentTests = Wddm20Tests;
|
||||||
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
|
||||||
EXPECT_FALSE(allocation.needsMakeResidentBeforeLock);
|
TEST_F(WddmLockWithMakeResidentTests, givenAllocationThatDoesntNeedMakeResidentBeforeLockWhenLockThenDontStoreItOrCallMakeResident) {
|
||||||
EXPECT_TRUE(wddm->temporaryResources.empty());
|
EXPECT_TRUE(wddm->temporaryResources.empty());
|
||||||
EXPECT_EQ(0u, wddm->makeResidentResult.called);
|
EXPECT_EQ(0u, wddm->makeResidentResult.called);
|
||||||
wddm->lockResource(allocation);
|
wddm->lockResource(ALLOCATION_HANDLE, false);
|
||||||
EXPECT_TRUE(wddm->temporaryResources.empty());
|
EXPECT_TRUE(wddm->temporaryResources.empty());
|
||||||
EXPECT_EQ(0u, wddm->makeResidentResult.called);
|
EXPECT_EQ(0u, wddm->makeResidentResult.called);
|
||||||
wddm->unlockResource(allocation);
|
wddm->unlockResource(ALLOCATION_HANDLE);
|
||||||
}
|
}
|
||||||
TEST_F(Wddm20Tests, givenAllocationThatNeedsMakeResidentBeforeLockWhenLockThenCallBlockingMakeResident) {
|
TEST_F(WddmLockWithMakeResidentTests, givenAllocationThatNeedsMakeResidentBeforeLockWhenLockThenCallBlockingMakeResident) {
|
||||||
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
wddm->lockResource(ALLOCATION_HANDLE, true);
|
||||||
allocation.needsMakeResidentBeforeLock = true;
|
|
||||||
wddm->lockResource(allocation);
|
|
||||||
EXPECT_EQ(1u, wddm->applyBlockingMakeResidentResult.called);
|
EXPECT_EQ(1u, wddm->applyBlockingMakeResidentResult.called);
|
||||||
}
|
}
|
||||||
TEST_F(Wddm20Tests, givenAllocationWhenApplyBlockingMakeResidentThenAcquireUniqueLock) {
|
TEST_F(WddmLockWithMakeResidentTests, givenAllocationWhenApplyBlockingMakeResidentThenAcquireUniqueLock) {
|
||||||
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
wddm->applyBlockingMakeResident(ALLOCATION_HANDLE);
|
||||||
wddm->applyBlockingMakeResident(allocation);
|
|
||||||
EXPECT_EQ(1u, wddm->acquireLockResult.called);
|
EXPECT_EQ(1u, wddm->acquireLockResult.called);
|
||||||
EXPECT_EQ(reinterpret_cast<uint64_t>(&wddm->temporaryResourcesLock), wddm->acquireLockResult.uint64ParamPassed);
|
EXPECT_EQ(reinterpret_cast<uint64_t>(&wddm->temporaryResourcesLock), wddm->acquireLockResult.uint64ParamPassed);
|
||||||
}
|
}
|
||||||
TEST_F(Wddm20Tests, givenAllocationWhenApplyBlockingMakeResidentThenCallMakeResidentAndStoreAllocation) {
|
TEST_F(WddmLockWithMakeResidentTests, givenAllocationWhenApplyBlockingMakeResidentThenCallMakeResidentAndStoreAllocation) {
|
||||||
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
wddm->applyBlockingMakeResident(ALLOCATION_HANDLE);
|
||||||
wddm->applyBlockingMakeResident(allocation);
|
|
||||||
EXPECT_EQ(1u, wddm->makeResidentResult.called);
|
EXPECT_EQ(1u, wddm->makeResidentResult.called);
|
||||||
EXPECT_EQ(allocation.handle, wddm->temporaryResources.back());
|
EXPECT_EQ(ALLOCATION_HANDLE, wddm->temporaryResources.back());
|
||||||
}
|
}
|
||||||
TEST_F(Wddm20Tests, givenAllocationWhenApplyBlockingMakeResidentThenWaitForCurrentPagingFenceValue) {
|
TEST_F(WddmLockWithMakeResidentTests, givenAllocationWhenApplyBlockingMakeResidentThenWaitForCurrentPagingFenceValue) {
|
||||||
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
|
||||||
wddm->mockPagingFence = 0u;
|
wddm->mockPagingFence = 0u;
|
||||||
wddm->currentPagingFenceValue = 3u;
|
wddm->currentPagingFenceValue = 3u;
|
||||||
wddm->applyBlockingMakeResident(allocation);
|
wddm->applyBlockingMakeResident(ALLOCATION_HANDLE);
|
||||||
EXPECT_EQ(1u, wddm->makeResidentResult.called);
|
EXPECT_EQ(1u, wddm->makeResidentResult.called);
|
||||||
EXPECT_EQ(3u, wddm->mockPagingFence);
|
EXPECT_EQ(3u, wddm->mockPagingFence);
|
||||||
EXPECT_EQ(3u, wddm->getPagingFenceAddressResult.called);
|
EXPECT_EQ(3u, wddm->getPagingFenceAddressResult.called);
|
||||||
}
|
}
|
||||||
TEST_F(Wddm20Tests, givenAllocationWhenApplyBlockingMakeResidentAndMakeResidentCallFailsThenEvictTemporaryResourcesAndRetry) {
|
TEST_F(WddmLockWithMakeResidentTests, givenAllocationWhenApplyBlockingMakeResidentAndMakeResidentCallFailsThenEvictTemporaryResourcesAndRetry) {
|
||||||
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
||||||
GmockWddm gmockWddm;
|
GmockWddm gmockWddm;
|
||||||
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_)).Times(2).WillRepeatedly(::testing::Return(false));
|
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_)).Times(2).WillRepeatedly(::testing::Return(false));
|
||||||
gmockWddm.applyBlockingMakeResident(allocation);
|
gmockWddm.applyBlockingMakeResident(allocation.handle);
|
||||||
EXPECT_EQ(1u, gmockWddm.evictAllTemporaryResourcesResult.called);
|
EXPECT_EQ(1u, gmockWddm.evictAllTemporaryResourcesResult.called);
|
||||||
}
|
}
|
||||||
TEST_F(Wddm20Tests, whenApplyBlockingMakeResidentAndTemporaryResourcesAreEvictedSuccessfullyThenCallMakeResidentOneMoreTime) {
|
TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndTemporaryResourcesAreEvictedSuccessfullyThenCallMakeResidentOneMoreTime) {
|
||||||
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
||||||
GmockWddm gmockWddm;
|
GmockWddm gmockWddm;
|
||||||
gmockWddm.temporaryResources.push_back(allocation.handle);
|
gmockWddm.temporaryResources.push_back(allocation.handle);
|
||||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillRepeatedly(::testing::Return(true));
|
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillRepeatedly(::testing::Return(true));
|
||||||
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_)).Times(3).WillRepeatedly(::testing::Return(false));
|
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_)).Times(3).WillRepeatedly(::testing::Return(false));
|
||||||
gmockWddm.applyBlockingMakeResident(allocation);
|
gmockWddm.applyBlockingMakeResident(allocation.handle);
|
||||||
EXPECT_EQ(2u, gmockWddm.evictAllTemporaryResourcesResult.called);
|
EXPECT_EQ(2u, gmockWddm.evictAllTemporaryResourcesResult.called);
|
||||||
}
|
}
|
||||||
TEST_F(Wddm20Tests, whenApplyBlockingMakeResidentAndMakeResidentStillFailsThenDontStoreTemporaryResource) {
|
TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeResidentStillFailsThenDontStoreTemporaryResource) {
|
||||||
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
||||||
allocation.handle = 0x2;
|
allocation.handle = 0x2;
|
||||||
GmockWddm gmockWddm;
|
GmockWddm gmockWddm;
|
||||||
@@ -896,10 +892,10 @@ TEST_F(Wddm20Tests, whenApplyBlockingMakeResidentAndMakeResidentStillFailsThenDo
|
|||||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillRepeatedly(::testing::Return(true));
|
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillRepeatedly(::testing::Return(true));
|
||||||
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_)).Times(3).WillRepeatedly(::testing::Return(false));
|
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_)).Times(3).WillRepeatedly(::testing::Return(false));
|
||||||
EXPECT_EQ(1u, gmockWddm.temporaryResources.size());
|
EXPECT_EQ(1u, gmockWddm.temporaryResources.size());
|
||||||
gmockWddm.applyBlockingMakeResident(allocation);
|
gmockWddm.applyBlockingMakeResident(allocation.handle);
|
||||||
EXPECT_EQ(0u, gmockWddm.temporaryResources.size());
|
EXPECT_EQ(0u, gmockWddm.temporaryResources.size());
|
||||||
}
|
}
|
||||||
TEST_F(Wddm20Tests, whenApplyBlockingMakeResidentAndMakeResidentPassesAfterEvictThenStoreTemporaryResource) {
|
TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeResidentPassesAfterEvictThenStoreTemporaryResource) {
|
||||||
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
||||||
allocation.handle = 0x2;
|
allocation.handle = 0x2;
|
||||||
GmockWddm gmockWddm;
|
GmockWddm gmockWddm;
|
||||||
@@ -907,30 +903,30 @@ TEST_F(Wddm20Tests, whenApplyBlockingMakeResidentAndMakeResidentPassesAfterEvict
|
|||||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillRepeatedly(::testing::Return(true));
|
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillRepeatedly(::testing::Return(true));
|
||||||
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_)).Times(2).WillOnce(::testing::Return(false)).WillOnce(::testing::Return(true));
|
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_)).Times(2).WillOnce(::testing::Return(false)).WillOnce(::testing::Return(true));
|
||||||
EXPECT_EQ(1u, gmockWddm.temporaryResources.size());
|
EXPECT_EQ(1u, gmockWddm.temporaryResources.size());
|
||||||
gmockWddm.applyBlockingMakeResident(allocation);
|
gmockWddm.applyBlockingMakeResident(allocation.handle);
|
||||||
EXPECT_EQ(1u, gmockWddm.temporaryResources.size());
|
EXPECT_EQ(1u, gmockWddm.temporaryResources.size());
|
||||||
EXPECT_EQ(0x2, gmockWddm.temporaryResources.back());
|
EXPECT_EQ(0x2, gmockWddm.temporaryResources.back());
|
||||||
}
|
}
|
||||||
TEST_F(Wddm20Tests, whenApplyBlockingMakeResidentAndMakeResidentPassesThenStoreTemporaryResource) {
|
TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeResidentPassesThenStoreTemporaryResource) {
|
||||||
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
||||||
allocation.handle = 0x2;
|
allocation.handle = 0x2;
|
||||||
GmockWddm gmockWddm;
|
GmockWddm gmockWddm;
|
||||||
gmockWddm.temporaryResources.push_back(0x1);
|
gmockWddm.temporaryResources.push_back(0x1);
|
||||||
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_)).Times(1).WillOnce(::testing::Return(true));
|
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_)).Times(1).WillOnce(::testing::Return(true));
|
||||||
gmockWddm.applyBlockingMakeResident(allocation);
|
gmockWddm.applyBlockingMakeResident(allocation.handle);
|
||||||
EXPECT_EQ(2u, gmockWddm.temporaryResources.size());
|
EXPECT_EQ(2u, gmockWddm.temporaryResources.size());
|
||||||
EXPECT_EQ(0x2, gmockWddm.temporaryResources.back());
|
EXPECT_EQ(0x2, gmockWddm.temporaryResources.back());
|
||||||
}
|
}
|
||||||
TEST_F(Wddm20Tests, givenNoTemporaryResourcesWhenEvictingAllTemporaryResourcesThenEvictionIsNotApplied) {
|
TEST_F(WddmLockWithMakeResidentTests, givenNoTemporaryResourcesWhenEvictingAllTemporaryResourcesThenEvictionIsNotApplied) {
|
||||||
wddm->evictAllTemporaryResources();
|
wddm->evictAllTemporaryResources();
|
||||||
EXPECT_EQ(EvictionStatus::NOT_APPLIED, wddm->evictAllTemporaryResourcesResult.status);
|
EXPECT_EQ(EvictionStatus::NOT_APPLIED, wddm->evictAllTemporaryResourcesResult.status);
|
||||||
}
|
}
|
||||||
TEST_F(Wddm20Tests, whenEvictingAllTemporaryResourcesThenAcquireTemporaryResourcesLock) {
|
TEST_F(WddmLockWithMakeResidentTests, whenEvictingAllTemporaryResourcesThenAcquireTemporaryResourcesLock) {
|
||||||
wddm->evictAllTemporaryResources();
|
wddm->evictAllTemporaryResources();
|
||||||
EXPECT_EQ(1u, wddm->acquireLockResult.called);
|
EXPECT_EQ(1u, wddm->acquireLockResult.called);
|
||||||
EXPECT_EQ(reinterpret_cast<uint64_t>(&wddm->temporaryResourcesLock), wddm->acquireLockResult.uint64ParamPassed);
|
EXPECT_EQ(reinterpret_cast<uint64_t>(&wddm->temporaryResourcesLock), wddm->acquireLockResult.uint64ParamPassed);
|
||||||
}
|
}
|
||||||
TEST_F(Wddm20Tests, whenEvictingAllTemporaryResourcesAndAllEvictionsSucceedThenReturnSuccess) {
|
TEST_F(WddmLockWithMakeResidentTests, whenEvictingAllTemporaryResourcesAndAllEvictionsSucceedThenReturnSuccess) {
|
||||||
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
||||||
GmockWddm gmockWddm;
|
GmockWddm gmockWddm;
|
||||||
gmockWddm.temporaryResources.push_back(allocation.handle);
|
gmockWddm.temporaryResources.push_back(allocation.handle);
|
||||||
@@ -939,7 +935,7 @@ TEST_F(Wddm20Tests, whenEvictingAllTemporaryResourcesAndAllEvictionsSucceedThenR
|
|||||||
EXPECT_EQ(1u, gmockWddm.evictAllTemporaryResourcesResult.called);
|
EXPECT_EQ(1u, gmockWddm.evictAllTemporaryResourcesResult.called);
|
||||||
EXPECT_EQ(EvictionStatus::SUCCESS, gmockWddm.evictAllTemporaryResourcesResult.status);
|
EXPECT_EQ(EvictionStatus::SUCCESS, gmockWddm.evictAllTemporaryResourcesResult.status);
|
||||||
}
|
}
|
||||||
TEST_F(Wddm20Tests, givenThreeAllocationsWhenEvictingAllTemporaryResourcesThenCallEvictForEachAllocationAndCleanList) {
|
TEST_F(WddmLockWithMakeResidentTests, givenThreeAllocationsWhenEvictingAllTemporaryResourcesThenCallEvictForEachAllocationAndCleanList) {
|
||||||
GmockWddm gmockWddm;
|
GmockWddm gmockWddm;
|
||||||
constexpr uint32_t numAllocations = 3u;
|
constexpr uint32_t numAllocations = 3u;
|
||||||
for (auto i = 0u; i < numAllocations; i++) {
|
for (auto i = 0u; i < numAllocations; i++) {
|
||||||
@@ -949,7 +945,7 @@ TEST_F(Wddm20Tests, givenThreeAllocationsWhenEvictingAllTemporaryResourcesThenCa
|
|||||||
gmockWddm.evictAllTemporaryResources();
|
gmockWddm.evictAllTemporaryResources();
|
||||||
EXPECT_TRUE(gmockWddm.temporaryResources.empty());
|
EXPECT_TRUE(gmockWddm.temporaryResources.empty());
|
||||||
}
|
}
|
||||||
TEST_F(Wddm20Tests, givenThreeAllocationsWhenEvictingAllTemporaryResourcesAndOneOfThemFailsThenReturnFail) {
|
TEST_F(WddmLockWithMakeResidentTests, givenThreeAllocationsWhenEvictingAllTemporaryResourcesAndOneOfThemFailsThenReturnFail) {
|
||||||
GmockWddm gmockWddm;
|
GmockWddm gmockWddm;
|
||||||
constexpr uint32_t numAllocations = 3u;
|
constexpr uint32_t numAllocations = 3u;
|
||||||
for (auto i = 0u; i < numAllocations; i++) {
|
for (auto i = 0u; i < numAllocations; i++) {
|
||||||
@@ -959,58 +955,66 @@ TEST_F(Wddm20Tests, givenThreeAllocationsWhenEvictingAllTemporaryResourcesAndOne
|
|||||||
gmockWddm.evictAllTemporaryResources();
|
gmockWddm.evictAllTemporaryResources();
|
||||||
EXPECT_EQ(EvictionStatus::FAILED, gmockWddm.evictAllTemporaryResourcesResult.status);
|
EXPECT_EQ(EvictionStatus::FAILED, gmockWddm.evictAllTemporaryResourcesResult.status);
|
||||||
}
|
}
|
||||||
TEST_F(Wddm20Tests, givenNoTemporaryResourcesWhenEvictingTemporaryResourceThenEvictionIsNotApplied) {
|
TEST_F(WddmLockWithMakeResidentTests, givenNoTemporaryResourcesWhenEvictingTemporaryResourceThenEvictionIsNotApplied) {
|
||||||
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
wddm->evictTemporaryResource(ALLOCATION_HANDLE);
|
||||||
wddm->evictTemporaryResource(allocation);
|
|
||||||
EXPECT_EQ(EvictionStatus::NOT_APPLIED, wddm->evictTemporaryResourceResult.status);
|
EXPECT_EQ(EvictionStatus::NOT_APPLIED, wddm->evictTemporaryResourceResult.status);
|
||||||
}
|
}
|
||||||
TEST_F(Wddm20Tests, whenEvictingTemporaryResourceThenAcquireTemporaryResourcesLock) {
|
TEST_F(WddmLockWithMakeResidentTests, whenEvictingTemporaryResourceThenAcquireTemporaryResourcesLock) {
|
||||||
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
wddm->evictTemporaryResource(ALLOCATION_HANDLE);
|
||||||
wddm->evictTemporaryResource(allocation);
|
|
||||||
EXPECT_EQ(1u, wddm->acquireLockResult.called);
|
EXPECT_EQ(1u, wddm->acquireLockResult.called);
|
||||||
EXPECT_EQ(reinterpret_cast<uint64_t>(&wddm->temporaryResourcesLock), wddm->acquireLockResult.uint64ParamPassed);
|
EXPECT_EQ(reinterpret_cast<uint64_t>(&wddm->temporaryResourcesLock), wddm->acquireLockResult.uint64ParamPassed);
|
||||||
}
|
}
|
||||||
TEST_F(Wddm20Tests, whenEvictingNonExistingTemporaryResourceThenEvictIsNotAppliedAndTemporaryResourcesAreRestored) {
|
TEST_F(WddmLockWithMakeResidentTests, whenEvictingNonExistingTemporaryResourceThenEvictIsNotAppliedAndTemporaryResourcesAreRestored) {
|
||||||
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
wddm->temporaryResources.push_back(ALLOCATION_HANDLE);
|
||||||
allocation.handle = 0x1;
|
|
||||||
wddm->temporaryResources.push_back(0x2);
|
|
||||||
EXPECT_FALSE(wddm->temporaryResources.empty());
|
EXPECT_FALSE(wddm->temporaryResources.empty());
|
||||||
wddm->evictTemporaryResource(allocation);
|
wddm->evictTemporaryResource(ALLOCATION_HANDLE + 1);
|
||||||
EXPECT_FALSE(wddm->temporaryResources.empty());
|
EXPECT_FALSE(wddm->temporaryResources.empty());
|
||||||
EXPECT_EQ(EvictionStatus::NOT_APPLIED, wddm->evictTemporaryResourceResult.status);
|
EXPECT_EQ(EvictionStatus::NOT_APPLIED, wddm->evictTemporaryResourceResult.status);
|
||||||
}
|
}
|
||||||
TEST_F(Wddm20Tests, whenEvictingTemporaryResourceAndEvictFailsThenReturnFail) {
|
TEST_F(WddmLockWithMakeResidentTests, whenEvictingTemporaryResourceAndEvictFailsThenReturnFail) {
|
||||||
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
|
||||||
GmockWddm gmockWddm;
|
GmockWddm gmockWddm;
|
||||||
gmockWddm.temporaryResources.push_back(allocation.handle);
|
gmockWddm.temporaryResources.push_back(ALLOCATION_HANDLE);
|
||||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillOnce(::testing::Return(false));
|
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillOnce(::testing::Return(false));
|
||||||
gmockWddm.evictTemporaryResource(allocation);
|
gmockWddm.evictTemporaryResource(ALLOCATION_HANDLE);
|
||||||
EXPECT_TRUE(gmockWddm.temporaryResources.empty());
|
EXPECT_TRUE(gmockWddm.temporaryResources.empty());
|
||||||
EXPECT_EQ(EvictionStatus::FAILED, gmockWddm.evictTemporaryResourceResult.status);
|
EXPECT_EQ(EvictionStatus::FAILED, gmockWddm.evictTemporaryResourceResult.status);
|
||||||
}
|
}
|
||||||
TEST_F(Wddm20Tests, whenEvictingTemporaryResourceAndEvictSucceedThenReturnSuccess) {
|
TEST_F(WddmLockWithMakeResidentTests, whenEvictingTemporaryResourceAndEvictSucceedThenReturnSuccess) {
|
||||||
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
|
||||||
GmockWddm gmockWddm;
|
GmockWddm gmockWddm;
|
||||||
gmockWddm.temporaryResources.push_back(allocation.handle);
|
gmockWddm.temporaryResources.push_back(ALLOCATION_HANDLE);
|
||||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillOnce(::testing::Return(true));
|
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillOnce(::testing::Return(true));
|
||||||
gmockWddm.evictTemporaryResource(allocation);
|
gmockWddm.evictTemporaryResource(ALLOCATION_HANDLE);
|
||||||
EXPECT_TRUE(gmockWddm.temporaryResources.empty());
|
EXPECT_TRUE(gmockWddm.temporaryResources.empty());
|
||||||
EXPECT_EQ(EvictionStatus::SUCCESS, gmockWddm.evictTemporaryResourceResult.status);
|
EXPECT_EQ(EvictionStatus::SUCCESS, gmockWddm.evictTemporaryResourceResult.status);
|
||||||
}
|
}
|
||||||
TEST_F(Wddm20Tests, whenEvictingTemporaryResourceThenOtherResourcesRemainOnTheList) {
|
TEST_F(WddmLockWithMakeResidentTests, whenEvictingTemporaryResourceThenOtherResourcesRemainOnTheList) {
|
||||||
wddm->temporaryResources.push_back(0x1);
|
wddm->temporaryResources.push_back(0x1);
|
||||||
wddm->temporaryResources.push_back(0x2);
|
wddm->temporaryResources.push_back(0x2);
|
||||||
wddm->temporaryResources.push_back(0x3);
|
wddm->temporaryResources.push_back(0x3);
|
||||||
|
|
||||||
WddmAllocation allocation{GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
|
wddm->evictTemporaryResource(0x2);
|
||||||
allocation.handle = 0x2;
|
|
||||||
wddm->evictTemporaryResource(allocation);
|
|
||||||
|
|
||||||
EXPECT_EQ(2u, wddm->temporaryResources.size());
|
EXPECT_EQ(2u, wddm->temporaryResources.size());
|
||||||
EXPECT_EQ(0x1, wddm->temporaryResources.front());
|
EXPECT_EQ(0x1, wddm->temporaryResources.front());
|
||||||
EXPECT_EQ(0x3, wddm->temporaryResources.back());
|
EXPECT_EQ(0x3, wddm->temporaryResources.back());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(WddmLockWithMakeResidentTests, whenAlllocationNeedsBlockingMakeResidentBeforeLockThenLockWithBlockingMakeResident) {
|
||||||
|
WddmMemoryManager memoryManager(false, false, wddm, executionEnvironment);
|
||||||
|
MockWddmAllocation allocation;
|
||||||
|
allocation.needsMakeResidentBeforeLock = false;
|
||||||
|
memoryManager.lockResource(&allocation);
|
||||||
|
EXPECT_EQ(1u, wddm->lockResult.called);
|
||||||
|
EXPECT_EQ(0u, wddm->lockResult.uint64ParamPassed);
|
||||||
|
memoryManager.unlockResource(&allocation);
|
||||||
|
|
||||||
|
allocation.needsMakeResidentBeforeLock = true;
|
||||||
|
memoryManager.lockResource(&allocation);
|
||||||
|
EXPECT_EQ(2u, wddm->lockResult.called);
|
||||||
|
EXPECT_EQ(1u, wddm->lockResult.uint64ParamPassed);
|
||||||
|
memoryManager.unlockResource(&allocation);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(WddmInternalHeapTest, whenConfigurationIs64BitThenInternalHeapIndexIsHeapInternalDeviceMemory) {
|
TEST(WddmInternalHeapTest, whenConfigurationIs64BitThenInternalHeapIndexIsHeapInternalDeviceMemory) {
|
||||||
if (is64bit) {
|
if (is64bit) {
|
||||||
EXPECT_EQ(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, internalHeapIndex);
|
EXPECT_EQ(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, internalHeapIndex);
|
||||||
|
|||||||
@@ -52,29 +52,23 @@ class WddmKmDafListenerTest : public GmmEnvironmentFixture, public ::testing::Te
|
|||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(WddmKmDafListenerTest, givenWddmWhenLockResourceIsCalledThenKmDafListenerNotifyLockIsFedWithCorrectParams) {
|
TEST_F(WddmKmDafListenerTest, givenWddmWhenLockResourceIsCalledThenKmDafListenerNotifyLockIsFedWithCorrectParams) {
|
||||||
MockWddmAllocation allocation;
|
wddmWithKmDafMock->lockResource(ALLOCATION_HANDLE, false);
|
||||||
allocation.handle = ALLOCATION_HANDLE;
|
|
||||||
|
|
||||||
wddmWithKmDafMock->lockResource(allocation);
|
|
||||||
|
|
||||||
EXPECT_EQ(wddmWithKmDafMock->featureTable->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->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.hAdapter);
|
||||||
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.hDevice);
|
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.hDevice);
|
||||||
EXPECT_EQ(allocation.handle, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.hAllocation);
|
EXPECT_EQ(ALLOCATION_HANDLE, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.hAllocation);
|
||||||
EXPECT_EQ(0, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.pLockFlags);
|
EXPECT_EQ(0, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.pLockFlags);
|
||||||
EXPECT_EQ(wddmWithKmDafMock->getGdi()->escape, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.pfnEscape);
|
EXPECT_EQ(wddmWithKmDafMock->getGdi()->escape, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.pfnEscape);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WddmKmDafListenerTest, givenWddmWhenUnlockResourceIsCalledThenKmDafListenerNotifyUnlockIsFedWithCorrectParams) {
|
TEST_F(WddmKmDafListenerTest, givenWddmWhenUnlockResourceIsCalledThenKmDafListenerNotifyUnlockIsFedWithCorrectParams) {
|
||||||
MockWddmAllocation allocation;
|
wddmWithKmDafMock->unlockResource(ALLOCATION_HANDLE);
|
||||||
allocation.handle = ALLOCATION_HANDLE;
|
|
||||||
|
|
||||||
wddmWithKmDafMock->unlockResource(allocation);
|
|
||||||
|
|
||||||
EXPECT_EQ(wddmWithKmDafMock->featureTable->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->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyUnlockParametrization.hAdapter);
|
||||||
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyUnlockParametrization.hDevice);
|
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyUnlockParametrization.hDevice);
|
||||||
EXPECT_EQ(allocation.handle, *wddmWithKmDafMock->getKmDafListenerMock().notifyUnlockParametrization.phAllocation);
|
EXPECT_EQ(ALLOCATION_HANDLE, *wddmWithKmDafMock->getKmDafListenerMock().notifyUnlockParametrization.phAllocation);
|
||||||
EXPECT_EQ(1u, wddmWithKmDafMock->getKmDafListenerMock().notifyUnlockParametrization.allocations);
|
EXPECT_EQ(1u, wddmWithKmDafMock->getKmDafListenerMock().notifyUnlockParametrization.allocations);
|
||||||
EXPECT_EQ(wddmWithKmDafMock->getGdi()->escape, wddmWithKmDafMock->getKmDafListenerMock().notifyUnlockParametrization.pfnEscape);
|
EXPECT_EQ(wddmWithKmDafMock->getGdi()->escape, wddmWithKmDafMock->getKmDafListenerMock().notifyUnlockParametrization.pfnEscape);
|
||||||
}
|
}
|
||||||
@@ -190,15 +184,12 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocationsAndMapGpuVaIsCalledT
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WddmKmDafListenerTest, givenWddmWhenKmDafLockIsCalledThenKmDafListenerNotifyLockIsFedWithCorrectParams) {
|
TEST_F(WddmKmDafListenerTest, givenWddmWhenKmDafLockIsCalledThenKmDafListenerNotifyLockIsFedWithCorrectParams) {
|
||||||
MockWddmAllocation allocation;
|
wddmWithKmDafMock->kmDafLock(ALLOCATION_HANDLE);
|
||||||
allocation.handle = ALLOCATION_HANDLE;
|
|
||||||
|
|
||||||
wddmWithKmDafMock->kmDafLock(&allocation);
|
|
||||||
|
|
||||||
EXPECT_EQ(wddmWithKmDafMock->featureTable->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->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.hAdapter);
|
||||||
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.hDevice);
|
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.hDevice);
|
||||||
EXPECT_EQ(allocation.handle, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.hAllocation);
|
EXPECT_EQ(ALLOCATION_HANDLE, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.hAllocation);
|
||||||
EXPECT_EQ(0, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.pLockFlags);
|
EXPECT_EQ(0, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.pLockFlags);
|
||||||
EXPECT_EQ(wddmWithKmDafMock->getGdi()->escape, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.pfnEscape);
|
EXPECT_EQ(wddmWithKmDafMock->getGdi()->escape, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.pfnEscape);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user