mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 15:53:45 +08:00
Move wddm_fixture.h and releted files from opencl to shared
Related-To: NEO-5894 Signed-off-by: Piotr Obst <piotr.obst@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
0f072a93e0
commit
acf3e58a64
11
shared/test/common/os_interface/CMakeLists.txt
Normal file
11
shared/test/common/os_interface/CMakeLists.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
#
|
||||
# Copyright (C) 2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
)
|
||||
|
||||
add_subdirectories()
|
||||
13
shared/test/common/os_interface/windows/CMakeLists.txt
Normal file
13
shared/test/common/os_interface/windows/CMakeLists.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# Copyright (C) 2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gdi_dll_fixture.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm_fixture.h
|
||||
)
|
||||
|
||||
set_property(GLOBAL PROPERTY NEO_CORE_SHARED_TESTS_OS_INTERFACE_WINDOWS ${NEO_CORE_SHARED_TESTS_OS_INTERFACE_WINDOWS})
|
||||
95
shared/test/common/os_interface/windows/gdi_dll_fixture.h
Normal file
95
shared/test/common/os_interface/windows/gdi_dll_fixture.h
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/os_interface/os_library.h"
|
||||
#include "shared/test/common/helpers/default_hw_info.h"
|
||||
#include "shared/test/common/mock_gdi/mock_gdi.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
OsLibrary *setAdapterInfo(const PLATFORM *platform, const GT_SYSTEM_INFO *gtSystemInfo, uint64_t gpuAddressSpace);
|
||||
|
||||
struct GdiDllFixture {
|
||||
virtual void SetUp() {
|
||||
const HardwareInfo *hwInfo = defaultHwInfo.get();
|
||||
mockGdiDll.reset(setAdapterInfo(&hwInfo->platform, &hwInfo->gtSystemInfo, hwInfo->capabilityTable.gpuAddressSpace));
|
||||
|
||||
setSizesFcn = reinterpret_cast<decltype(&MockSetSizes)>(mockGdiDll->getProcAddress("MockSetSizes"));
|
||||
getSizesFcn = reinterpret_cast<decltype(&GetMockSizes)>(mockGdiDll->getProcAddress("GetMockSizes"));
|
||||
getMockLastDestroyedResHandleFcn =
|
||||
reinterpret_cast<decltype(&GetMockLastDestroyedResHandle)>(mockGdiDll->getProcAddress("GetMockLastDestroyedResHandle"));
|
||||
setMockLastDestroyedResHandleFcn =
|
||||
reinterpret_cast<decltype(&SetMockLastDestroyedResHandle)>(mockGdiDll->getProcAddress("SetMockLastDestroyedResHandle"));
|
||||
getMockCreateDeviceParamsFcn =
|
||||
reinterpret_cast<decltype(&GetMockCreateDeviceParams)>(mockGdiDll->getProcAddress("GetMockCreateDeviceParams"));
|
||||
setMockCreateDeviceParamsFcn =
|
||||
reinterpret_cast<decltype(&SetMockCreateDeviceParams)>(mockGdiDll->getProcAddress("SetMockCreateDeviceParams"));
|
||||
getMockAllocationFcn = reinterpret_cast<decltype(&getMockAllocation)>(mockGdiDll->getProcAddress("getMockAllocation"));
|
||||
getAdapterInfoAddressFcn = reinterpret_cast<decltype(&getAdapterInfoAddress)>(mockGdiDll->getProcAddress("getAdapterInfoAddress"));
|
||||
getLastCallMapGpuVaArgFcn = reinterpret_cast<decltype(&getLastCallMapGpuVaArg)>(mockGdiDll->getProcAddress("getLastCallMapGpuVaArg"));
|
||||
getLastCallReserveGpuVaArgFcn = reinterpret_cast<decltype(&getLastCallReserveGpuVaArg)>(mockGdiDll->getProcAddress("getLastCallReserveGpuVaArg"));
|
||||
setMapGpuVaFailConfigFcn = reinterpret_cast<decltype(&setMapGpuVaFailConfig)>(mockGdiDll->getProcAddress("setMapGpuVaFailConfig"));
|
||||
setMapGpuVaFailConfigFcn(0, 0);
|
||||
getCreateContextDataFcn = reinterpret_cast<decltype(&getCreateContextData)>(mockGdiDll->getProcAddress("getCreateContextData"));
|
||||
getCreateHwQueueDataFcn = reinterpret_cast<decltype(&getCreateHwQueueData)>(mockGdiDll->getProcAddress("getCreateHwQueueData"));
|
||||
getDestroyHwQueueDataFcn = reinterpret_cast<decltype(&getDestroyHwQueueData)>(mockGdiDll->getProcAddress("getDestroyHwQueueData"));
|
||||
getSubmitCommandToHwQueueDataFcn =
|
||||
reinterpret_cast<decltype(&getSubmitCommandToHwQueueData)>(mockGdiDll->getProcAddress("getSubmitCommandToHwQueueData"));
|
||||
getDestroySynchronizationObjectDataFcn =
|
||||
reinterpret_cast<decltype(&getDestroySynchronizationObjectData)>(mockGdiDll->getProcAddress("getDestroySynchronizationObjectData"));
|
||||
getMonitorFenceCpuFenceAddressFcn =
|
||||
reinterpret_cast<decltype(&getMonitorFenceCpuFenceAddress)>(mockGdiDll->getProcAddress("getMonitorFenceCpuFenceAddress"));
|
||||
getCreateSynchronizationObject2FailCallFcn =
|
||||
reinterpret_cast<decltype(&getCreateSynchronizationObject2FailCall)>(mockGdiDll->getProcAddress("getCreateSynchronizationObject2FailCall"));
|
||||
getRegisterTrimNotificationFailCallFcn =
|
||||
reinterpret_cast<decltype(&getRegisterTrimNotificationFailCall)>(mockGdiDll->getProcAddress("getRegisterTrimNotificationFailCall"));
|
||||
getLastPriorityFcn =
|
||||
reinterpret_cast<decltype(&getLastPriority)>(mockGdiDll->getProcAddress("getLastPriority"));
|
||||
setAdapterBDFFcn =
|
||||
reinterpret_cast<decltype(&setAdapterBDF)>(mockGdiDll->getProcAddress("setAdapterBDF"));
|
||||
setMockLastDestroyedResHandleFcn((D3DKMT_HANDLE)0);
|
||||
*getDestroySynchronizationObjectDataFcn() = {};
|
||||
*getCreateSynchronizationObject2FailCallFcn() = false;
|
||||
*getRegisterTrimNotificationFailCallFcn() = false;
|
||||
}
|
||||
|
||||
virtual void TearDown() {
|
||||
*getCreateHwQueueDataFcn() = {};
|
||||
*getDestroyHwQueueDataFcn() = {};
|
||||
*getSubmitCommandToHwQueueDataFcn() = {};
|
||||
*getDestroySynchronizationObjectDataFcn() = {};
|
||||
setMapGpuVaFailConfigFcn(0, 0);
|
||||
*getCreateSynchronizationObject2FailCallFcn() = false;
|
||||
*getRegisterTrimNotificationFailCallFcn() = false;
|
||||
}
|
||||
|
||||
std::unique_ptr<OsLibrary> mockGdiDll;
|
||||
|
||||
decltype(&MockSetSizes) setSizesFcn = nullptr;
|
||||
decltype(&GetMockSizes) getSizesFcn = nullptr;
|
||||
decltype(&GetMockLastDestroyedResHandle) getMockLastDestroyedResHandleFcn = nullptr;
|
||||
decltype(&SetMockLastDestroyedResHandle) setMockLastDestroyedResHandleFcn = nullptr;
|
||||
decltype(&GetMockCreateDeviceParams) getMockCreateDeviceParamsFcn = nullptr;
|
||||
decltype(&SetMockCreateDeviceParams) setMockCreateDeviceParamsFcn = nullptr;
|
||||
decltype(&getMockAllocation) getMockAllocationFcn = nullptr;
|
||||
decltype(&getAdapterInfoAddress) getAdapterInfoAddressFcn = nullptr;
|
||||
decltype(&getLastCallMapGpuVaArg) getLastCallMapGpuVaArgFcn = nullptr;
|
||||
decltype(&getLastCallReserveGpuVaArg) getLastCallReserveGpuVaArgFcn = nullptr;
|
||||
decltype(&setMapGpuVaFailConfig) setMapGpuVaFailConfigFcn = nullptr;
|
||||
decltype(&getCreateContextData) getCreateContextDataFcn = nullptr;
|
||||
decltype(&getCreateHwQueueData) getCreateHwQueueDataFcn = nullptr;
|
||||
decltype(&getDestroyHwQueueData) getDestroyHwQueueDataFcn = nullptr;
|
||||
decltype(&getSubmitCommandToHwQueueData) getSubmitCommandToHwQueueDataFcn = nullptr;
|
||||
decltype(&getDestroySynchronizationObjectData) getDestroySynchronizationObjectDataFcn = nullptr;
|
||||
decltype(&getMonitorFenceCpuFenceAddress) getMonitorFenceCpuFenceAddressFcn = nullptr;
|
||||
decltype(&getCreateSynchronizationObject2FailCall) getCreateSynchronizationObject2FailCallFcn = nullptr;
|
||||
decltype(&getRegisterTrimNotificationFailCall) getRegisterTrimNotificationFailCallFcn = nullptr;
|
||||
decltype(&getLastPriority) getLastPriorityFcn = nullptr;
|
||||
decltype(&setAdapterBDF) setAdapterBDFFcn = nullptr;
|
||||
};
|
||||
125
shared/test/common/os_interface/windows/wddm_fixture.h
Normal file
125
shared/test/common/os_interface/windows/wddm_fixture.h
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#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"
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
#include "shared/source/os_interface/windows/gdi_interface.h"
|
||||
#include "shared/source/os_interface/windows/os_context_win.h"
|
||||
#include "shared/source/os_interface/windows/os_environment_win.h"
|
||||
#include "shared/source/os_interface/windows/wddm_memory_operations_handler.h"
|
||||
#include "shared/test/common/fixtures/mock_execution_environment_gmm_fixture.h"
|
||||
#include "shared/test/common/helpers/default_hw_info.h"
|
||||
#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"
|
||||
#include "shared/test/common/os_interface/windows/gdi_dll_fixture.h"
|
||||
#include "shared/test/unit_test/os_interface/windows/mock_gdi_interface.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#include "mock_gmm_memory.h"
|
||||
|
||||
namespace NEO {
|
||||
struct WddmFixture : public Test<MockExecutionEnvironmentGmmFixture> {
|
||||
void SetUp() override {
|
||||
MockExecutionEnvironmentGmmFixture::SetUp();
|
||||
rootDeviceEnvironemnt = executionEnvironment->rootDeviceEnvironments[0].get();
|
||||
auto osEnvironment = new OsEnvironmentWin();
|
||||
gdi = new MockGdi();
|
||||
osEnvironment->gdi.reset(gdi);
|
||||
executionEnvironment->osEnvironment.reset(osEnvironment);
|
||||
wddm = static_cast<WddmMock *>(Wddm::createWddm(nullptr, *rootDeviceEnvironemnt));
|
||||
rootDeviceEnvironemnt->osInterface = std::make_unique<OSInterface>();
|
||||
rootDeviceEnvironemnt->osInterface->setDriverModel(std::unique_ptr<DriverModel>(wddm));
|
||||
rootDeviceEnvironemnt->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
|
||||
osInterface = rootDeviceEnvironemnt->osInterface.get();
|
||||
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo);
|
||||
wddm->init();
|
||||
auto hwInfo = rootDeviceEnvironemnt->getHardwareInfo();
|
||||
auto engine = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[0];
|
||||
osContext = std::make_unique<OsContextWin>(*osInterface->getDriverModel()->as<Wddm>(), 0u, 1u, engine, preemptionMode,
|
||||
false);
|
||||
osContext->ensureContextInitialized();
|
||||
mockTemporaryResources = static_cast<MockWddmResidentAllocationsContainer *>(wddm->temporaryResources.get());
|
||||
}
|
||||
|
||||
WddmMock *wddm = nullptr;
|
||||
OSInterface *osInterface;
|
||||
RootDeviceEnvironment *rootDeviceEnvironemnt = nullptr;
|
||||
std::unique_ptr<OsContextWin> osContext;
|
||||
|
||||
MockGdi *gdi = nullptr;
|
||||
MockWddmResidentAllocationsContainer *mockTemporaryResources;
|
||||
};
|
||||
|
||||
struct WddmFixtureWithMockGdiDll : public GdiDllFixture, public MockExecutionEnvironmentGmmFixture {
|
||||
void SetUp() override {
|
||||
MockExecutionEnvironmentGmmFixture::SetUp();
|
||||
GdiDllFixture::SetUp();
|
||||
rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get();
|
||||
wddm = static_cast<WddmMock *>(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, 1, engine, preemptionMode,
|
||||
false);
|
||||
osContext->ensureContextInitialized();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
GdiDllFixture::TearDown();
|
||||
}
|
||||
|
||||
WddmMock *wddm = nullptr;
|
||||
OSInterface *osInterface;
|
||||
std::unique_ptr<OsContextWin> osContext;
|
||||
WddmMockInterface20 *wddmMockInterface = nullptr;
|
||||
RootDeviceEnvironment *rootDeviceEnvironment = nullptr;
|
||||
};
|
||||
|
||||
struct WddmInstrumentationGmmFixture {
|
||||
void SetUp() {
|
||||
executionEnvironment = platform()->peekExecutionEnvironment();
|
||||
auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get();
|
||||
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->setDriverModel(std::unique_ptr<DriverModel>(wddm));
|
||||
}
|
||||
void TearDown() {
|
||||
}
|
||||
|
||||
WddmMock *wddm;
|
||||
GmockGmmMemory *gmmMem = nullptr;
|
||||
ExecutionEnvironment *executionEnvironment;
|
||||
};
|
||||
|
||||
using WddmTest = WddmFixture;
|
||||
using WddmTestWithMockGdiDll = Test<WddmFixtureWithMockGdiDll>;
|
||||
using WddmInstrumentationTest = Test<WddmInstrumentationGmmFixture>;
|
||||
using WddmTestSingle = ::testing::Test;
|
||||
} // namespace NEO
|
||||
Reference in New Issue
Block a user