mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Move memory fixtures to shared
Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
997d28f6b2
commit
0cbc320e57
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/fixtures/memory_allocator_multi_device_fixture.h"
|
||||
#include "shared/test/common/mocks/linux/mock_drm_memory_manager.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
void MemoryAllocatorMultiDeviceSystemSpecificFixture::SetUp(ExecutionEnvironment &executionEnvironment) {
|
||||
auto memoryManager = static_cast<TestedDrmMemoryManager *>(executionEnvironment.memoryManager.get());
|
||||
auto bufferObject = new (std::nothrow) BufferObject(&memoryManager->getDrm(0u), 0, 10, MemoryManager::maxOsContextCount);
|
||||
memoryManager->pushSharedBufferObject(bufferObject);
|
||||
}
|
||||
|
||||
void MemoryAllocatorMultiDeviceSystemSpecificFixture::TearDown(ExecutionEnvironment &executionEnvironment) {
|
||||
auto memoryManager = static_cast<TestedDrmMemoryManager *>(executionEnvironment.memoryManager.get());
|
||||
auto bufferObject = memoryManager->sharingBufferObjects.back();
|
||||
memoryManager->eraseSharedBufferObject(bufferObject);
|
||||
delete bufferObject;
|
||||
}
|
||||
49
shared/test/common/fixtures/memory_allocator_fixture.h
Normal file
49
shared/test/common/fixtures/memory_allocator_fixture.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2022 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/helpers/hw_helper.h"
|
||||
#include "shared/source/memory_manager/os_agnostic_memory_manager.h"
|
||||
#include "shared/test/common/fixtures/memory_management_fixture.h"
|
||||
#include "shared/test/common/helpers/engine_descriptor_helper.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/mock_memory_manager.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
class MemoryAllocatorFixture : public MemoryManagementFixture {
|
||||
public:
|
||||
void SetUp() override {
|
||||
MemoryManagementFixture::SetUp();
|
||||
executionEnvironment = new ExecutionEnvironment();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
|
||||
device.reset(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, 0u));
|
||||
memoryManager = new MockMemoryManager(false, false, *executionEnvironment);
|
||||
executionEnvironment->memoryManager.reset(memoryManager);
|
||||
csr = &device->getGpgpuCommandStreamReceiver();
|
||||
auto &hwInfo = device->getHardwareInfo();
|
||||
auto engineType = HwHelper::get(hwInfo.platform.eRenderCoreFamily).getGpgpuEngineInstances(hwInfo)[0].first;
|
||||
auto osContext = memoryManager->createAndRegisterOsContext(csr, EngineDescriptorHelper::getDefaultDescriptor({engineType, EngineUsage::Regular},
|
||||
PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo)));
|
||||
csr->setupContext(*osContext);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
device.reset();
|
||||
MemoryManagementFixture::TearDown();
|
||||
}
|
||||
|
||||
protected:
|
||||
std::unique_ptr<MockDevice> device;
|
||||
ExecutionEnvironment *executionEnvironment;
|
||||
MockMemoryManager *memoryManager = nullptr;
|
||||
CommandStreamReceiver *csr = nullptr;
|
||||
};
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/gmm_helper/gmm.h"
|
||||
#include "shared/source/os_interface/device_factory.h"
|
||||
#include "shared/test/common/fixtures/memory_management_fixture.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/default_hw_info.h"
|
||||
#include "shared/test/common/helpers/ult_hw_config.h"
|
||||
#include "shared/test/common/helpers/variable_backup.h"
|
||||
#include "shared/test/common/mocks/mock_execution_environment.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
class MemoryAllocatorMultiDeviceSystemSpecificFixture {
|
||||
public:
|
||||
void SetUp(ExecutionEnvironment &executionEnvironment);
|
||||
void TearDown(ExecutionEnvironment &executionEnvironment);
|
||||
|
||||
std::unique_ptr<Gmm> gmm;
|
||||
};
|
||||
|
||||
template <uint32_t numRootDevices>
|
||||
class MemoryAllocatorMultiDeviceFixture : public MemoryManagementFixture, public MemoryAllocatorMultiDeviceSystemSpecificFixture, public ::testing::TestWithParam<bool> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
MemoryManagementFixture::SetUp();
|
||||
|
||||
isOsAgnosticMemoryManager = GetParam();
|
||||
DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices);
|
||||
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
||||
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
|
||||
ultHwConfig.forceOsAgnosticMemoryManager = isOsAgnosticMemoryManager;
|
||||
|
||||
executionEnvironment = new MockExecutionEnvironment(defaultHwInfo.get(), true, numRootDevices);
|
||||
devices = DeviceFactory::createDevices(*executionEnvironment);
|
||||
memoryManager = executionEnvironment->memoryManager.get();
|
||||
|
||||
if (!isOsAgnosticMemoryManager) {
|
||||
MemoryAllocatorMultiDeviceSystemSpecificFixture::SetUp(*executionEnvironment);
|
||||
}
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
if (!isOsAgnosticMemoryManager) {
|
||||
MemoryAllocatorMultiDeviceSystemSpecificFixture::TearDown(*executionEnvironment);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t getNumRootDevices() { return numRootDevices; }
|
||||
|
||||
protected:
|
||||
std::vector<std::unique_ptr<Device>> devices;
|
||||
ExecutionEnvironment *executionEnvironment = nullptr;
|
||||
MemoryManager *memoryManager = nullptr;
|
||||
DebugManagerStateRestore restorer;
|
||||
bool isOsAgnosticMemoryManager;
|
||||
};
|
||||
34
shared/test/common/fixtures/memory_manager_fixture.cpp
Normal file
34
shared/test/common/fixtures/memory_manager_fixture.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/fixtures/memory_manager_fixture.h"
|
||||
|
||||
#include "shared/source/command_stream/preemption.h"
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/source/os_interface/os_context.h"
|
||||
#include "shared/test/common/helpers/engine_descriptor_helper.h"
|
||||
#include "shared/test/common/mocks/mock_csr.h"
|
||||
#include "shared/test/common/mocks/mock_memory_manager.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
void MemoryManagerWithCsrFixture::SetUp() {
|
||||
executionEnvironment.prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment.rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
|
||||
csr = std::make_unique<MockCommandStreamReceiver>(this->executionEnvironment, 0, 1);
|
||||
memoryManager = new MockMemoryManager(executionEnvironment);
|
||||
executionEnvironment.memoryManager.reset(memoryManager);
|
||||
csr->tagAddress = ¤tGpuTag;
|
||||
auto hwInfo = executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo();
|
||||
auto engine = HwHelper::get(hwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[0];
|
||||
auto osContext = memoryManager->createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor({engine.first, EngineUsage::Regular},
|
||||
PreemptionHelper::getDefaultPreemptionMode(*hwInfo)));
|
||||
csr->setupContext(*osContext);
|
||||
}
|
||||
|
||||
void MemoryManagerWithCsrFixture::TearDown() {
|
||||
}
|
||||
31
shared/test/common/fixtures/memory_manager_fixture.h
Normal file
31
shared/test/common/fixtures/memory_manager_fixture.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#include "shared/source/helpers/options.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
class MockCommandStreamReceiver;
|
||||
namespace NEO {
|
||||
class MockMemoryManager;
|
||||
}; // namespace NEO
|
||||
|
||||
class MemoryManagerWithCsrFixture {
|
||||
public:
|
||||
MockMemoryManager *memoryManager;
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
std::unique_ptr<MockCommandStreamReceiver> csr;
|
||||
uint32_t taskCount = 0;
|
||||
uint32_t currentGpuTag = initialHardwareTag;
|
||||
|
||||
~MemoryManagerWithCsrFixture() = default;
|
||||
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/source/gmm_helper/resource_info.h"
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
#include "shared/source/os_interface/windows/os_environment_win.h"
|
||||
#include "shared/test/common/fixtures/memory_allocator_multi_device_fixture.h"
|
||||
#include "shared/test/common/mock_gdi/mock_gdi.h"
|
||||
#include "shared/test/common/mocks/mock_wddm.h"
|
||||
#include "shared/test/common/mocks/windows/mock_gdi_interface.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
void MemoryAllocatorMultiDeviceSystemSpecificFixture::SetUp(ExecutionEnvironment &executionEnvironment) {
|
||||
static D3DDDI_OPENALLOCATIONINFO allocationInfo;
|
||||
auto gdi = new MockGdi();
|
||||
gdi->getQueryResourceInfoArgOut().NumAllocations = 1;
|
||||
gdi->getOpenResourceArgOut().pOpenAllocationInfo = &allocationInfo;
|
||||
auto osEnvironment = new OsEnvironmentWin();
|
||||
osEnvironment->gdi.reset(gdi);
|
||||
for (auto i = 0u; i < executionEnvironment.rootDeviceEnvironments.size(); i++) {
|
||||
gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[i]->getGmmClientContext(), nullptr, 0, 0, false);
|
||||
auto wddm = static_cast<WddmMock *>(executionEnvironment.rootDeviceEnvironments[i]->osInterface->getDriverModel()->as<Wddm>());
|
||||
wddm->hwDeviceId = std::make_unique<HwDeviceIdWddm>(ADAPTER_HANDLE, LUID{}, osEnvironment, std::make_unique<UmKmDataTranslator>());
|
||||
wddm->callBaseMapGpuVa = false;
|
||||
|
||||
allocationInfo.pPrivateDriverData = gmm->gmmResourceInfo->peekHandle();
|
||||
allocationInfo.hAllocation = ALLOCATION_HANDLE;
|
||||
allocationInfo.PrivateDriverDataSize = sizeof(GMM_RESOURCE_INFO);
|
||||
}
|
||||
executionEnvironment.osEnvironment.reset(osEnvironment);
|
||||
}
|
||||
|
||||
void MemoryAllocatorMultiDeviceSystemSpecificFixture::TearDown(ExecutionEnvironment &executionEnvironment) {}
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2021 Intel Corporation
|
||||
# Copyright (C) 2021-2022 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@@ -63,8 +63,12 @@ set(neo_libult_common_SRCS_LIB_ULT
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/fixtures/device_fixture.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/fixtures/device_fixture.h
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/fixtures/gmm_callbacks_fixture.h
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/fixtures/memory_allocator_fixture.h
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/fixtures/memory_allocator_multi_device_fixture.h
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/fixtures/memory_management_fixture.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/fixtures/memory_management_fixture.h
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/fixtures/memory_manager_fixture.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/fixtures/memory_manager_fixture.h
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/fixtures/mock_execution_environment_gmm_fixture.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/fixtures/mock_execution_environment_gmm_fixture.h
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/fixtures/tbx_command_stream_fixture.cpp
|
||||
@@ -114,14 +118,14 @@ if(TESTS_XEHP_AND_LATER)
|
||||
endif()
|
||||
|
||||
get_property(NEO_SHARED_TESTS_CMD_PARSE GLOBAL PROPERTY NEO_SHARED_TESTS_CMD_PARSE)
|
||||
|
||||
list(APPEND neo_libult_common_SRCS_LIB_ULT
|
||||
${NEO_SHARED_TESTS_CMD_PARSE}
|
||||
)
|
||||
set_property(GLOBAL PROPERTY neo_libult_common_SRCS_LIB_ULT ${neo_libult_common_SRCS_LIB_ULT})
|
||||
|
||||
if(UNIX)
|
||||
list(APPEND neo_libult_common_SRCS_ENABLE_TESTED_HW ${neo_libult_common_SRCS_ENABLE_TESTED_HW_LINUX})
|
||||
endif()
|
||||
set_property(GLOBAL PROPERTY neo_libult_common_SRCS_ENABLE_TESTED_HW ${neo_libult_common_SRCS_ENABLE_TESTED_HW})
|
||||
|
||||
set_property(GLOBAL PROPERTY neo_libult_common_SRCS_ENABLE_TESTED_HW_LINUX ${neo_libult_common_SRCS_ENABLE_TESTED_HW_LINUX})
|
||||
|
||||
add_library(neo_libult_common OBJECT EXCLUDE_FROM_ALL
|
||||
${neo_libult_common_SRCS_LIB_ULT}
|
||||
@@ -129,27 +133,32 @@ add_library(neo_libult_common OBJECT EXCLUDE_FROM_ALL
|
||||
)
|
||||
|
||||
set(neo_libult_common_SRCS_LIB_ULT_WIN
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/fixtures/windows/memory_allocator_multi_device_fixture_windows.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/windows/ult_dxcore_factory.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/windows/ult_dxcore_factory.h
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/windows/ult_dxgi_factory.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/windows/ult_dxgi_factory.h
|
||||
)
|
||||
set_property(GLOBAL PROPERTY neo_libult_common_SRCS_LIB_ULT_WIN ${neo_libult_common_SRCS_LIB_ULT_WIN})
|
||||
|
||||
set(neo_libult_common_SRCS_LIB_ULT_LINUX
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/fixtures/linux/memory_allocator_multi_device_fixture_linux.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/linux/device_command_stream_fixture.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/linux/device_command_stream_fixture.h
|
||||
)
|
||||
set_property(GLOBAL PROPERTY neo_libult_common_SRCS_LIB_ULT_LINUX ${neo_libult_common_SRCS_LIB_ULT_LINUX})
|
||||
|
||||
if(UNIX AND NOT DISABLE_WDDM_LINUX)
|
||||
target_sources(neo_libult_common PRIVATE
|
||||
${NEO_SHARED_DIRECTORY}/os_interface/windows/wddm/wddm_create.cpp
|
||||
)
|
||||
endif()
|
||||
if(WIN32)
|
||||
target_sources(neo_libult_common PRIVATE ${neo_libult_common_SRCS_LIB_ULT_WIN})
|
||||
elseif(UNIX)
|
||||
target_sources(neo_libult_common PRIVATE ${neo_libult_common_SRCS_LIB_ULT_LINUX})
|
||||
target_sources(neo_libult_common PRIVATE ${neo_libult_common_SRCS_ENABLE_TESTED_HW_LINUX})
|
||||
endif()
|
||||
|
||||
if(UNIX AND NOT DISABLE_WDDM_LINUX)
|
||||
target_sources(neo_libult_common PRIVATE
|
||||
${NEO_SHARED_DIRECTORY}/os_interface/windows/wddm/wddm_create.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
set(neo_libult_SRCS_LINUX
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2021 Intel Corporation
|
||||
# Copyright (C) 2021-2022 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@@ -7,9 +7,12 @@
|
||||
if(TESTS_GEN12LP)
|
||||
add_subdirectories()
|
||||
|
||||
target_sources(neo_libult_common PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/special_ult_helper_gen12lp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/special_ult_helper_gen12lp.h
|
||||
set(neo_libult_common_SRCS_LIB_ULT_SPECIAL_HELPER
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/special_ult_helper_gen12lp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/special_ult_helper_gen12lp.h
|
||||
)
|
||||
|
||||
set_property(GLOBAL PROPERTY neo_libult_common_SRCS_LIB_ULT_SPECIAL_HELPER ${neo_libult_common_SRCS_LIB_ULT_SPECIAL_HELPER})
|
||||
target_sources(neo_libult_common PRIVATE ${neo_libult_common_SRCS_LIB_ULT_SPECIAL_HELPER})
|
||||
endif()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2020-2021 Intel Corporation
|
||||
# Copyright (C) 2020-2022 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@@ -95,6 +95,8 @@ if(WIN32)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_wddm_residency_allocations_container.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_wddm_residency_logger.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm_mock_helpers.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/windows/mock_gdi_interface.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/windows/mock_gdi_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/windows/mock_wddm_direct_submission.h
|
||||
)
|
||||
else()
|
||||
|
||||
13
shared/test/common/mocks/windows/mock_gdi_interface.cpp
Normal file
13
shared/test/common/mocks/windows/mock_gdi_interface.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/mocks/windows/mock_gdi_interface.h"
|
||||
|
||||
namespace NEO {
|
||||
UINT64 MockGdi::pagingFenceReturnValue = 0x3ull;
|
||||
LUID MockGdi::adapterLuidToReturn{};
|
||||
} // namespace NEO
|
||||
169
shared/test/common/mocks/windows/mock_gdi_interface.h
Normal file
169
shared/test/common/mocks/windows/mock_gdi_interface.h
Normal file
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/os_interface/windows/gdi_interface.h"
|
||||
#include "shared/test/common/mock_gdi/mock_gdi.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class MockGdi : public Gdi {
|
||||
public:
|
||||
MockGdi() {
|
||||
initialized = MockGdi::getAllProcAddresses();
|
||||
}
|
||||
~MockGdi(){};
|
||||
|
||||
static const D3DKMT_HANDLE adapterHandleForHdc = 0x1233;
|
||||
static UINT64 pagingFenceReturnValue;
|
||||
bool nonZeroNumBytesToTrim = false;
|
||||
static LUID adapterLuidToReturn;
|
||||
|
||||
void setNonZeroNumBytesToTrimInEvict() {
|
||||
nonZeroNumBytesToTrim = true;
|
||||
initialized = getAllProcAddresses();
|
||||
}
|
||||
|
||||
static NTSTATUS __stdcall makeResidentMock(IN OUT D3DDDI_MAKERESIDENT *arg) {
|
||||
if (arg->AllocationList[0] == INVALID_HANDLE) {
|
||||
return STATUS_SEVERITY_ERROR;
|
||||
}
|
||||
getMakeResidentArg() = *arg;
|
||||
arg->PagingFenceValue = pagingFenceReturnValue;
|
||||
return STATUS_PENDING;
|
||||
}
|
||||
|
||||
static NTSTATUS __stdcall evictMock(IN D3DKMT_EVICT *arg) {
|
||||
getEvictArg() = *arg;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static NTSTATUS __stdcall evictMockWithNonZeroTrim(IN D3DKMT_EVICT *arg) {
|
||||
getEvictArg() = *arg;
|
||||
arg->NumBytesToTrim = 4096;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static NTSTATUS __stdcall registerTrimNotificationMock(IN D3DKMT_REGISTERTRIMNOTIFICATION *arg) {
|
||||
getRegisterTrimNotificationArg() = *arg;
|
||||
arg->Handle = reinterpret_cast<VOID *>(1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static NTSTATUS __stdcall unregisterTrimNotificationMock(IN D3DKMT_UNREGISTERTRIMNOTIFICATION *arg) {
|
||||
getUnregisterTrimNotificationArg() = *arg;
|
||||
arg->Handle = reinterpret_cast<VOID *>(1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static NTSTATUS __stdcall destroyAllocation2Mock(IN D3DKMT_DESTROYALLOCATION2 *arg) {
|
||||
getDestroyArg() = *arg;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static NTSTATUS __stdcall waitFromCpuMock(IN CONST D3DKMT_WAITFORSYNCHRONIZATIONOBJECTFROMCPU *arg) {
|
||||
getWaitFromCpuArg() = *arg;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static NTSTATUS __stdcall createSynchronizationObject2Mock(IN OUT D3DKMT_CREATESYNCHRONIZATIONOBJECT2 *arg) {
|
||||
getCreateSynchronizationObject2Arg() = *arg;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static NTSTATUS __stdcall queryResourceInfoMock(IN OUT D3DKMT_QUERYRESOURCEINFO *arg) {
|
||||
getQueryResourceInfoArgIn() = *arg;
|
||||
arg->NumAllocations = getQueryResourceInfoArgOut().NumAllocations;
|
||||
arg->ResourcePrivateDriverDataSize = getQueryResourceInfoArgOut().ResourcePrivateDriverDataSize;
|
||||
arg->TotalPrivateDriverDataSize = getQueryResourceInfoArgOut().TotalPrivateDriverDataSize;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static NTSTATUS __stdcall openResourceMock(IN OUT D3DKMT_OPENRESOURCE *arg) {
|
||||
getOpenResourceArgIn() = *arg;
|
||||
if (arg->NumAllocations > 0) {
|
||||
arg->pOpenAllocationInfo[0].hAllocation = getOpenResourceArgOut().pOpenAllocationInfo->hAllocation;
|
||||
arg->pOpenAllocationInfo[0].PrivateDriverDataSize = getOpenResourceArgOut().pOpenAllocationInfo->PrivateDriverDataSize;
|
||||
arg->pOpenAllocationInfo[0].pPrivateDriverData = getOpenResourceArgOut().pOpenAllocationInfo->pPrivateDriverData;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool getAllProcAddresses() override {
|
||||
makeResident = reinterpret_cast<PFND3DKMT_MAKERESIDENT>(makeResidentMock);
|
||||
if (nonZeroNumBytesToTrim) {
|
||||
evict = reinterpret_cast<PFND3DKMT_EVICT>(evictMockWithNonZeroTrim);
|
||||
} else {
|
||||
evict = reinterpret_cast<PFND3DKMT_EVICT>(evictMock);
|
||||
}
|
||||
registerTrimNotification = reinterpret_cast<PFND3DKMT_REGISTERTRIMNOTIFICATION>(registerTrimNotificationMock);
|
||||
unregisterTrimNotification = reinterpret_cast<PFND3DKMT_UNREGISTERTRIMNOTIFICATION>(unregisterTrimNotificationMock);
|
||||
destroyAllocation2 = reinterpret_cast<PFND3DKMT_DESTROYALLOCATION2>(destroyAllocation2Mock);
|
||||
waitForSynchronizationObjectFromCpu = reinterpret_cast<PFND3DKMT_WAITFORSYNCHRONIZATIONOBJECTFROMCPU>(waitFromCpuMock);
|
||||
queryResourceInfo = reinterpret_cast<PFND3DKMT_QUERYRESOURCEINFO>(queryResourceInfoMock);
|
||||
openResource = reinterpret_cast<PFND3DKMT_OPENRESOURCE>(openResourceMock);
|
||||
return true;
|
||||
}
|
||||
|
||||
static D3DDDI_MAKERESIDENT &getMakeResidentArg() {
|
||||
static D3DDDI_MAKERESIDENT makeResidentArg;
|
||||
return makeResidentArg;
|
||||
}
|
||||
|
||||
static D3DKMT_EVICT &getEvictArg() {
|
||||
static D3DKMT_EVICT evictArg;
|
||||
return evictArg;
|
||||
}
|
||||
|
||||
static D3DKMT_REGISTERTRIMNOTIFICATION &getRegisterTrimNotificationArg() {
|
||||
static D3DKMT_REGISTERTRIMNOTIFICATION registerTrimArg;
|
||||
return registerTrimArg;
|
||||
}
|
||||
|
||||
static D3DKMT_UNREGISTERTRIMNOTIFICATION &getUnregisterTrimNotificationArg() {
|
||||
static D3DKMT_UNREGISTERTRIMNOTIFICATION unregisterTrimArg;
|
||||
return unregisterTrimArg;
|
||||
}
|
||||
|
||||
static D3DKMT_DESTROYALLOCATION2 &getDestroyArg() {
|
||||
static D3DKMT_DESTROYALLOCATION2 destroyArg;
|
||||
return destroyArg;
|
||||
}
|
||||
|
||||
static D3DKMT_WAITFORSYNCHRONIZATIONOBJECTFROMCPU &getWaitFromCpuArg() {
|
||||
static D3DKMT_WAITFORSYNCHRONIZATIONOBJECTFROMCPU waitFromCpu;
|
||||
return waitFromCpu;
|
||||
}
|
||||
|
||||
static D3DKMT_CREATESYNCHRONIZATIONOBJECT2 getCreateSynchronizationObject2Arg() {
|
||||
static D3DKMT_CREATESYNCHRONIZATIONOBJECT2 createSynchronizationObject2;
|
||||
return createSynchronizationObject2;
|
||||
}
|
||||
|
||||
static D3DKMT_QUERYRESOURCEINFO &getQueryResourceInfoArgIn() {
|
||||
static D3DKMT_QUERYRESOURCEINFO queryResourceInfo;
|
||||
return queryResourceInfo;
|
||||
}
|
||||
|
||||
static D3DKMT_QUERYRESOURCEINFO &getQueryResourceInfoArgOut() {
|
||||
static D3DKMT_QUERYRESOURCEINFO queryResourceInfo;
|
||||
return queryResourceInfo;
|
||||
}
|
||||
|
||||
static D3DKMT_OPENRESOURCE &getOpenResourceArgIn() {
|
||||
static D3DKMT_OPENRESOURCE openResource;
|
||||
return openResource;
|
||||
}
|
||||
|
||||
static D3DKMT_OPENRESOURCE &getOpenResourceArgOut() {
|
||||
static D3DKMT_OPENRESOURCE openResource;
|
||||
return openResource;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -24,10 +24,10 @@
|
||||
#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/mocks/windows/mock_gdi_interface.h"
|
||||
#include "shared/test/common/mocks/windows/mock_gmm_memory_base.h"
|
||||
#include "shared/test/common/os_interface/windows/gdi_dll_fixture.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
#include "shared/test/unit_test/os_interface/windows/mock_gdi_interface.h"
|
||||
|
||||
namespace NEO {
|
||||
struct WddmFixture : public Test<MockExecutionEnvironmentGmmFixture> {
|
||||
|
||||
Reference in New Issue
Block a user