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