Fill OsInterface in Wddm::init

Change-Id: I0a4645040b06870007a20b46dbea562bf6024ad3
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2020-04-08 11:45:54 +02:00
committed by sys_ocldev
parent 259cdae5cd
commit 86f5555f67
20 changed files with 78 additions and 104 deletions

View File

@ -25,12 +25,12 @@ typedef ::testing::Test MockOSTimeWinTest;
TEST_F(MockOSTimeWinTest, WhenCreatingTimerThenResolutionIsSetCorrectly) {
MockExecutionEnvironment executionEnvironment;
RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment);
auto wddmMock = std::unique_ptr<WddmMock>(new WddmMock(rootDeviceEnvironment));
auto wddmMock = new WddmMock(rootDeviceEnvironment);
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
wddmMock->init();
std::unique_ptr<MockOSTimeWin> timeWin(new MockOSTimeWin(wddmMock.get()));
std::unique_ptr<MockOSTimeWin> timeWin(new MockOSTimeWin(wddmMock));
double res = 0.0;
res = timeWin->getDynamicDeviceTimerResolution(device->getHardwareInfo());

View File

@ -25,7 +25,7 @@ struct Gen12LpWddmTest : public GdiDllFixture, ::testing::Test {
executionEnvironment = std::make_unique<MockExecutionEnvironment>();
rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get();
rootDeviceEnvironment->initGmm();
wddm.reset(static_cast<WddmMock *>(Wddm::createWddm(nullptr, *rootDeviceEnvironment)));
wddm = static_cast<WddmMock *>(Wddm::createWddm(nullptr, *rootDeviceEnvironment));
gmmMemory = new ::testing::NiceMock<GmockGmmMemory>(rootDeviceEnvironment->getGmmClientContext());
wddm->gmmMemory.reset(gmmMemory);
}
@ -35,8 +35,8 @@ struct Gen12LpWddmTest : public GdiDllFixture, ::testing::Test {
}
std::unique_ptr<MockExecutionEnvironment> executionEnvironment;
RootDeviceEnvironment *rootDeviceEnvironment;
std::unique_ptr<WddmMock> wddm;
RootDeviceEnvironment *rootDeviceEnvironment = nullptr;
WddmMock *wddm = nullptr;
GmockGmmMemory *gmmMemory = nullptr;
};

View File

@ -300,11 +300,6 @@ void WddmMock::createPagingFenceLogger() {
}
}
bool WddmMock::init() {
osInterfaceAvailable = rootDeviceEnvironment.osInterface != nullptr;
return Wddm::init();
}
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

