add method for setting allocation priority

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2021-04-19 19:53:46 +00:00
committed by Compute-Runtime-Automation
parent 9a22d06efe
commit c5546a5cfb
12 changed files with 97 additions and 2 deletions

View File

@@ -301,6 +301,17 @@ void WddmMock::createPagingFenceLogger() {
}
}
bool WddmMock::setAllocationPriority(const D3DKMT_HANDLE *handles, uint32_t allocationCount, uint32_t priority) {
if (callBaseSetAllocationPriority) {
auto status = Wddm::setAllocationPriority(handles, allocationCount, priority);
setAllocationPriorityResult.success = status;
setAllocationPriorityResult.called++;
setAllocationPriorityResult.uint64ParamPassed = priority;
return status;
}
return setAllocationPriorityResult.success;
}
void *GmockWddm::virtualAllocWrapper(void *inPtr, size_t size, uint32_t flags, uint32_t type) {
void *tmp = reinterpret_cast<void *>(virtualAllocAddress);
size += MemoryConstants::pageSize;

View File

@@ -96,6 +96,7 @@ class WddmMock : public Wddm {
}
return verifyAdapterLuidReturnValue;
}
bool setAllocationPriority(const D3DKMT_HANDLE *handles, uint32_t allocationCount, uint32_t priority) override;
bool configureDeviceAddressSpace() {
configureDeviceAddressSpaceResult.called++;
@@ -147,6 +148,7 @@ class WddmMock : public Wddm {
WddmMockHelpers::CallResult getPagingFenceAddressResult;
WddmMockHelpers::CallResult reserveGpuVirtualAddressResult;
WddmMockHelpers::CallResult waitOnPagingFenceFromCpuResult;
WddmMockHelpers::CallResult setAllocationPriorityResult;
NTSTATUS createAllocationStatus = STATUS_SUCCESS;
bool verifyAdapterLuidReturnValue = true;
@@ -163,6 +165,7 @@ class WddmMock : public Wddm {
bool callBaseMakeResident = true;
bool callBaseCreatePagingLogger = true;
bool shutdownStatus = false;
bool callBaseSetAllocationPriority = true;
};
struct GmockWddm : WddmMock {

View File

@@ -49,6 +49,8 @@ struct GdiDllFixture {
reinterpret_cast<decltype(&getCreateSynchronizationObject2FailCall)>(mockGdiDll->getProcAddress("getCreateSynchronizationObject2FailCall"));
getRegisterTrimNotificationFailCallFcn =
reinterpret_cast<decltype(&getRegisterTrimNotificationFailCall)>(mockGdiDll->getProcAddress("getRegisterTrimNotificationFailCall"));
getLastPriorityFcn =
reinterpret_cast<decltype(&getLastPriority)>(mockGdiDll->getProcAddress("getLastPriority"));
setMockLastDestroyedResHandleFcn((D3DKMT_HANDLE)0);
*getDestroySynchronizationObjectDataFcn() = {};
*getCreateSynchronizationObject2FailCallFcn() = false;
@@ -86,4 +88,5 @@ struct GdiDllFixture {
decltype(&getMonitorFenceCpuFenceAddress) getMonitorFenceCpuFenceAddressFcn = nullptr;
decltype(&getCreateSynchronizationObject2FailCall) getCreateSynchronizationObject2FailCallFcn = nullptr;
decltype(&getRegisterTrimNotificationFailCall) getRegisterTrimNotificationFailCallFcn = nullptr;
decltype(&getLastPriority) getLastPriorityFcn = nullptr;
};

View File

@@ -1533,3 +1533,23 @@ TEST(VerifyAdapterType, whenAdapterSupportsRenderThenCreateHwDeviceId) {
auto hwDeviceId = createHwDeviceIdFromAdapterLuid(*osEnv, adapterLuid);
EXPECT_NE(nullptr, hwDeviceId.get());
}
TEST_F(WddmTestWithMockGdiDll, givenInvalidInputwhenSettingAllocationPriorityThenFalseIsReturned) {
init();
EXPECT_FALSE(wddm->setAllocationPriority(nullptr, 0, DXGI_RESOURCE_PRIORITY_MAXIMUM));
EXPECT_FALSE(wddm->setAllocationPriority(nullptr, 5, DXGI_RESOURCE_PRIORITY_MAXIMUM));
{
D3DKMT_HANDLE handles[] = {ALLOCATION_HANDLE, 0};
EXPECT_FALSE(wddm->setAllocationPriority(handles, 2, DXGI_RESOURCE_PRIORITY_MAXIMUM));
}
}
TEST_F(WddmTestWithMockGdiDll, givenValidInputwhenSettingAllocationPriorityThenTrueIsReturned) {
init();
D3DKMT_HANDLE handles[] = {ALLOCATION_HANDLE, ALLOCATION_HANDLE + 1};
EXPECT_TRUE(wddm->setAllocationPriority(handles, 2, DXGI_RESOURCE_PRIORITY_MAXIMUM));
EXPECT_EQ(DXGI_RESOURCE_PRIORITY_MAXIMUM, getLastPriorityFcn());
EXPECT_TRUE(wddm->setAllocationPriority(handles, 2, DXGI_RESOURCE_PRIORITY_NORMAL));
EXPECT_EQ(DXGI_RESOURCE_PRIORITY_NORMAL, getLastPriorityFcn());
}