[1/n] Move different wddm functions to dedicated helper.

- This is first phase of moving wddm specific internals to Wddm
Interface helper
- Instead of having 2 different wddm classes driver will route interface
specific functions to dedicated helper
- Helper will be initialized when interface version will be known,
therefore we would not need to initialize wddm multiple times

Change-Id: Ic71788ccb2f8a71bf2f3f3c2a04117f16417d85e
This commit is contained in:
Mrozek, Michal
2018-08-10 16:41:44 +02:00
committed by sys_ocldev
parent 95e28faca0
commit d51c7ccdd4
13 changed files with 269 additions and 185 deletions

View File

@@ -35,6 +35,8 @@ struct Wddm23Tests : public ::testing::Test, GdiDllFixture, public GmmEnvironmen
GmmEnvironmentFixture::SetUp();
GdiDllFixture::SetUp();
wddm.reset(static_cast<WddmMock23 *>(Wddm::createWddm(WddmInterfaceVersion::Wddm23)));
wddmMockInterface = new WddmMockInterface23(*wddm);
wddm->wddmInterface.reset(wddmMockInterface);
wddm->registryReader.reset(new RegistryReaderMock());
}
@@ -44,10 +46,11 @@ struct Wddm23Tests : public ::testing::Test, GdiDllFixture, public GmmEnvironmen
}
std::unique_ptr<WddmMock23> wddm;
WddmMockInterface23 *wddmMockInterface = nullptr;
};
TEST_F(Wddm23Tests, whenCreateMonitoredFenceCalledThenDoNothing) {
EXPECT_TRUE(wddm->createMonitoredFence());
EXPECT_TRUE(wddm->wddmInterface->createMonitoredFence());
EXPECT_TRUE(nullptr == wddm->getMonitoredFence().cpuAddress);
EXPECT_EQ(0u, wddm->getMonitoredFence().currentFenceValue);
EXPECT_EQ(static_cast<D3DKMT_HANDLE>(0), wddm->getMonitoredFence().fenceHandle);
@@ -57,7 +60,7 @@ TEST_F(Wddm23Tests, whenCreateMonitoredFenceCalledThenDoNothing) {
HWTEST_F(Wddm23Tests, whenCreateContextIsCalledThenEnableHwQueues) {
wddm->init<FamilyType>();
EXPECT_TRUE(wddm->hwQueuesSupported());
EXPECT_TRUE(wddm->wddmInterface->hwQueuesSupported());
EXPECT_EQ(1u, getCreateContextDataFcn()->Flags.HwQueueSupported);
}
@@ -65,7 +68,7 @@ TEST_F(Wddm23Tests, whenCreateHwQueueIsCalledThenSetAllRequiredFieldsAndMonitore
EXPECT_EQ(0u, wddm->hwQueueHandle);
wddm->context = 1;
wddm->createHwQueue();
wddm->wddmInterface->createHwQueue(wddm->preemptionMode);
EXPECT_EQ(wddm->context, getCreateHwQueueDataFcn()->hHwContext);
EXPECT_EQ(0u, getCreateHwQueueDataFcn()->PrivateDriverDataSize);
@@ -80,29 +83,29 @@ TEST_F(Wddm23Tests, whenCreateHwQueueIsCalledThenSetAllRequiredFieldsAndMonitore
TEST_F(Wddm23Tests, givenPreemptionModeWhenCreateHwQueueCalledThenSetGpuTimeoutIfEnabled) {
wddm->setPreemptionMode(PreemptionMode::Disabled);
wddm->createHwQueue();
wddm->wddmInterface->createHwQueue(wddm->preemptionMode);
EXPECT_EQ(0u, getCreateHwQueueDataFcn()->Flags.DisableGpuTimeout);
wddm->setPreemptionMode(PreemptionMode::MidBatch);
wddm->createHwQueue();
wddm->wddmInterface->createHwQueue(wddm->preemptionMode);
EXPECT_EQ(1u, getCreateHwQueueDataFcn()->Flags.DisableGpuTimeout);
}
HWTEST_F(Wddm23Tests, whenDestroyHwQueueCalledThenPassExistingHandle) {
wddm->init<FamilyType>();
wddm->hwQueueHandle = 123;
wddm->destroyHwQueue();
EXPECT_EQ(wddm->hwQueueHandle, getDestroyHwQueueDataFcn()->hHwQueue);
wddmMockInterface->hwQueueHandle = 123;
wddm->wddmInterface->destroyHwQueue();
EXPECT_EQ(wddmMockInterface->hwQueueHandle, getDestroyHwQueueDataFcn()->hHwQueue);
wddm->hwQueueHandle = 0;
wddm->destroyHwQueue();
EXPECT_NE(wddm->hwQueueHandle, getDestroyHwQueueDataFcn()->hHwQueue); // gdi not called when 0
wddmMockInterface->hwQueueHandle = 0;
wddm->wddmInterface->destroyHwQueue();
EXPECT_NE(wddmMockInterface->hwQueueHandle, getDestroyHwQueueDataFcn()->hHwQueue); // gdi not called when 0
}
HWTEST_F(Wddm23Tests, whenObjectIsDestructedThenDestroyHwQueue) {
wddm->init<FamilyType>();
D3DKMT_HANDLE hwQueue = 123;
wddm->hwQueueHandle = hwQueue;
wddmMockInterface->hwQueueHandle = hwQueue;
wddm.reset(nullptr);
EXPECT_EQ(hwQueue, getDestroyHwQueueDataFcn()->hHwQueue);
}
@@ -120,7 +123,7 @@ HWTEST_F(Wddm23Tests, givenCmdBufferWhenSubmitCalledThenSetAllRequiredFiledsAndU
EXPECT_EQ(cmdBufferAddress, getSubmitCommandToHwQueueDataFcn()->CommandBuffer);
EXPECT_EQ(static_cast<UINT>(cmdSize), getSubmitCommandToHwQueueDataFcn()->CommandLength);
EXPECT_EQ(wddm->hwQueueHandle, getSubmitCommandToHwQueueDataFcn()->hHwQueue);
EXPECT_EQ(wddmMockInterface->hwQueueHandle, getSubmitCommandToHwQueueDataFcn()->hHwQueue);
EXPECT_EQ(wddm->getMonitoredFence().fenceHandle, getSubmitCommandToHwQueueDataFcn()->HwQueueProgressFenceId);
EXPECT_EQ(&cmdBufferHeader, getSubmitCommandToHwQueueDataFcn()->pPrivateDriverData);
EXPECT_EQ(static_cast<UINT>(sizeof(COMMAND_BUFFER_HEADER)), getSubmitCommandToHwQueueDataFcn()->PrivateDriverDataSize);
@@ -153,7 +156,7 @@ HWTEST_F(Wddm23Tests, whenInitCalledThenInitializeNewGdiDDIsAndCallToCreateHwQue
EXPECT_EQ(nullptr, wddm->gdi->submitCommandToHwQueue.mFunc);
EXPECT_TRUE(wddm->init<FamilyType>());
EXPECT_EQ(1u, wddm->createHwQueueCalled);
EXPECT_EQ(1u, wddmMockInterface->createHwQueueCalled);
EXPECT_NE(nullptr, wddm->gdi->createHwQueue.mFunc);
EXPECT_NE(nullptr, wddm->gdi->destroyHwQueue.mFunc);
@@ -161,7 +164,7 @@ HWTEST_F(Wddm23Tests, whenInitCalledThenInitializeNewGdiDDIsAndCallToCreateHwQue
}
HWTEST_F(Wddm23Tests, whenCreateHwQueueFailedThenReturnFalseFromInit) {
wddm->forceCreateHwQueueFail = true;
wddmMockInterface->forceCreateHwQueueFail = true;
EXPECT_FALSE(wddm->init<FamilyType>());
}
@@ -171,9 +174,9 @@ HWTEST_F(Wddm23Tests, givenFailureOnGdiInitializationWhenCreatingHwQueueThenRetu
return false;
}
};
wddm->gdi.reset(new MyMockGdi());
auto myMockGdi = new MyMockGdi();
wddm->gdi.reset(myMockGdi);
EXPECT_FALSE(wddm->init<FamilyType>());
EXPECT_EQ(1u, wddm->createHwQueueCalled);
EXPECT_FALSE(wddm->createHwQueueResult);
EXPECT_EQ(1u, wddmMockInterface->createHwQueueCalled);
EXPECT_FALSE(wddmMockInterface->createHwQueueResult);
}