@ -85,7 +85,6 @@ class WddmMock : public Wddm {
uint64_t *getPagingFenceAddress() override;
void waitOnPagingFenceFromCpu() override;
void createPagingFenceLogger() override;
bool init() override;
bool configureDeviceAddressSpace() {
configureDeviceAddressSpaceResult.called++;
@ -135,7 +134,6 @@ class WddmMock : public Wddm {
bool makeResidentStatus = true;
bool callBaseMakeResident = true;
bool callBaseCreatePagingLogger = true;
bool osInterfaceAvailable = false;
};
struct GmockWddm : WddmMock {

View File

@ -55,10 +55,8 @@ class DriverInfoDeviceTest : public ::testing::Test {
CommandStreamReceiver *createMockCommandStreamReceiver(bool withAubDump, ExecutionEnvironment &executionEnvironment, uint32_t rootDeviceIndex) {
auto csr = new MockCommandStreamReceiver(executionEnvironment, rootDeviceIndex);
if (!executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface) {
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
auto wddm = new WddmMock(*executionEnvironment.rootDeviceEnvironments[0]);
wddm->init();
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface->get()->setWddm(wddm);
}
EXPECT_NE(nullptr, executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface.get());

View File

@ -65,7 +65,7 @@ void HwInfoConfigTestWindows::SetUp() {
osInterface.reset(new OSInterface());
std::unique_ptr<Wddm> wddm(Wddm::createWddm(nullptr, *rootDeviceEnvironment));
auto wddm = Wddm::createWddm(nullptr, *rootDeviceEnvironment);
wddm->init();
outHwInfo = *rootDeviceEnvironment->getHardwareInfo();
}

View File

@ -28,8 +28,6 @@ TEST(OsContextTest, givenWddmWhenCreateOsContextAfterInitWddmThenOsContextIsInit
MockExecutionEnvironment executionEnvironment;
RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment);
auto wddm = new WddmMock(rootDeviceEnvironment);
OSInterface osInterface;
osInterface.get()->setWddm(wddm);
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo);
wddm->init();
EXPECT_EQ(0u, wddm->registerTrimCallbackResult.called);

View File

@ -134,7 +134,7 @@ TEST(Wddm20EnumAdaptersTest, expectTrue) {
MockExecutionEnvironment executionEnvironment;
RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment);
std::unique_ptr<Wddm> wddm(Wddm::createWddm(nullptr, rootDeviceEnvironment));
auto wddm = Wddm::createWddm(nullptr, rootDeviceEnvironment);
bool success = wddm->init();
EXPECT_TRUE(success);
@ -151,7 +151,7 @@ TEST(Wddm20EnumAdaptersTest, givenEmptyHardwareInfoWhenEnumAdapterIsCalledThenCa
ExecutionEnvironment executionEnvironment;
executionEnvironment.prepareRootDeviceEnvironments(1);
auto rootDeviceEnvironment = executionEnvironment.rootDeviceEnvironments[0].get();
std::unique_ptr<Wddm> wddm(Wddm::createWddm(nullptr, *rootDeviceEnvironment));
auto wddm = Wddm::createWddm(nullptr, *rootDeviceEnvironment);
bool success = wddm->init();
HardwareInfo outHwInfo = *rootDeviceEnvironment->getHardwareInfo();
EXPECT_TRUE(success);
@ -175,7 +175,7 @@ TEST(Wddm20EnumAdaptersTest, givenUnknownPlatformWhenEnumAdapterIsCalledThenFals
MockExecutionEnvironment executionEnvironment;
RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment);
std::unique_ptr<Wddm> wddm(Wddm::createWddm(nullptr, rootDeviceEnvironment));
auto wddm = Wddm::createWddm(nullptr, rootDeviceEnvironment);
auto ret = wddm->init();
EXPECT_FALSE(ret);
@ -1070,18 +1070,19 @@ TEST(WddmGfxPartitionTests, initGfxPartitionHeapStandard64KBSplit) {
MockWddm(RootDeviceEnvironment &rootDeviceEnvironment) : Wddm(std::move(OSInterface::discoverDevices(rootDeviceEnvironment.executionEnvironment)[0]), rootDeviceEnvironment) {}
};
MockWddm wddm(*platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]);
MockExecutionEnvironment executionEnvironment;
auto wddm = new MockWddm(*executionEnvironment.rootDeviceEnvironments[0]);
uint32_t rootDeviceIndex = 3;
size_t numRootDevices = 5;
MockGfxPartition gfxPartition;
wddm.init();
wddm.initGfxPartition(gfxPartition, rootDeviceIndex, numRootDevices);
wddm->init();
wddm->initGfxPartition(gfxPartition, rootDeviceIndex, numRootDevices);
auto heapStandard64KBSize = alignDown((wddm.gfxPartition.Standard64KB.Limit - wddm.gfxPartition.Standard64KB.Base + 1) / numRootDevices, GfxPartition::heapGranularity);
auto heapStandard64KBSize = alignDown((wddm->gfxPartition.Standard64KB.Limit - wddm->gfxPartition.Standard64KB.Base + 1) / numRootDevices, GfxPartition::heapGranularity);
EXPECT_EQ(heapStandard64KBSize, gfxPartition.getHeapSize(HeapIndex::HEAP_STANDARD64KB));
EXPECT_EQ(wddm.gfxPartition.Standard64KB.Base + rootDeviceIndex * heapStandard64KBSize, gfxPartition.getHeapBase(HeapIndex::HEAP_STANDARD64KB));
EXPECT_EQ(wddm->gfxPartition.Standard64KB.Base + rootDeviceIndex * heapStandard64KBSize, gfxPartition.getHeapBase(HeapIndex::HEAP_STANDARD64KB));
}
TEST_F(Wddm20Tests, givenWddmWhenDiscoverDevicesAndForceDeviceIdIsTheSameAsTheExistingDeviceThenReturnTheAdapter) {
@ -1402,12 +1403,3 @@ TEST(DiscoverDevices, whenDriverInfoHasIncompatibleDriverStoreThenHwDeviceIdIsNo
auto hwDeviceIds = OSInterface::discoverDevices(executionEnvironment);
EXPECT_TRUE(hwDeviceIds.empty());
}
TEST(InitOsInterfaceTest, givenRootDeviceEnvironmentWhenIntializingWddmDuringInitOsInterfaceMethodThenOsInterfaceIsAvailable) {
MockExecutionEnvironment executionEnvironment{};
auto hwDeviceIds = OSInterface::discoverDevices(executionEnvironment);
EXPECT_EQ(1u, hwDeviceIds.size());
executionEnvironment.rootDeviceEnvironments[0]->initOsInterface(std::move(hwDeviceIds[0]));
auto wddm = static_cast<WddmMock *>(executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->getWddm());
EXPECT_TRUE(wddm->osInterfaceAvailable);
}

View File

@ -7,6 +7,7 @@
#include "shared/source/command_stream/preemption.h"
#include "shared/source/execution_environment/execution_environment.h"
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/helpers/constants.h"
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/os_interface/windows/gdi_interface.h"
@ -29,6 +30,7 @@ struct Wddm23TestsWithoutWddmInit : public ::testing::Test, GdiDllFixture {
executionEnvironment = platform()->peekExecutionEnvironment();
wddm = static_cast<WddmMock *>(Wddm::createWddm(nullptr, *executionEnvironment->rootDeviceEnvironments[0].get()));
auto &osInterface = executionEnvironment->rootDeviceEnvironments[0]->osInterface;
osInterface = std::make_unique<OSInterface>();
osInterface->get()->setWddm(wddm);
@ -52,7 +54,6 @@ struct Wddm23TestsWithoutWddmInit : public ::testing::Test, GdiDllFixture {
GdiDllFixture::TearDown();
}
std::unique_ptr<OSInterface> osInterface;
std::unique_ptr<OsContextWin> osContext;
WddmMock *wddm = nullptr;
WddmMockInterface23 *wddmMockInterface = nullptr;
@ -78,9 +79,9 @@ TEST_F(Wddm23Tests, whenCreateContextIsCalledThenEnableHwQueues) {
TEST_F(Wddm23Tests, givenPreemptionModeWhenCreateHwQueueCalledThenSetGpuTimeoutIfEnabled) {
auto defaultEngine = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*defaultHwInfo)[0];
OsContextWin osContextWithoutPreemption(*osInterface->get()->getWddm(), 0u, 1, defaultEngine, PreemptionMode::Disabled,
OsContextWin osContextWithoutPreemption(*wddm, 0u, 1, defaultEngine, PreemptionMode::Disabled,
false, false, false);
OsContextWin osContextWithPreemption(*osInterface->get()->getWddm(), 0u, 1, defaultEngine, PreemptionMode::MidBatch,
OsContextWin osContextWithPreemption(*wddm, 0u, 1, defaultEngine, PreemptionMode::MidBatch,
false, false, false);
wddm->wddmInterface->createHwQueue(osContextWithoutPreemption);

View File

@ -59,7 +59,7 @@ class WddmMockReserveAddress : public WddmMock {
TEST(WddmReserveAddressTest, givenWddmWhenFirstIsSuccessfulThenReturnReserveAddress) {
MockExecutionEnvironment executionEnvironment;
RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment);
std::unique_ptr<WddmMockReserveAddress> wddm(new WddmMockReserveAddress(rootDeviceEnvironment));
auto wddm = new WddmMockReserveAddress(rootDeviceEnvironment);
size_t size = 0x1000;
void *reserve = nullptr;
@ -77,7 +77,7 @@ TEST(WddmReserveAddressTest, givenWddmWhenFirstIsSuccessfulThenReturnReserveAddr
TEST(WddmReserveAddressTest, givenWddmWhenFirstIsNullThenReturnNull) {
MockExecutionEnvironment executionEnvironment;
RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment);
std::unique_ptr<WddmMockReserveAddress> wddm(new WddmMockReserveAddress(rootDeviceEnvironment));
auto wddm = new WddmMockReserveAddress(rootDeviceEnvironment);
size_t size = 0x1000;
void *reserve = nullptr;
@ -91,7 +91,7 @@ TEST(WddmReserveAddressTest, givenWddmWhenFirstIsNullThenReturnNull) {
TEST(WddmReserveAddressTest, givenWddmWhenFirstIsInvalidSecondSuccessfulThenReturnSecond) {
MockExecutionEnvironment executionEnvironment;
RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment);
std::unique_ptr<WddmMockReserveAddress> wddm(new WddmMockReserveAddress(rootDeviceEnvironment));
auto wddm = new WddmMockReserveAddress(rootDeviceEnvironment);
size_t size = 0x1000;
void *reserve = nullptr;
@ -109,7 +109,7 @@ TEST(WddmReserveAddressTest, givenWddmWhenFirstIsInvalidSecondSuccessfulThenRetu
TEST(WddmReserveAddressTest, givenWddmWhenSecondIsInvalidThirdSuccessfulThenReturnThird) {
MockExecutionEnvironment executionEnvironment;
RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment);
std::unique_ptr<WddmMockReserveAddress> wddm(new WddmMockReserveAddress(rootDeviceEnvironment));
auto wddm = new WddmMockReserveAddress(rootDeviceEnvironment);
size_t size = 0x1000;
void *reserve = nullptr;
@ -127,7 +127,7 @@ TEST(WddmReserveAddressTest, givenWddmWhenSecondIsInvalidThirdSuccessfulThenRetu
TEST(WddmReserveAddressTest, givenWddmWhenFirstIsInvalidSecondNullThenReturnSecondNull) {
MockExecutionEnvironment executionEnvironment;
RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment);
std::unique_ptr<WddmMockReserveAddress> wddm(new WddmMockReserveAddress(rootDeviceEnvironment));
auto wddm = new WddmMockReserveAddress(rootDeviceEnvironment);
size_t size = 0x1000;
void *reserve = nullptr;

View File

@ -102,14 +102,16 @@ struct WddmInstrumentationGmmFixture {
void SetUp() {
executionEnvironment = platform()->peekExecutionEnvironment();
auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get();
wddm.reset(static_cast<WddmMock *>(Wddm::createWddm(nullptr, *rootDeviceEnvironment)));
wddm = static_cast<WddmMock *>(Wddm::createWddm(nullptr, *rootDeviceEnvironment));
gmmMem = new ::testing::NiceMock<GmockGmmMemory>(rootDeviceEnvironment->getGmmClientContext());
wddm->gmmMemory.reset(gmmMem);
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
rootDeviceEnvironment->osInterface->get()->setWddm(wddm);
}
void TearDown() {
}
std::unique_ptr<WddmMock> wddm;
WddmMock *wddm;
GmockGmmMemory *gmmMem = nullptr;
ExecutionEnvironment *executionEnvironment;
};

View File

@ -46,15 +46,15 @@ class WddmKmDafListenerTest : public ::testing::Test {
auto osEnvironment = new OsEnvironmentWin();
osEnvironment->gdi.reset(new MockGdi());
executionEnvironment->osEnvironment.reset(osEnvironment);
wddmWithKmDafMock.reset(new WddmWithKmDafMock(*rootDeviceEnvironment));
wddmWithKmDafMock = new WddmWithKmDafMock(*rootDeviceEnvironment);
wddmWithKmDafMock->init();
wddmWithKmDafMock->featureTable->ftrKmdDaf = true;
}
void TearDown() {
}
std::unique_ptr<WddmWithKmDafMock> wddmWithKmDafMock;
ExecutionEnvironment *executionEnvironment;
WddmWithKmDafMock *wddmWithKmDafMock = nullptr;
ExecutionEnvironment *executionEnvironment = nullptr;
RootDeviceEnvironment *rootDeviceEnvironment = nullptr;
};

View File

@ -52,8 +52,6 @@ void WddmMemoryManagerFixture::SetUp() {
constexpr uint64_t heap32Base = (is32bit) ? 0x1000 : 0x800000000000;
wddm->setHeap32(heap32Base, 1000 * MemoryConstants::pageSize - 1);
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
rootDeviceEnvironment->osInterface->get()->setWddm(wddm);
rootDeviceEnvironment->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
memoryManager = std::make_unique<MockWddmMemoryManager>(*executionEnvironment);
@ -352,20 +350,19 @@ TEST_F(WddmMemoryManagerSimpleTest, givenNonZeroFenceValuesOnMultipleEnginesRegi
for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) {
executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(defaultHwInfo.get());
}
std::unique_ptr<CommandStreamReceiver> csr(createCommandStream(*executionEnvironment, 1u));
const uint32_t rootDeviceIndex = 1;
std::unique_ptr<CommandStreamReceiver> csr(createCommandStream(*executionEnvironment, rootDeviceIndex));
auto wddm2 = static_cast<WddmMock *>(Wddm::createWddm(nullptr, *executionEnvironment->rootDeviceEnvironments[0].get()));
auto wddm2 = static_cast<WddmMock *>(Wddm::createWddm(nullptr, *executionEnvironment->rootDeviceEnvironments[rootDeviceIndex].get()));
wddm2->init();
executionEnvironment->rootDeviceEnvironments[1]->osInterface.reset(new OSInterface());
executionEnvironment->rootDeviceEnvironments[1]->osInterface->get()->setWddm(wddm2);
executionEnvironment->rootDeviceEnvironments[1]->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm2);
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm2);
auto hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo();
auto hwInfo = executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo();
memoryManager->createAndRegisterOsContext(csr.get(), HwHelper::get(hwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[1],
2, PreemptionHelper::getDefaultPreemptionMode(*hwInfo), false, false, false);
ASSERT_EQ(2u, memoryManager->getRegisteredEnginesCount());
auto allocation = static_cast<WddmAllocation *>(memoryManager->allocateGraphicsMemoryWithProperties({0, 32, GraphicsAllocation::AllocationType::BUFFER}));
auto allocation = static_cast<WddmAllocation *>(memoryManager->allocateGraphicsMemoryWithProperties({0u, 32, GraphicsAllocation::AllocationType::BUFFER}));
auto lastEngineFence = &static_cast<OsContextWin *>(memoryManager->getRegisteredEngines()[1].osContext)->getResidencyController().getMonitoredFence();
allocation->getResidencyData().updateCompletionData(129u, 0u);
allocation->getResidencyData().updateCompletionData(152u, 1u);
@ -381,24 +378,23 @@ TEST_F(WddmMemoryManagerSimpleTest, givenNonZeroFenceValuesOnMultipleEnginesRegi
}
TEST_F(WddmMemoryManagerSimpleTest, givenNonZeroFenceValueOnSomeOfMultipleEnginesRegisteredWhenHandleFenceCompletionIsCalledThenWaitOnCpuForTheseEngines) {
const uint32_t rootDeviceIndex = 1;
executionEnvironment->prepareRootDeviceEnvironments(2u);
for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) {
executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(defaultHwInfo.get());
}
std::unique_ptr<CommandStreamReceiver> csr(createCommandStream(*executionEnvironment, 1u));
std::unique_ptr<CommandStreamReceiver> csr(createCommandStream(*executionEnvironment, rootDeviceIndex));
auto wddm2 = static_cast<WddmMock *>(Wddm::createWddm(nullptr, *executionEnvironment->rootDeviceEnvironments[0].get()));
auto wddm2 = static_cast<WddmMock *>(Wddm::createWddm(nullptr, *executionEnvironment->rootDeviceEnvironments[rootDeviceIndex].get()));
wddm2->init();
executionEnvironment->rootDeviceEnvironments[1]->osInterface.reset(new OSInterface());
executionEnvironment->rootDeviceEnvironments[1]->osInterface->get()->setWddm(wddm2);
executionEnvironment->rootDeviceEnvironments[1]->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm2);
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm2);
auto hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo();
auto hwInfo = executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo();
memoryManager->createAndRegisterOsContext(csr.get(), HwHelper::get(hwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[1],
2, PreemptionHelper::getDefaultPreemptionMode(*hwInfo), false, false, false);
ASSERT_EQ(2u, memoryManager->getRegisteredEnginesCount());
auto allocation = static_cast<WddmAllocation *>(memoryManager->allocateGraphicsMemoryWithProperties({0, 32, GraphicsAllocation::AllocationType::BUFFER}));
auto allocation = static_cast<WddmAllocation *>(memoryManager->allocateGraphicsMemoryWithProperties({0u, 32, GraphicsAllocation::AllocationType::BUFFER}));
auto lastEngineFence = &static_cast<OsContextWin *>(memoryManager->getRegisteredEngines()[0].osContext)->getResidencyController().getMonitoredFence();
allocation->getResidencyData().updateCompletionData(129u, 0u);
allocation->getResidencyData().updateCompletionData(0, 1u);
@ -874,15 +870,13 @@ TEST_F(WddmMemoryManagerTest, GivenUnAlignedPointerAndSizeWhenAllocate32BitMemor
TEST_F(WddmMemoryManagerTest, getSystemSharedMemory) {
executionEnvironment->prepareRootDeviceEnvironments(4u);
for (auto i = 0u; i < 4u; i++) {
executionEnvironment->rootDeviceEnvironments[i]->osInterface.reset();
auto mockWddm = Wddm::createWddm(nullptr, *executionEnvironment->rootDeviceEnvironments[i].get());
mockWddm->init();
executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[i]->osInterface->get()->setWddm(mockWddm);
int64_t mem = memoryManager->getSystemSharedMemory(i);
EXPECT_EQ(mem, 4249540608);
executionEnvironment->rootDeviceEnvironments[i]->osInterface.reset();
}
}
@ -1453,10 +1447,9 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWithRegisteredOsContextWhenC
}
executionEnvironment->initializeMemoryManager();
for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) {
executionEnvironment->rootDeviceEnvironments[i]->osInterface.reset();
auto wddm = static_cast<WddmMock *>(Wddm::createWddm(nullptr, *executionEnvironment->rootDeviceEnvironments[i].get()));
wddm->init();
executionEnvironment->rootDeviceEnvironments[i]->osInterface.reset(new OSInterface());
executionEnvironment->rootDeviceEnvironments[i]->osInterface->get()->setWddm(wddm);
executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
}
std::unique_ptr<CommandStreamReceiver> csr(createCommandStream(*executionEnvironment, 0u));
@ -1478,10 +1471,9 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWithRegisteredOsContextWithE
}
executionEnvironment->initializeMemoryManager();
for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) {
executionEnvironment->rootDeviceEnvironments[i]->osInterface.reset();
auto wddm = static_cast<WddmMock *>(Wddm::createWddm(nullptr, *executionEnvironment->rootDeviceEnvironments[i].get()));
wddm->init();
executionEnvironment->rootDeviceEnvironments[i]->osInterface.reset(new OSInterface());
executionEnvironment->rootDeviceEnvironments[i]->osInterface->get()->setWddm(wddm);
executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
}
std::unique_ptr<CommandStreamReceiver> csr(createCommandStream(*executionEnvironment, 0u));
@ -1736,8 +1728,6 @@ TEST(WddmMemoryManagerCleanupTest, givenUsedTagAllocationInWddmMemoryManagerWhen
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo);
wddm->init();
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->setWddm(wddm);
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
executionEnvironment.memoryManager = std::make_unique<WddmMemoryManager>(executionEnvironment);
auto osContext = executionEnvironment.memoryManager->createAndRegisterOsContext(csr.get(), aub_stream::ENGINE_RCS, 1, preemptionMode,

View File

@ -61,8 +61,6 @@ class MockWddmMemoryManagerFixture {
wddm->setHeap32(heap32Base, 1000 * MemoryConstants::pageSize - 1);
wddm->init();
rootDeviceEnvironment->osInterface.reset(new OSInterface());
rootDeviceEnvironment->osInterface->get()->setWddm(wddm);
rootDeviceEnvironment->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
executionEnvironment->initializeMemoryManager();
@ -110,11 +108,9 @@ class WddmMemoryManagerFixtureWithGmockWddm : public ExecutionEnvironmentFixture
// wddm is deleted by memory manager
wddm = new NiceMock<GmockWddm>(*executionEnvironment->rootDeviceEnvironments[0].get());
executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
ASSERT_NE(nullptr, wddm);
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo);
wddm->init();
executionEnvironment->rootDeviceEnvironments[0]->osInterface->get()->setWddm(wddm);
executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
osInterface = executionEnvironment->rootDeviceEnvironments[0]->osInterface.get();
memoryManager = new (std::nothrow) MockWddmMemoryManager(*executionEnvironment);

View File

@ -74,7 +74,7 @@ struct WddmResidencyControllerTest : ::testing::Test {
void SetUp() {
executionEnvironment = std::make_unique<MockExecutionEnvironment>();
rootDeviceEnvironment = std::make_unique<RootDeviceEnvironment>(*executionEnvironment);
wddm = std::unique_ptr<WddmMock>(static_cast<WddmMock *>(Wddm::createWddm(nullptr, *rootDeviceEnvironment)));
wddm = static_cast<WddmMock *>(Wddm::createWddm(nullptr, *rootDeviceEnvironment));
wddm->init();
mockOsContextWin = std::make_unique<MockOsContextWin>(*wddm, osContextId, 0, aub_stream::ENGINE_RCS,
PreemptionMode::Disabled, false, false, false);
@ -84,7 +84,7 @@ struct WddmResidencyControllerTest : ::testing::Test {
std::unique_ptr<MockExecutionEnvironment> executionEnvironment;
std::unique_ptr<RootDeviceEnvironment> rootDeviceEnvironment;
std::unique_ptr<WddmMock> wddm;
WddmMock *wddm = nullptr;
std::unique_ptr<MockOsContextWin> mockOsContextWin;
MockWddmResidencyController *residencyController = nullptr;
};
@ -95,7 +95,7 @@ struct WddmResidencyControllerWithGdiTest : ::testing::Test {
void SetUp() {
executionEnvironment = std::make_unique<MockExecutionEnvironment>();
rootDeviceEnvironment = std::make_unique<RootDeviceEnvironment>(*executionEnvironment);
wddm = std::unique_ptr<WddmMock>(static_cast<WddmMock *>(Wddm::createWddm(nullptr, *rootDeviceEnvironment)));
wddm = static_cast<WddmMock *>(Wddm::createWddm(nullptr, *rootDeviceEnvironment));
gdi = new MockGdi();
wddm->resetGdi(gdi);
wddm->init();
@ -109,10 +109,10 @@ struct WddmResidencyControllerWithGdiTest : ::testing::Test {
std::unique_ptr<MockExecutionEnvironment> executionEnvironment;
std::unique_ptr<RootDeviceEnvironment> rootDeviceEnvironment;
std::unique_ptr<WddmMock> wddm;
WddmMock *wddm = nullptr;
std::unique_ptr<MockOsContextWin> mockOsContextWin;
MockWddmResidencyController *residencyController = nullptr;
MockGdi *gdi;
MockGdi *gdi = nullptr;
};
struct WddmResidencyControllerWithMockWddmTest : public WddmResidencyControllerTest {
@ -124,8 +124,6 @@ struct WddmResidencyControllerWithMockWddmTest : public WddmResidencyControllerT
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo);
wddm->init();
executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[0]->osInterface->get()->setWddm(wddm);
executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
executionEnvironment->initializeMemoryManager();
@ -163,8 +161,6 @@ struct WddmResidencyControllerWithGdiAndMemoryManagerTest : ::testing::Test {
gdi = new MockGdi();
wddm->resetGdi(gdi);
executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[0]->osInterface->get()->setWddm(wddm);
executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
executionEnvironment->initializeMemoryManager();
@ -199,7 +195,7 @@ TEST(WddmResidencyController, givenWddmResidencyControllerWhenItIsConstructedThe
MockExecutionEnvironment executionEnvironment;
executionEnvironment.prepareRootDeviceEnvironments(1);
auto gdi = new MockGdi();
auto wddm = std::unique_ptr<WddmMock>{static_cast<WddmMock *>(Wddm::createWddm(nullptr, *executionEnvironment.rootDeviceEnvironments[0].get()))};
auto wddm = static_cast<WddmMock *>(Wddm::createWddm(nullptr, *executionEnvironment.rootDeviceEnvironments[0].get()));
wddm->resetGdi(gdi);
wddm->init();
@ -218,7 +214,7 @@ TEST(WddmResidencyController, givenWddmResidencyControllerWhenRegisterCallbackTh
MockExecutionEnvironment executionEnvironment;
executionEnvironment.prepareRootDeviceEnvironments(1);
auto gdi = new MockGdi();
auto wddm = std::unique_ptr<WddmMock>{static_cast<WddmMock *>(Wddm::createWddm(nullptr, *executionEnvironment.rootDeviceEnvironments[0].get()))};
auto wddm = static_cast<WddmMock *>(Wddm::createWddm(nullptr, *executionEnvironment.rootDeviceEnvironments[0].get()));
wddm->resetGdi(gdi);
wddm->init();

View File

@ -87,17 +87,19 @@ struct GlArbSyncEventOsTest : public ::testing::Test {
sharing.GLContextHandle = 0x2cU;
sharing.GLDeviceHandle = 0x3cU;
wddm = new WddmMock(*rootDeviceEnvironment);
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
osInterface = rootDeviceEnvironment->osInterface.get();
osInterface->get()->setWddm(wddm);
gdi = new MockGdi();
wddm->resetGdi(gdi);
osInterface.get()->setWddm(wddm);
}
MockExecutionEnvironment executionEnvironment;
std::unique_ptr<RootDeviceEnvironment> rootDeviceEnvironment;
GlSharingFunctionsMock sharing;
MockGdi *gdi = nullptr;
WddmMock *wddm = nullptr;
OSInterface osInterface;
CL_GL_SYNC_INFO syncInfo = {};
OSInterface *osInterface = nullptr;
};
TEST_F(GlArbSyncEventOsTest, WhenCreateSynchronizationObjectSucceedsThenAllHAndlesAreValid) {
@ -144,7 +146,7 @@ TEST_F(GlArbSyncEventOsTest, WhenCreateSynchronizationObjectSucceedsThenAllHAndl
wddm->init();
gdi->createSynchronizationObject.mFunc = CreateSyncObjectMock::createSynchObject;
gdi->createSynchronizationObject2.mFunc = CreateSyncObjectMock::createSynchObject2;
auto ret = setupArbSyncObject(sharing, osInterface, syncInfo);
auto ret = setupArbSyncObject(sharing, *osInterface, syncInfo);
EXPECT_TRUE(ret);
EXPECT_EQ(1U, syncInfo.serverSynchronizationObject);
EXPECT_EQ(2U, syncInfo.clientSynchronizationObject);
@ -155,7 +157,7 @@ TEST_F(GlArbSyncEventOsTest, WhenCreateSynchronizationObjectSucceedsThenAllHAndl
EXPECT_NE(nullptr, syncInfo.submissionEvent);
EXPECT_NE(nullptr, syncInfo.submissionEventName);
EXPECT_FALSE(syncInfo.waitCalled);
cleanupArbSyncObject(osInterface, &syncInfo);
cleanupArbSyncObject(*osInterface, &syncInfo);
}
TEST_F(GlArbSyncEventOsTest, GivenNewGlSyncInfoWhenCreateSynchronizationObjectFailsThenSetupArbSyncObjectFails) {
@ -198,19 +200,21 @@ TEST_F(GlArbSyncEventOsTest, GivenNewGlSyncInfoWhenCreateSynchronizationObjectFa
CreateSyncObjectMock::getFailHandleId() = CreateSyncObjectMock::getHandle();
int failuresCount = 0;
auto ret = setupArbSyncObject(sharing, osInterface, syncInfo);
auto ret = setupArbSyncObject(sharing, *osInterface, syncInfo);
while (false == ret) {
++failuresCount;
CreateSyncObjectMock::getHandle() = 1;
++CreateSyncObjectMock::getFailHandleId();
ret = setupArbSyncObject(sharing, osInterface, syncInfo);
ret = setupArbSyncObject(sharing, *osInterface, syncInfo);
}
EXPECT_EQ(3, failuresCount);
cleanupArbSyncObject(osInterface, &syncInfo);
cleanupArbSyncObject(*osInterface, &syncInfo);
}
TEST_F(GlArbSyncEventOsTest, GivenNewGlSyncInfoWhenCreateEventFailsThenSetupArbSyncObjectFails) {
auto rootDeviceEnvironment = platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0].get();
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
MockOSInterface mockOsInterface;
MockOSInterfaceImpl *mockOsInterfaceImpl = static_cast<MockOSInterfaceImpl *>(mockOsInterface.get());
@ -242,6 +246,7 @@ TEST_F(GlArbSyncEventOsTest, GivenInvalidGlSyncInfoWhenCleanupArbSyncObjectIsCal
}
};
auto rootDeviceEnvironment = platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0].get();
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
auto wddm = new WddmMock(*rootDeviceEnvironment);
auto gdi = new MockGdi();
@ -272,6 +277,7 @@ TEST_F(GlArbSyncEventOsTest, GivenValidGlSyncInfoWhenCleanupArbSyncObjectIsCalle
}
};
auto rootDeviceEnvironment = platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0].get();
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
auto wddm = new WddmMock(*rootDeviceEnvironment);
auto gdi = new MockGdi();
@ -336,7 +342,7 @@ TEST_F(GlArbSyncEventOsTest, GivenCallToSignalArbSyncObjectWhenSignalSynchroniza
FailSignalSyncObjectMock::reset();
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo);
wddm->init();
OsContextWin osContext(*osInterface.get()->getWddm(), 0u, 1,
OsContextWin osContext(*wddm, 0u, 1,
HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*defaultHwInfo)[0],
preemptionMode, false, false, false);
@ -397,7 +403,7 @@ TEST_F(GlArbSyncEventOsTest, GivenCallToSignalArbSyncObjectWhenSignalSynchroniza
FailSignalSyncObjectMock::reset();
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo);
wddm->init();
OsContextWin osContext(*osInterface.get()->getWddm(), 0u, 1,
OsContextWin osContext(*wddm, 0u, 1,
HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*defaultHwInfo)[0],
preemptionMode, false, false, false);
@ -451,7 +457,7 @@ TEST_F(GlArbSyncEventOsTest, GivenCallToServerWaitForArbSyncObjectWhenWaitForSyn
gdi->waitForSynchronizationObject.mFunc = FailWaitSyncObjectMock::waitForSynchObject;
EXPECT_FALSE(syncInfo.waitCalled);
serverWaitForArbSyncObject(osInterface, syncInfo);
serverWaitForArbSyncObject(*osInterface, syncInfo);
EXPECT_FALSE(syncInfo.waitCalled);
}
@ -460,6 +466,6 @@ TEST_F(GlArbSyncEventOsTest, GivenCallToServerWaitForArbSyncObjectWhenWaitForSyn
syncInfo.serverSynchronizationObject = 0x7cU;
EXPECT_FALSE(syncInfo.waitCalled);
serverWaitForArbSyncObject(osInterface, syncInfo);
serverWaitForArbSyncObject(*osInterface, syncInfo);
EXPECT_TRUE(syncInfo.waitCalled);
}

View File

@ -22,9 +22,9 @@ TEST(osInterfaceTests, whenOsInterfaceSetupGmmInputArgsThenProperAdapterBDFIsSet
MockExecutionEnvironment executionEnvironment;
RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment);
auto wddm = new WddmMock(rootDeviceEnvironment);
OSInterface osInterface;
osInterface.get()->setWddm(wddm);
EXPECT_EQ(nullptr, rootDeviceEnvironment.osInterface.get());
wddm->init();
EXPECT_NE(nullptr, rootDeviceEnvironment.osInterface.get());
auto &adapterBDF = wddm->adapterBDF;
adapterBDF.Bus = 0x12;
@ -33,6 +33,6 @@ TEST(osInterfaceTests, whenOsInterfaceSetupGmmInputArgsThenProperAdapterBDFIsSet
GMM_INIT_IN_ARGS gmmInputArgs = {};
EXPECT_NE(0, memcmp(&adapterBDF, &gmmInputArgs.stAdapterBDF, sizeof(ADAPTER_BDF)));
osInterface.setGmmInputArgs(&gmmInputArgs);
rootDeviceEnvironment.osInterface->setGmmInputArgs(&gmmInputArgs);
EXPECT_EQ(0, memcmp(&adapterBDF, &gmmInputArgs.stAdapterBDF, sizeof(ADAPTER_BDF)));
}