2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2021-12-31 13:56:03 +00:00
|
|
|
* Copyright (C) 2018-2022 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
2018-05-08 13:19:26 +02:00
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#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/hw_helper.h"
|
2021-05-21 01:17:57 +02:00
|
|
|
#include "shared/source/os_interface/os_interface.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/os_interface/windows/gdi_interface.h"
|
|
|
|
|
#include "shared/source/os_interface/windows/os_context_win.h"
|
2020-03-17 07:26:46 +01:00
|
|
|
#include "shared/source/os_interface/windows/os_environment_win.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/os_interface/windows/wddm_memory_operations_handler.h"
|
2021-07-09 13:06:20 +00:00
|
|
|
#include "shared/test/common/fixtures/device_fixture.h"
|
2021-07-06 15:44:16 +02:00
|
|
|
#include "shared/test/common/fixtures/mock_execution_environment_gmm_fixture.h"
|
2021-01-21 13:10:13 +01:00
|
|
|
#include "shared/test/common/helpers/default_hw_info.h"
|
2021-08-11 17:36:00 +00:00
|
|
|
#include "shared/test/common/helpers/engine_descriptor_helper.h"
|
2021-07-06 15:44:16 +02:00
|
|
|
#include "shared/test/common/mocks/mock_execution_environment.h"
|
|
|
|
|
#include "shared/test/common/mocks/mock_wddm.h"
|
|
|
|
|
#include "shared/test/common/mocks/mock_wddm_interface20.h"
|
|
|
|
|
#include "shared/test/common/mocks/mock_wddm_residency_allocations_container.h"
|
2021-12-31 13:56:03 +00:00
|
|
|
#include "shared/test/common/mocks/windows/mock_gdi_interface.h"
|
2021-10-21 18:22:38 +00:00
|
|
|
#include "shared/test/common/mocks/windows/mock_gmm_memory_base.h"
|
2021-07-06 15:44:16 +02:00
|
|
|
#include "shared/test/common/os_interface/windows/gdi_dll_fixture.h"
|
2021-12-14 17:40:08 +00:00
|
|
|
#include "shared/test/common/test_macros/test.h"
|
2020-02-24 10:22:30 +01:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2020-03-30 14:11:43 +02:00
|
|
|
struct WddmFixture : public Test<MockExecutionEnvironmentGmmFixture> {
|
2019-07-12 16:50:14 +02:00
|
|
|
void SetUp() override {
|
2020-03-30 14:11:43 +02:00
|
|
|
MockExecutionEnvironmentGmmFixture::SetUp();
|
2021-08-06 13:38:07 +00:00
|
|
|
rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get();
|
2020-03-17 07:26:46 +01:00
|
|
|
auto osEnvironment = new OsEnvironmentWin();
|
|
|
|
|
gdi = new MockGdi();
|
|
|
|
|
osEnvironment->gdi.reset(gdi);
|
|
|
|
|
executionEnvironment->osEnvironment.reset(osEnvironment);
|
2021-08-06 13:38:07 +00:00
|
|
|
wddm = static_cast<WddmMock *>(Wddm::createWddm(nullptr, *rootDeviceEnvironment));
|
|
|
|
|
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
|
|
|
|
|
rootDeviceEnvironment->osInterface->setDriverModel(std::unique_ptr<DriverModel>(wddm));
|
|
|
|
|
rootDeviceEnvironment->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
|
|
|
|
|
osInterface = rootDeviceEnvironment->osInterface.get();
|
2020-03-24 11:42:54 +01:00
|
|
|
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo);
|
2020-02-10 11:15:34 +01:00
|
|
|
wddm->init();
|
2021-08-06 13:38:07 +00:00
|
|
|
auto hwInfo = rootDeviceEnvironment->getHardwareInfo();
|
2021-03-08 18:50:32 +00:00
|
|
|
auto engine = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[0];
|
2021-08-11 17:36:00 +00:00
|
|
|
osContext = std::make_unique<OsContextWin>(*osInterface->getDriverModel()->as<Wddm>(), 0u, EngineDescriptorHelper::getDefaultDescriptor(engine, preemptionMode));
|
2021-04-15 16:14:04 +00:00
|
|
|
osContext->ensureContextInitialized();
|
2019-07-12 16:50:14 +02:00
|
|
|
mockTemporaryResources = static_cast<MockWddmResidentAllocationsContainer *>(wddm->temporaryResources.get());
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
2018-08-27 15:48:29 +02:00
|
|
|
WddmMock *wddm = nullptr;
|
2019-03-21 17:45:00 +01:00
|
|
|
OSInterface *osInterface;
|
2021-08-06 13:38:07 +00:00
|
|
|
RootDeviceEnvironment *rootDeviceEnvironment = nullptr;
|
2020-03-17 07:26:46 +01:00
|
|
|
std::unique_ptr<OsContextWin> osContext;
|
2018-08-27 15:48:29 +02:00
|
|
|
|
2018-05-10 11:42:41 +02:00
|
|
|
MockGdi *gdi = nullptr;
|
2019-07-12 16:50:14 +02:00
|
|
|
MockWddmResidentAllocationsContainer *mockTemporaryResources;
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
|
|
|
|
|
2020-03-30 14:11:43 +02:00
|
|
|
struct WddmFixtureWithMockGdiDll : public GdiDllFixture, public MockExecutionEnvironmentGmmFixture {
|
2018-05-07 20:42:00 +02:00
|
|
|
void SetUp() override {
|
2020-03-30 14:11:43 +02:00
|
|
|
MockExecutionEnvironmentGmmFixture::SetUp();
|
2018-05-07 20:42:00 +02:00
|
|
|
GdiDllFixture::SetUp();
|
2020-03-30 14:11:43 +02:00
|
|
|
rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get();
|
2020-02-24 18:04:30 +01:00
|
|
|
wddm = static_cast<WddmMock *>(Wddm::createWddm(nullptr, *rootDeviceEnvironment));
|
2019-12-13 15:47:45 +01:00
|
|
|
wddmMockInterface = new WddmMockInterface20(*wddm);
|
|
|
|
|
wddm->wddmInterface.reset(wddmMockInterface);
|
2020-02-24 18:04:30 +01:00
|
|
|
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
|
2021-05-21 01:17:57 +02:00
|
|
|
rootDeviceEnvironment->osInterface->setDriverModel(std::unique_ptr<DriverModel>(wddm));
|
2020-02-24 18:04:30 +01:00
|
|
|
rootDeviceEnvironment->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
|
|
|
|
|
osInterface = rootDeviceEnvironment->osInterface.get();
|
2018-08-27 15:48:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void init() {
|
2020-03-24 11:42:54 +01:00
|
|
|
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo);
|
2019-12-17 14:29:28 +01:00
|
|
|
wddmMockInterface = static_cast<WddmMockInterface20 *>(wddm->wddmInterface.release());
|
2020-02-10 11:15:34 +01:00
|
|
|
wddm->init();
|
2019-12-13 15:47:45 +01:00
|
|
|
wddm->wddmInterface.reset(wddmMockInterface);
|
2020-02-21 15:25:04 +01:00
|
|
|
|
2020-03-03 09:21:18 +01:00
|
|
|
auto hwInfo = rootDeviceEnvironment->getHardwareInfo();
|
2021-03-08 18:50:32 +00:00
|
|
|
auto engine = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[0];
|
2021-08-11 17:36:00 +00:00
|
|
|
osContext = std::make_unique<OsContextWin>(*osInterface->getDriverModel()->as<Wddm>(), 0u, EngineDescriptorHelper::getDefaultDescriptor(engine, preemptionMode));
|
2021-04-15 16:14:04 +00:00
|
|
|
osContext->ensureContextInitialized();
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
2018-05-07 20:42:00 +02:00
|
|
|
void TearDown() override {
|
|
|
|
|
GdiDllFixture::TearDown();
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
2018-05-07 20:42:00 +02:00
|
|
|
|
2018-08-27 15:48:29 +02:00
|
|
|
WddmMock *wddm = nullptr;
|
2019-03-21 17:45:00 +01:00
|
|
|
OSInterface *osInterface;
|
2019-02-27 11:17:17 +01:00
|
|
|
std::unique_ptr<OsContextWin> osContext;
|
2019-12-13 15:47:45 +01:00
|
|
|
WddmMockInterface20 *wddmMockInterface = nullptr;
|
2020-02-24 18:04:30 +01:00
|
|
|
RootDeviceEnvironment *rootDeviceEnvironment = nullptr;
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
|
|
|
|
|
2021-12-16 02:13:00 +00:00
|
|
|
struct NoCleanupWddmMock : WddmMock {
|
|
|
|
|
bool skipResourceCleanup() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct WddmFixtureWithMockGdiDllWddmNoCleanup : public GdiDllFixture, public MockExecutionEnvironmentGmmFixture {
|
|
|
|
|
void SetUp() override {
|
|
|
|
|
MockExecutionEnvironmentGmmFixture::SetUp();
|
|
|
|
|
GdiDllFixture::SetUp();
|
|
|
|
|
rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get();
|
|
|
|
|
wddm = static_cast<NoCleanupWddmMock *>(Wddm::createWddm(nullptr, *rootDeviceEnvironment));
|
|
|
|
|
wddmMockInterface = new WddmMockInterface20(*wddm);
|
|
|
|
|
wddm->wddmInterface.reset(wddmMockInterface);
|
|
|
|
|
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
|
|
|
|
|
rootDeviceEnvironment->osInterface->setDriverModel(std::unique_ptr<DriverModel>(wddm));
|
|
|
|
|
rootDeviceEnvironment->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
|
|
|
|
|
osInterface = rootDeviceEnvironment->osInterface.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void init() {
|
|
|
|
|
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo);
|
|
|
|
|
wddmMockInterface = static_cast<WddmMockInterface20 *>(wddm->wddmInterface.release());
|
|
|
|
|
wddm->init();
|
|
|
|
|
wddm->wddmInterface.reset(wddmMockInterface);
|
|
|
|
|
|
|
|
|
|
auto hwInfo = rootDeviceEnvironment->getHardwareInfo();
|
|
|
|
|
auto engine = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[0];
|
|
|
|
|
osContext = std::make_unique<OsContextWin>(*osInterface->getDriverModel()->as<Wddm>(), 0u, EngineDescriptorHelper::getDefaultDescriptor(engine, preemptionMode));
|
|
|
|
|
osContext->ensureContextInitialized();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TearDown() override {
|
|
|
|
|
GdiDllFixture::TearDown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NoCleanupWddmMock *wddm = nullptr;
|
|
|
|
|
OSInterface *osInterface;
|
|
|
|
|
std::unique_ptr<OsContextWin> osContext;
|
|
|
|
|
WddmMockInterface20 *wddmMockInterface = nullptr;
|
|
|
|
|
RootDeviceEnvironment *rootDeviceEnvironment = nullptr;
|
|
|
|
|
};
|
|
|
|
|
|
2021-07-09 13:06:20 +00:00
|
|
|
struct WddmInstrumentationGmmFixture : DeviceFixture {
|
2019-01-23 11:59:54 +01:00
|
|
|
void SetUp() {
|
2021-07-09 13:06:20 +00:00
|
|
|
DeviceFixture::SetUp();
|
|
|
|
|
executionEnvironment = pDevice->getExecutionEnvironment();
|
2020-02-24 18:04:30 +01:00
|
|
|
auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get();
|
2020-04-08 11:45:54 +02:00
|
|
|
wddm = static_cast<WddmMock *>(Wddm::createWddm(nullptr, *rootDeviceEnvironment));
|
2020-02-24 18:04:30 +01:00
|
|
|
gmmMem = new ::testing::NiceMock<GmockGmmMemory>(rootDeviceEnvironment->getGmmClientContext());
|
2018-05-08 21:57:36 +02:00
|
|
|
wddm->gmmMemory.reset(gmmMem);
|
2020-04-08 11:45:54 +02:00
|
|
|
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
|
2021-05-21 01:17:57 +02:00
|
|
|
rootDeviceEnvironment->osInterface->setDriverModel(std::unique_ptr<DriverModel>(wddm));
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
2019-01-23 11:59:54 +01:00
|
|
|
void TearDown() {
|
2021-07-09 13:06:20 +00:00
|
|
|
DeviceFixture::TearDown();
|
2018-07-16 16:37:17 +02:00
|
|
|
}
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2020-04-08 11:45:54 +02:00
|
|
|
WddmMock *wddm;
|
2018-05-07 20:42:00 +02:00
|
|
|
GmockGmmMemory *gmmMem = nullptr;
|
2019-01-23 11:59:54 +01:00
|
|
|
ExecutionEnvironment *executionEnvironment;
|
2018-05-07 20:42:00 +02:00
|
|
|
};
|
2018-05-08 13:19:26 +02:00
|
|
|
|
2019-01-23 11:59:54 +01:00
|
|
|
using WddmTest = WddmFixture;
|
2018-07-16 16:37:17 +02:00
|
|
|
using WddmTestWithMockGdiDll = Test<WddmFixtureWithMockGdiDll>;
|
2021-12-16 02:13:00 +00:00
|
|
|
using WddmTestWithMockGdiDllNoCleanup = Test<WddmFixtureWithMockGdiDllWddmNoCleanup>;
|
2018-07-16 16:37:17 +02:00
|
|
|
using WddmInstrumentationTest = Test<WddmInstrumentationGmmFixture>;
|
|
|
|
|
using WddmTestSingle = ::testing::Test;
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|