| 1 |
/* |
| 2 |
* Copyright (C) 2020-2022 Intel Corporation |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: MIT |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
#include "shared/source/command_stream/preemption.h" |
| 9 |
#include "shared/source/execution_environment/root_device_environment.h" |
| 10 |
#include "shared/source/os_interface/os_interface.h" |
| 11 |
#include "shared/source/os_interface/windows/gdi_interface.h" |
| 12 |
#include "shared/test/common/mocks/mock_execution_environment.h" |
| 13 |
#include "shared/test/common/mocks/mock_wddm.h" |
| 14 |
#include "shared/test/common/mocks/windows/mock_gmm_memory_base.h" |
| 15 |
#include "shared/test/common/os_interface/windows/gdi_dll_fixture.h" |
| 16 |
#include "shared/test/common/test_macros/hw_test.h" |
| 17 |
|
| 18 |
using namespace NEO; |
| 19 |
|
| 20 |
struct Gen12LpWddmTest : public ::testing::Test { |
| 21 |
void SetUp() override { |
| 22 |
executionEnvironment = std::make_unique<MockExecutionEnvironment>(); |
| 23 |
rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get(); |
| 24 |
rootDeviceEnvironment->initGmm(); |
| 25 |
wddm = static_cast<WddmMock *>(Wddm::createWddm(nullptr, *rootDeviceEnvironment)); |
| 26 |
gmmMemory = new MockGmmMemoryBase(rootDeviceEnvironment->getGmmClientContext()); |
| 27 |
wddm->gmmMemory.reset(gmmMemory); |
| 28 |
} |
| 29 |
|
| 30 |
void TearDown() override { |
| 31 |
} |
| 32 |
|
| 33 |
std::unique_ptr<MockExecutionEnvironment> executionEnvironment; |
| 34 |
RootDeviceEnvironment *rootDeviceEnvironment = nullptr; |
| 35 |
WddmMock *wddm = nullptr; |
| 36 |
MockGmmMemoryBase *gmmMemory = nullptr; |
| 37 |
}; |
| 38 |
|
| 39 |
GEN12LPTEST_F(Gen12LpWddmTest, whenConfigureDeviceAddressSpaceThenObtainMinAddress) { |
| 40 |
uintptr_t minAddress = 0x12345u; |
| 41 |
|
| 42 |
EXPECT_NE(NEO::windowsMinAddress, minAddress); |
| 43 |
|
| 44 |
gmmMemory->getInternalGpuVaRangeLimitResult = minAddress; |
| 45 |
|
| 46 |
wddm->init(); |
| 47 |
|
| 48 |
EXPECT_EQ(minAddress, wddm->getWddmMinAddress()); |
| 49 |
EXPECT_EQ(1u, gmmMemory->getInternalGpuVaRangeLimitCalled); |
| 50 |
} |
| 51 |
|
| 52 |
using Gen12LpWddmHwInfoTest = ::testing::Test; |
| 53 |
|
| 54 |
GEN12LPTEST_F(Gen12LpWddmHwInfoTest, givenIncorrectProductFamiliyWhenInitCalledThenOverride) { |
| 55 |
HardwareInfo localHwInfo = *defaultHwInfo; |
| 56 |
|
| 57 |
localHwInfo.platform.eRenderCoreFamily = GFXCORE_FAMILY::IGFX_UNKNOWN_CORE; |
| 58 |
localHwInfo.platform.eDisplayCoreFamily = GFXCORE_FAMILY::IGFX_UNKNOWN_CORE; |
| 59 |
|
| 60 |
std::unique_ptr<OsLibrary> mockGdiDll(setAdapterInfo(&localHwInfo.platform, |
| 61 |
&localHwInfo.gtSystemInfo, |
| 62 |
localHwInfo.capabilityTable.gpuAddressSpace)); |
| 63 |
|
| 64 |
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>(); |
| 65 |
auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get(); |
| 66 |
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>(); |
| 67 |
|
| 68 |
auto localWddm = std::unique_ptr<Wddm>(Wddm::createWddm(nullptr, *rootDeviceEnvironment)); |
| 69 |
localWddm->init(); |
| 70 |
|
| 71 |
auto newHwInfo = rootDeviceEnvironment->getHardwareInfo(); |
| 72 |
|
| 73 |
EXPECT_EQ(GFXCORE_FAMILY::IGFX_GEN12LP_CORE, newHwInfo->platform.eRenderCoreFamily); |
| 74 |
EXPECT_EQ(GFXCORE_FAMILY::IGFX_GEN12LP_CORE, newHwInfo->platform.eDisplayCoreFamily); |
| 75 |
|
| 76 |
// reset mock gdi globals |
| 77 |
localHwInfo = *defaultHwInfo; |
| 78 |
mockGdiDll.reset(setAdapterInfo(&localHwInfo.platform, |
| 79 |
&localHwInfo.gtSystemInfo, |
| 80 |
localHwInfo.capabilityTable.gpuAddressSpace)); |
| 81 |
} |