/* * Copyright (C) 2018-2024 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 { void setUp() { const HardwareInfo *hwInfo = defaultHwInfo.get(); mockGdiDll.reset(setAdapterInfo(&hwInfo->platform, &hwInfo->gtSystemInfo, hwInfo->capabilityTable.gpuAddressSpace)); setSizesFcn = reinterpret_cast(mockGdiDll->getProcAddress("setMockSizes")); getSizesFcn = reinterpret_cast(mockGdiDll->getProcAddress("getMockSizes")); getMockLastDestroyedResHandleFcn = reinterpret_cast(mockGdiDll->getProcAddress("getMockLastDestroyedResHandle")); setMockLastDestroyedResHandleFcn = reinterpret_cast(mockGdiDll->getProcAddress("setMockLastDestroyedResHandle")); getMockCreateDeviceParamsFcn = reinterpret_cast(mockGdiDll->getProcAddress("getMockCreateDeviceParams")); setMockCreateDeviceParamsFcn = reinterpret_cast(mockGdiDll->getProcAddress("setMockCreateDeviceParams")); getMockAllocationFcn = reinterpret_cast(mockGdiDll->getProcAddress("getMockAllocation")); getAdapterInfoAddressFcn = reinterpret_cast(mockGdiDll->getProcAddress("getAdapterInfoAddress")); getLastCallMapGpuVaArgFcn = reinterpret_cast(mockGdiDll->getProcAddress("getLastCallMapGpuVaArg")); getLastCallReserveGpuVaArgFcn = reinterpret_cast(mockGdiDll->getProcAddress("getLastCallReserveGpuVaArg")); setMapGpuVaFailConfigFcn = reinterpret_cast(mockGdiDll->getProcAddress("setMapGpuVaFailConfig")); setMapGpuVaFailConfigFcn(0, 0); getCreateContextDataFcn = reinterpret_cast(mockGdiDll->getProcAddress("getCreateContextData")); getCreateHwQueueDataFcn = reinterpret_cast(mockGdiDll->getProcAddress("getCreateHwQueueData")); getDestroyHwQueueDataFcn = reinterpret_cast(mockGdiDll->getProcAddress("getDestroyHwQueueData")); getSubmitCommandToHwQueueDataFcn = reinterpret_cast(mockGdiDll->getProcAddress("getSubmitCommandToHwQueueData")); getDestroySynchronizationObjectDataFcn = reinterpret_cast(mockGdiDll->getProcAddress("getDestroySynchronizationObjectData")); getMonitorFenceCpuFenceAddressFcn = reinterpret_cast(mockGdiDll->getProcAddress("getMonitorFenceCpuFenceAddress")); getMonitorFenceCpuAddressSelectorFcn = reinterpret_cast(mockGdiDll->getProcAddress("getMonitorFenceCpuAddressSelector")); getCreateSynchronizationObject2FailCallFcn = reinterpret_cast(mockGdiDll->getProcAddress("getCreateSynchronizationObject2FailCall")); getFailOnSetContextSchedulingPriorityCallFcn = reinterpret_cast(mockGdiDll->getProcAddress("getFailOnSetContextSchedulingPriorityCall")); getSetContextSchedulingPriorityDataCallFcn = reinterpret_cast(mockGdiDll->getProcAddress("getSetContextSchedulingPriorityDataCall")); getRegisterTrimNotificationFailCallFcn = reinterpret_cast(mockGdiDll->getProcAddress("getRegisterTrimNotificationFailCall")); getLastPriorityFcn = reinterpret_cast(mockGdiDll->getProcAddress("getLastPriority")); setAdapterBDFFcn = reinterpret_cast(mockGdiDll->getProcAddress("setAdapterBDF")); setMockDeviceExecutionStateFcn = reinterpret_cast(mockGdiDll->getProcAddress("setMockDeviceExecutionState")); setMockGetDeviceStateReturnValueFcn = reinterpret_cast(mockGdiDll->getProcAddress("setMockGetDeviceStateReturnValue")); getCreateAllocation2ReadOnlyFailConfigFcn = reinterpret_cast(mockGdiDll->getProcAddress("getCreateAllocation2ReadOnlyFailConfig")); setCreateAllocation2ReadOnlyFailConfigFcn = reinterpret_cast(mockGdiDll->getProcAddress("setCreateAllocation2ReadOnlyFailConfig")); setMockLastDestroyedResHandleFcn((D3DKMT_HANDLE)0); *getDestroySynchronizationObjectDataFcn() = {}; *getCreateSynchronizationObject2FailCallFcn() = false; *getFailOnSetContextSchedulingPriorityCallFcn() = false; *getSetContextSchedulingPriorityDataCallFcn() = {}; *getRegisterTrimNotificationFailCallFcn() = false; } void tearDown() { *getCreateHwQueueDataFcn() = {}; *getDestroyHwQueueDataFcn() = {}; *getSubmitCommandToHwQueueDataFcn() = {}; *getDestroySynchronizationObjectDataFcn() = {}; setMapGpuVaFailConfigFcn(0, 0); *getCreateSynchronizationObject2FailCallFcn() = false; *getFailOnSetContextSchedulingPriorityCallFcn() = false; *getSetContextSchedulingPriorityDataCallFcn() = {}; *getRegisterTrimNotificationFailCallFcn() = false; } std::unique_ptr mockGdiDll; decltype(&setMockSizes) 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(&getMonitorFenceCpuAddressSelector) getMonitorFenceCpuAddressSelectorFcn = nullptr; decltype(&getCreateSynchronizationObject2FailCall) getCreateSynchronizationObject2FailCallFcn = nullptr; decltype(&getFailOnSetContextSchedulingPriorityCall) getFailOnSetContextSchedulingPriorityCallFcn = nullptr; decltype(&getSetContextSchedulingPriorityDataCall) getSetContextSchedulingPriorityDataCallFcn = nullptr; decltype(&getRegisterTrimNotificationFailCall) getRegisterTrimNotificationFailCallFcn = nullptr; decltype(&getLastPriority) getLastPriorityFcn = nullptr; decltype(&setAdapterBDF) setAdapterBDFFcn = nullptr; decltype(&setMockDeviceExecutionState) setMockDeviceExecutionStateFcn = nullptr; decltype(&setMockGetDeviceStateReturnValue) setMockGetDeviceStateReturnValueFcn = nullptr; decltype(&getCreateAllocation2ReadOnlyFailConfig) getCreateAllocation2ReadOnlyFailConfigFcn = nullptr; decltype(&setCreateAllocation2ReadOnlyFailConfig) setCreateAllocation2ReadOnlyFailConfigFcn = nullptr; };