diff --git a/CMakeLists.txt b/CMakeLists.txt index cc78809f37..7cb52916f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -240,8 +240,27 @@ if(NOT GMMUMD_LIB_NAME) endif() endif() endif() +get_target_property(target_type ${GMMUMD_LIB_NAME} TYPE) + +if(target_type STREQUAL "STATIC_LIBRARY") + set(USE_STATIC_GMM TRUE) +endif() + set(UMKM_SHAREDDATA_INCLUDE_PATHS $) +set(GMM_LIB_FILENAME "igdgmm${NEO_BITS}${CMAKE_SHARED_LIBRARY_SUFFIX}") + +macro(copy_gmm_dll_for target) + if(WIN32 AND NOT USE_STATIC_GMM) + add_dependencies(${target} ${GMMUMD_LIB_NAME}) + add_custom_command( + TARGET ${target} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ + ) + endif() +endmacro() + # Instrumentation detection if(NOT INSTRUMENTATION_LIB_NAME) if(INSTRUMENTATION_SOURCE_DIR) @@ -534,3 +553,4 @@ include(package.cmake) configure_file(config.h.in ${IGDRCL_BUILD_DIR}/config.h) configure_file(compiler.config.h.in ${IGDRCL_BUILD_DIR}/compiler.config.h) configure_file(driver_version.h.in ${IGDRCL_BUILD_DIR}/driver_version.h) # Put Driver version into define +configure_file(lib_names.h.in ${IGDRCL_BUILD_DIR}/lib_names.h) diff --git a/lib_names.h.in b/lib_names.h.in new file mode 100644 index 0000000000..a267c03d98 --- /dev/null +++ b/lib_names.h.in @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2018, Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef LIB_NAMES_H +#define LIB_NAMES_H + +#cmakedefine GMM_LIB_FILENAME "${GMM_LIB_FILENAME}" + +#endif /* LIB_NAMES_H */ diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 4fead95b52..08e867d745 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -100,7 +100,11 @@ target_compile_definitions(${NEO_STATIC_LIB_NAME} PUBLIC DEFAULT_PLATFORM=${DEFA link_directories(${GMM_LIB_PATHS}) -target_link_libraries(${NEO_STATIC_LIB_NAME} ${GMMUMD_LIB_NAME}) +if(UNIX OR USE_STATIC_GMM) + target_link_libraries(${NEO_STATIC_LIB_NAME} ${GMMUMD_LIB_NAME}) +else() + target_compile_definitions(${NEO_STATIC_LIB_NAME} PUBLIC GMM_LIB_DLL) +endif() if(INSTRUMENTATION_LIB_NAME) add_dependencies(${NEO_STATIC_LIB_NAME} ${INSTRUMENTATION_LIB_NAME}) @@ -134,6 +138,7 @@ if(${GENERATE_EXECUTABLE}) add_library(${NEO_DYNAMIC_LIB_NAME} SHARED ${NEO_DYNAMIC_LIB__TARGET_OBJECTS} ) + add_dependencies(${NEO_DYNAMIC_LIB_NAME} ${GMMUMD_LIB_NAME}) if(GTPIN_HEADERS_DIR) macro(macro_for_each_gen) diff --git a/runtime/dll/windows/options.cpp b/runtime/dll/windows/options.cpp index 63ad28be4c..d6acd02387 100644 --- a/runtime/dll/windows/options.cpp +++ b/runtime/dll/windows/options.cpp @@ -19,6 +19,7 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ +#include "lib_names.h" namespace Os { #if defined(_WIN64) @@ -30,4 +31,5 @@ const char *igcDllName = "igc32.dll"; #endif const char *gdiDllName = "gdi32.dll"; +const char *gmmDllName = GMM_LIB_FILENAME; } // namespace Os diff --git a/runtime/gmm_helper/gmm_helper.cpp b/runtime/gmm_helper/gmm_helper.cpp index 3623c08931..7a126b490c 100644 --- a/runtime/gmm_helper/gmm_helper.cpp +++ b/runtime/gmm_helper/gmm_helper.cpp @@ -31,28 +31,6 @@ #include "runtime/helpers/hw_info.h" #include "runtime/sku_info/operations/sku_info_transfer.h" -extern "C" { - -void GMMDebugBreak(const char *file, const char *function, const int line) { -} - -void GMMPrintMessage(uint32_t debugLevel, const char *debugMessageFmt, ...) { -} - -typedef struct GfxDebugControlRec { - uint32_t Version; - uint32_t Size; - uint32_t AssertEnableMask; - uint32_t EnableDebugFileDump; - uint32_t DebugEnableMask; - uint32_t RingBufDbgMask; - uint32_t ReportAssertEnable; - uint32_t AssertBreakDisable; - -} GFX_DEBUG_CONTROL, *PGFX_DEBUG_CONTROL; -PGFX_DEBUG_CONTROL pDebugControl; -} - namespace OCLRT { void Gmm::create() { if (resourceParams.BaseWidth >= maxPossiblePitch) { @@ -71,19 +49,21 @@ bool Gmm::initContext(const PLATFORM *pPlatform, _WA_TABLE gmmWaTable = {}; SkuInfoTransfer::transferFtrTableForGmm(&gmmFtrTable, pSkuTable); SkuInfoTransfer::transferWaTableForGmm(&gmmWaTable, pWaTable); - - bool success = GMM_SUCCESS == GmmInitGlobalContext(*pPlatform, &gmmFtrTable, &gmmWaTable, pGtSysInfo, GMM_CLIENT::GMM_OCL_VISTA); + if (!isLoaded) { + loadLib(); + } + bool success = GMM_SUCCESS == initGlobalContextFunc(*pPlatform, &gmmFtrTable, &gmmWaTable, pGtSysInfo, GMM_CLIENT::GMM_OCL_VISTA); UNRECOVERABLE_IF(!success); - Gmm::gmmClientContext = GmmCreateClientContext(GMM_CLIENT::GMM_OCL_VISTA); + Gmm::gmmClientContext = createClientContextFunc(GMM_CLIENT::GMM_OCL_VISTA); } return Gmm::gmmClientContext != nullptr; } void Gmm::destroyContext() { if (Gmm::gmmClientContext) { - GmmDeleteClientContext(Gmm::gmmClientContext); + deleteClientContextFunc(Gmm::gmmClientContext); Gmm::gmmClientContext = nullptr; - GmmDestroyGlobalContext(); + destroyGlobalContextFunc(); } } @@ -414,5 +394,6 @@ bool Gmm::unifiedAuxTranslationCapable() const { bool Gmm::useSimplifiedMocsTable = false; GMM_CLIENT_CONTEXT *Gmm::gmmClientContext = nullptr; +bool Gmm::isLoaded = false; } // namespace OCLRT diff --git a/runtime/gmm_helper/gmm_helper.h b/runtime/gmm_helper/gmm_helper.h index 191ebc61c5..ea520f23ac 100644 --- a/runtime/gmm_helper/gmm_helper.h +++ b/runtime/gmm_helper/gmm_helper.h @@ -27,12 +27,6 @@ #include "runtime/gmm_helper/gmm_lib.h" #include "runtime/api/cl_types.h" -extern "C" { -void GMMDebugBreak(const char *file, const char *function, const int line); - -void GMMPrintMessage(uint32_t debugLevel, const char *debugMessageFmt, ...); -} - namespace OCLRT { struct HardwareInfo; struct FeatureTable; @@ -63,6 +57,7 @@ class Gmm { static Gmm *create(GMM_RESOURCE_INFO *inputGmm); static bool initContext(const PLATFORM *pPlatform, const FeatureTable *pSkuTable, const WorkaroundTable *pWaTable, const GT_SYSTEM_INFO *pGtSysInfo); + static void loadLib(); static void destroyContext(); static uint32_t getMOCS(uint32_t type); @@ -97,8 +92,14 @@ class Gmm { GMM_RESCREATE_PARAMS resourceParams = {}; std::unique_ptr gmmResourceInfo; + static decltype(&GmmInitGlobalContext) initGlobalContextFunc; + static decltype(&GmmDestroyGlobalContext) destroyGlobalContextFunc; + static decltype(&GmmCreateClientContext) createClientContextFunc; + static decltype(&GmmDeleteClientContext) deleteClientContextFunc; + bool isRenderCompressed = false; static bool useSimplifiedMocsTable; static GMM_CLIENT_CONTEXT *gmmClientContext; + static bool isLoaded; }; } // namespace OCLRT diff --git a/runtime/gmm_helper/gmm_memory_base.cpp b/runtime/gmm_helper/gmm_memory_base.cpp index 0ed17f6586..8dffff562a 100644 --- a/runtime/gmm_helper/gmm_memory_base.cpp +++ b/runtime/gmm_helper/gmm_memory_base.cpp @@ -46,7 +46,7 @@ bool GmmMemoryBase::configureDeviceAddressSpace(GMM_ESCAPE_HANDLE hAdapter, } uintptr_t GmmMemoryBase::getInternalGpuVaRangeLimit() { - return static_cast(pGmmGlobalContext->GetInternalGpuVaRangeLimit()); + return static_cast(Gmm::gmmClientContext->GetInternalGpuVaRangeLimit()); } }; // namespace OCLRT diff --git a/runtime/gmm_helper/page_table_mngr.cpp b/runtime/gmm_helper/page_table_mngr.cpp index c40fbbb8c6..ec970a0f40 100644 --- a/runtime/gmm_helper/page_table_mngr.cpp +++ b/runtime/gmm_helper/page_table_mngr.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2017, Intel Corporation +* Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -24,7 +24,7 @@ #include "runtime/gmm_helper/page_table_mngr.h" namespace OCLRT { -GmmPageTableMngr *GmmPageTableMngr::create(GMM_DEVICE_CALLBACKS *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb) { +GmmPageTableMngr *GmmPageTableMngr::create(GMM_DEVICE_CALLBACKS_INT *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb) { return new GmmPageTableMngr(deviceCb, translationTableFlags, translationTableCb); } diff --git a/runtime/gmm_helper/page_table_mngr.h b/runtime/gmm_helper/page_table_mngr.h index 6a0fe3425a..28822da01c 100644 --- a/runtime/gmm_helper/page_table_mngr.h +++ b/runtime/gmm_helper/page_table_mngr.h @@ -30,7 +30,7 @@ class GmmPageTableMngr { public: MOCKABLE_VIRTUAL ~GmmPageTableMngr() = default; - static GmmPageTableMngr *create(GMM_DEVICE_CALLBACKS *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb); + static GmmPageTableMngr *create(GMM_DEVICE_CALLBACKS_INT *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb); MOCKABLE_VIRTUAL GMM_STATUS initContextAuxTableRegister(HANDLE initialBBHandle, GMM_ENGINE_TYPE engineType) { return pageTableManager->InitContextAuxTableRegister(initialBBHandle, engineType); @@ -50,7 +50,7 @@ class GmmPageTableMngr { GmmPageTableMngr() = default; - GmmPageTableMngr(GMM_DEVICE_CALLBACKS *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb); + GmmPageTableMngr(GMM_DEVICE_CALLBACKS_INT *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb); UniquePtrType pageTableManager; }; diff --git a/runtime/gmm_helper/page_table_mngr_impl.cpp b/runtime/gmm_helper/page_table_mngr_impl.cpp index a6f7316804..134d8c2964 100644 --- a/runtime/gmm_helper/page_table_mngr_impl.cpp +++ b/runtime/gmm_helper/page_table_mngr_impl.cpp @@ -28,7 +28,7 @@ void GmmPageTableMngr::customDeleter(GMM_PAGETABLE_MGR *gmmPageTableManager) { Gmm::gmmClientContext->DestroyPageTblMgrObject(gmmPageTableManager); } -GmmPageTableMngr::GmmPageTableMngr(GMM_DEVICE_CALLBACKS *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb) { +GmmPageTableMngr::GmmPageTableMngr(GMM_DEVICE_CALLBACKS_INT *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb) { auto pageTableMngrPtr = Gmm::gmmClientContext->CreatePageTblMgrObject(deviceCb, translationTableCb, translationTableFlags); this->pageTableManager = UniquePtrType(pageTableMngrPtr, GmmPageTableMngr::customDeleter); } diff --git a/runtime/os_interface/linux/CMakeLists.txt b/runtime/os_interface/linux/CMakeLists.txt index 27874daa39..ae730909b5 100644 --- a/runtime/os_interface/linux/CMakeLists.txt +++ b/runtime/os_interface/linux/CMakeLists.txt @@ -43,6 +43,7 @@ set(RUNTIME_SRCS_OS_INTERFACE_LINUX ${CMAKE_CURRENT_SOURCE_DIR}/drm_neo.h ${CMAKE_CURRENT_SOURCE_DIR}/drm_neo_create.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_null_device.h + ${CMAKE_CURRENT_SOURCE_DIR}/gmm_interface_linux.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config.cpp ${CMAKE_CURRENT_SOURCE_DIR}/linux_inc.cpp ${CMAKE_CURRENT_SOURCE_DIR}/os_thread_linux.cpp diff --git a/runtime/os_interface/linux/gmm_interface_linux.cpp b/runtime/os_interface/linux/gmm_interface_linux.cpp new file mode 100644 index 0000000000..199b660e72 --- /dev/null +++ b/runtime/os_interface/linux/gmm_interface_linux.cpp @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018, Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "runtime/gmm_helper/gmm_helper.h" + +namespace OCLRT { + +decltype(Gmm::initGlobalContextFunc) Gmm::initGlobalContextFunc = nullptr; +decltype(Gmm::destroyGlobalContextFunc) Gmm::destroyGlobalContextFunc = nullptr; +decltype(Gmm::createClientContextFunc) Gmm::createClientContextFunc = nullptr; +decltype(Gmm::deleteClientContextFunc) Gmm::deleteClientContextFunc = nullptr; + +void Gmm::loadLib() { + Gmm::initGlobalContextFunc = GmmInitGlobalContext; + Gmm::destroyGlobalContextFunc = GmmDestroyGlobalContext; + Gmm::createClientContextFunc = GmmCreateClientContext; + Gmm::deleteClientContextFunc = GmmDeleteClientContext; + isLoaded = true; +} +} diff --git a/runtime/os_interface/windows/CMakeLists.txt b/runtime/os_interface/windows/CMakeLists.txt index 39c9515bb9..8bcbb019de 100644 --- a/runtime/os_interface/windows/CMakeLists.txt +++ b/runtime/os_interface/windows/CMakeLists.txt @@ -24,6 +24,13 @@ else() set(KMDAF_FILE_SUFFIX "_stub") endif() +if(USE_STATIC_GMM) + set(GMM_INTERFACE_FILE_WINDOWS ${CMAKE_CURRENT_SOURCE_DIR}/gmm_interface_static_win.cpp) +else() + set(GMM_INTERFACE_FILE_WINDOWS ${CMAKE_CURRENT_SOURCE_DIR}/gmm_interface_dynamic_win.cpp) +endif() +set_property(GLOBAL PROPERTY GMM_INTERFACE_FILE_WINDOWS ${GMM_INTERFACE_FILE_WINDOWS}) + set(RUNTIME_SRCS_OS_INTERFACE_WINDOWS ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/api_win.cpp @@ -39,6 +46,7 @@ set(RUNTIME_SRCS_OS_INTERFACE_WINDOWS ${CMAKE_CURRENT_SOURCE_DIR}/driver_info.h ${CMAKE_CURRENT_SOURCE_DIR}/gdi_interface.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gdi_interface.h + ${GMM_INTERFACE_FILE_WINDOWS} ${CMAKE_CURRENT_SOURCE_DIR}/kmdaf_listener${KMDAF_FILE_SUFFIX}.cpp ${CMAKE_CURRENT_SOURCE_DIR}/kmdaf_listener.h ${CMAKE_CURRENT_SOURCE_DIR}/os_inc.h diff --git a/runtime/os_interface/windows/gdi_interface.h b/runtime/os_interface/windows/gdi_interface.h index c4c8d31730..eb59623dcc 100644 --- a/runtime/os_interface/windows/gdi_interface.h +++ b/runtime/os_interface/windows/gdi_interface.h @@ -99,7 +99,5 @@ class Gdi { private: OCLRT::Windows::OsLibrary gdiDll; - static const std::string gdiDllName; - static const std::string gdiMockDllName; }; } // namespace OCLRT diff --git a/runtime/os_interface/windows/gmm_interface_dynamic_win.cpp b/runtime/os_interface/windows/gmm_interface_dynamic_win.cpp new file mode 100644 index 0000000000..8e991e2517 --- /dev/null +++ b/runtime/os_interface/windows/gmm_interface_dynamic_win.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2018, Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "runtime/gmm_helper/gmm_helper.h" +#include "runtime/helpers/debug_helpers.h" +#include "runtime/os_interface/os_library.h" + +namespace Os { +extern const char *gmmDllName; +} + +namespace OCLRT { +GMM_STATUS(GMM_STDCALL *myPfnCreateSingletonContext) +(const PLATFORM Platform, const SKU_FEATURE_TABLE *pSkuTable, const WA_TABLE *pWaTable, const GT_SYSTEM_INFO *pGtSysInfo); +GMM_STATUS GMM_STDCALL myGmmInitGlobalContext(const PLATFORM Platform, const SKU_FEATURE_TABLE *pSkuTable, const WA_TABLE *pWaTable, const GT_SYSTEM_INFO *pGtSysInfo, GMM_CLIENT ClientType) { + return myPfnCreateSingletonContext(Platform, pSkuTable, pWaTable, pGtSysInfo); +} +decltype(Gmm::initGlobalContextFunc) Gmm::initGlobalContextFunc = &myGmmInitGlobalContext; +decltype(Gmm::destroyGlobalContextFunc) Gmm::destroyGlobalContextFunc = nullptr; +decltype(Gmm::createClientContextFunc) Gmm::createClientContextFunc = nullptr; +decltype(Gmm::deleteClientContextFunc) Gmm::deleteClientContextFunc = nullptr; + +std::unique_ptr gmmLib; +void Gmm::loadLib() { + gmmLib.reset(OsLibrary::load(Os::gmmDllName)); + + UNRECOVERABLE_IF(!gmmLib); + if (gmmLib->isLoaded()) { + auto openGmmFunc = reinterpret_cast(gmmLib->getProcAddress(GMM_ENTRY_NAME)); + GmmExportEntries entries; + auto status = openGmmFunc(&entries); + if (status == GMM_SUCCESS) { + myPfnCreateSingletonContext = entries.pfnCreateSingletonContext; + Gmm::destroyGlobalContextFunc = entries.pfnDestroySingletonContext; + Gmm::createClientContextFunc = entries.pfnCreateClientContext; + Gmm::deleteClientContextFunc = entries.pfnDeleteClientContext; + isLoaded = myPfnCreateSingletonContext && Gmm::destroyGlobalContextFunc && Gmm::createClientContextFunc && Gmm::deleteClientContextFunc; + } + } + UNRECOVERABLE_IF(!isLoaded); +} +} diff --git a/runtime/os_interface/windows/gmm_interface_static_win.cpp b/runtime/os_interface/windows/gmm_interface_static_win.cpp new file mode 100644 index 0000000000..82688f3447 --- /dev/null +++ b/runtime/os_interface/windows/gmm_interface_static_win.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2018, Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "runtime/gmm_helper/gmm_helper.h" + +namespace OCLRT { + +decltype(Gmm::initGlobalContextFunc) Gmm::initGlobalContextFunc = nullptr; +decltype(Gmm::destroyGlobalContextFunc) Gmm::destroyGlobalContextFunc = nullptr; +decltype(Gmm::createClientContextFunc) Gmm::createClientContextFunc = nullptr; +decltype(Gmm::deleteClientContextFunc) Gmm::deleteClientContextFunc = nullptr; + +void Gmm::loadLib() { + Gmm::initGlobalContextFunc = GmmInitGlobalContext; + Gmm::destroyGlobalContextFunc = GmmDestroyGlobalContext; + Gmm::createClientContextFunc = GmmCreateClientContext; + Gmm::deleteClientContextFunc = GmmDeleteClientContext; + isLoaded = true; +} +} +extern "C" { +void GMMDebugBreak(const char *file, const char *function, const int line) { +} + +void GMMPrintMessage(uint32_t debugLevel, const char *debugMessageFmt, ...) { +} +typedef struct GfxDebugControlRec { + uint32_t Version; + uint32_t Size; + uint32_t AssertEnableMask; + uint32_t EnableDebugFileDump; + uint32_t DebugEnableMask; + uint32_t RingBufDbgMask; + uint32_t ReportAssertEnable; + uint32_t AssertBreakDisable; + +} GFX_DEBUG_CONTROL, *PGFX_DEBUG_CONTROL; +PGFX_DEBUG_CONTROL pDebugControl; +} diff --git a/runtime/os_interface/windows/os_inc.h b/runtime/os_interface/windows/os_inc.h index 164336015e..f6c851a957 100644 --- a/runtime/os_interface/windows/os_inc.h +++ b/runtime/os_interface/windows/os_inc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), diff --git a/runtime/os_interface/windows/wddm_device_command_stream.inl b/runtime/os_interface/windows/wddm_device_command_stream.inl index 34c5db790c..2ea3aa5170 100644 --- a/runtime/os_interface/windows/wddm_device_command_stream.inl +++ b/runtime/os_interface/windows/wddm_device_command_stream.inl @@ -176,27 +176,27 @@ bool WddmCommandStreamReceiver::waitForFlushStamp(FlushStamp &flushSt template GmmPageTableMngr *WddmCommandStreamReceiver::createPageTableManager() { - GMM_DEVICE_CALLBACKS deviceCallbacks = {}; + GMM_DEVICE_CALLBACKS_INT deviceCallbacks = {}; GMM_TRANSLATIONTABLE_CALLBACKS ttCallbacks = {}; auto gdi = wddm->getGdi(); // clang-format off - deviceCallbacks.Adapter = wddm->getAdapter(); - deviceCallbacks.hDevice = wddm->getDevice(); + deviceCallbacks.Adapter.KmtHandle = wddm->getAdapter(); + deviceCallbacks.hDevice.KmtHandle = wddm->getDevice(); deviceCallbacks.PagingQueue = wddm->getPagingQueue(); deviceCallbacks.PagingFence = wddm->getPagingQueueSyncObject(); - deviceCallbacks.pfnAllocate = gdi->createAllocation; - deviceCallbacks.pfnDeallocate = gdi->destroyAllocation; - deviceCallbacks.pfnMapGPUVA = gdi->mapGpuVirtualAddress; - deviceCallbacks.pfnMakeResident = gdi->makeResident; - deviceCallbacks.pfnEvict = gdi->evict; - deviceCallbacks.pfnReserveGPUVA = gdi->reserveGpuVirtualAddress; - deviceCallbacks.pfnUpdateGPUVA = gdi->updateGpuVirtualAddress; - deviceCallbacks.pfnWaitFromCpu = gdi->waitForSynchronizationObjectFromCpu; - deviceCallbacks.pfnLock = gdi->lock2; - deviceCallbacks.pfnUnLock = gdi->unlock2; - deviceCallbacks.pfnEscape = gdi->escape; + deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnAllocate = gdi->createAllocation; + deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnDeallocate = gdi->destroyAllocation; + deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnMapGPUVA = gdi->mapGpuVirtualAddress; + deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnMakeResident = gdi->makeResident; + deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnEvict = gdi->evict; + deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnReserveGPUVA = gdi->reserveGpuVirtualAddress; + deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnUpdateGPUVA = gdi->updateGpuVirtualAddress; + deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnWaitFromCpu = gdi->waitForSynchronizationObjectFromCpu; + deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnLock = gdi->lock2; + deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnUnLock = gdi->unlock2; + deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnEscape = gdi->escape; ttCallbacks.pfWriteL3Adr = TTCallbacks::writeL3Address; // clang-format on diff --git a/unit_tests/aub_tests/CMakeLists.txt b/unit_tests/aub_tests/CMakeLists.txt index b313abd8d0..b6d9517cfe 100644 --- a/unit_tests/aub_tests/CMakeLists.txt +++ b/unit_tests/aub_tests/CMakeLists.txt @@ -53,6 +53,7 @@ if(WIN32) ) endif() +copy_gmm_dll_for(igdrcl_aub_tests) add_subdirectories() target_link_libraries(igdrcl_aub_tests igdrcl_mocks) diff --git a/unit_tests/aub_tests/aub_tests_configuration.cpp b/unit_tests/aub_tests/aub_tests_configuration.cpp index 0520af0ace..d8af236f75 100644 --- a/unit_tests/aub_tests/aub_tests_configuration.cpp +++ b/unit_tests/aub_tests/aub_tests_configuration.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -23,4 +23,5 @@ namespace OCLRT { // max time per single test iteration unsigned int ultIterationMaxTime = 180; +bool useMockGmm = false; } diff --git a/unit_tests/gmm_helper/gmm_helper_tests.cpp b/unit_tests/gmm_helper/gmm_helper_tests.cpp index 554f15ebf5..52aa071052 100644 --- a/unit_tests/gmm_helper/gmm_helper_tests.cpp +++ b/unit_tests/gmm_helper/gmm_helper_tests.cpp @@ -34,12 +34,6 @@ using namespace ::testing; namespace OCLRT { class GmmTests : public ::testing::Test { - public: - void SetUp() override { - // empty calls - GMMDebugBreak(nullptr, nullptr, 0); - GMMPrintMessage(0, nullptr); - } }; TEST_F(GmmTests, resourceCreation) { diff --git a/unit_tests/main.cpp b/unit_tests/main.cpp index f8f26607f1..89f418c2e6 100644 --- a/unit_tests/main.cpp +++ b/unit_tests/main.cpp @@ -31,6 +31,7 @@ #include "unit_tests/mocks/mock_sip.h" #include "runtime/gmm_helper/resource_info.h" #include "runtime/os_interface/debug_settings_manager.h" +#include "lib_names.h" #include "gmock/gmock.h" #include #include @@ -51,9 +52,13 @@ extern const char *hardwarePrefix[]; extern const HardwareInfo *hardwareInfoTable[IGFX_MAX_PRODUCT]; extern const unsigned int ultIterationMaxTime; +extern bool useMockGmm; std::thread::id tempThreadID; } // namespace OCLRT +namespace Os { +extern const char *gmmDllName; +} using namespace OCLRT; TestEnvironment *gEnvironment; @@ -403,6 +408,9 @@ int main(int argc, char **argv) { } #else SetUnhandledExceptionFilter(&UltExceptionFilter); + if (!useMockGmm) { + Os::gmmDllName = GMM_LIB_FILENAME; + } #endif initializeTestHelpers(); diff --git a/unit_tests/mock_gmm/CMakeLists.txt b/unit_tests/mock_gmm/CMakeLists.txt new file mode 100644 index 0000000000..71a47bf0df --- /dev/null +++ b/unit_tests/mock_gmm/CMakeLists.txt @@ -0,0 +1,51 @@ +# Copyright (c) 2018, Intel Corporation +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. + +if(WIN32) + set(target_name mock_gmm) + project(${target_name}) + + # Setting up our local list of test files + set(IGDRCL_SRCS_tests_mock_gmm + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm.h + ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/init_platform.cpp + ) + add_library(${target_name} SHARED ${IGDRCL_SRCS_tests_mock_gmm}) + + target_include_directories(${target_name} PRIVATE + ${WDK_INCLUDE_PATHS} + ${UMKM_SHAREDDATA_INCLUDE_PATHS} + ) + + set_target_properties( + ${target_name} + PROPERTIES DEBUG_OUTPUT_NAME ${target_name} + RELEASE_OUTPUT_NAME ${target_name} + RELEASEINTERNAL_OUTPUT_NAME ${target_name} + OUTPUT_NAME ${target_name} + ) + + create_project_source_tree(${target_name}) + set_target_properties(${target_name} PROPERTIES FOLDER "test mocks") + target_compile_definitions(${target_name} PUBLIC GMM_LIB_DLL GMM_LIB_DLL_EXPORTS) + add_dependencies(unit_tests ${target_name}) +endif() diff --git a/unit_tests/mock_gmm/init_platform.cpp b/unit_tests/mock_gmm/init_platform.cpp new file mode 100644 index 0000000000..e3d63fb077 --- /dev/null +++ b/unit_tests/mock_gmm/init_platform.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2018, Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "mock_gmm.h" + +void initPlatform(GMM_PLATFORM_INFO *platform) {} diff --git a/unit_tests/mock_gmm/mock_gmm.cpp b/unit_tests/mock_gmm/mock_gmm.cpp new file mode 100644 index 0000000000..9ca2e39b58 --- /dev/null +++ b/unit_tests/mock_gmm/mock_gmm.cpp @@ -0,0 +1,620 @@ +/* + * Copyright (c) 2018, Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "mock_gmm.h" + +GMM_GLOBAL_CONTEXT *pGmmGlobalContext; +GMM_PLATFORM_INFO *pGlobalPlatformInfo = nullptr; + +GMM_CLIENT_CONTEXT *GMM_STDCALL createClientContext(GMM_CLIENT ClientType) { + return new GMM_CLIENT_CONTEXT(ClientType); +} +void GMM_STDCALL deleteClientContext(GMM_CLIENT_CONTEXT *pGmmClientContext) { + delete pGmmClientContext; +} +void GMM_STDCALL destroySingletonContext(void) { + delete pGlobalPlatformInfo; +} +GMM_STATUS GMM_STDCALL createSingletonContext(const PLATFORM Platform, + const SKU_FEATURE_TABLE *pSkuTable, + const WA_TABLE *pWaTable, + const GT_SYSTEM_INFO *pGtSysInfo) { + pGlobalPlatformInfo = new GMM_PLATFORM_INFO; + initPlatform(pGlobalPlatformInfo); + return GMM_SUCCESS; +} +GMM_STATUS GMM_STDCALL OpenGmm(GmmExportEntries *pm_GmmFuncs) { + pm_GmmFuncs->pfnCreateClientContext = &createClientContext; + pm_GmmFuncs->pfnCreateSingletonContext = &createSingletonContext; + pm_GmmFuncs->pfnDeleteClientContext = &deleteClientContext; + pm_GmmFuncs->pfnDestroySingletonContext = &destroySingletonContext; + return GMM_SUCCESS; +} + +namespace GmmLib { +MEMORY_OBJECT_CONTROL_STATE GmmClientContext::CachePolicyGetMemoryObject(GMM_RESOURCE_INFO *pResInfo, GMM_RESOURCE_USAGE_TYPE Usage) { + return {}; +} +GmmClientContext::GmmClientContext(GMM_CLIENT ClientType) { +} +GmmClientContext::~GmmClientContext() { +} + +GMM_PTE_CACHE_CONTROL_BITS GMM_STDCALL GmmClientContext::CachePolicyGetPteType(GMM_RESOURCE_USAGE_TYPE Usage) { + return {}; +} + +MEMORY_OBJECT_CONTROL_STATE GMM_STDCALL GmmClientContext::CachePolicyGetOriginalMemoryObject(GMM_RESOURCE_INFO *pResInfo) { + return {}; +} + +uint8_t GMM_STDCALL GmmClientContext::CachePolicyIsUsagePTECached(GMM_RESOURCE_USAGE_TYPE Usage) { + return 0; +} + +uint32_t GMM_STDCALL GmmClientContext::CachePolicyGetMaxMocsIndex() { + return 0; +} + +uint32_t GMM_STDCALL GmmClientContext::CachePolicyGetMaxL1HdcMocsIndex() { + return 0; +} + +uint32_t GMM_STDCALL GmmClientContext::CachePolicyGetMaxSpecialMocsIndex(void) { + return 0; +} + +const GMM_CACHE_POLICY_ELEMENT *GMM_STDCALL GmmClientContext::GetCachePolicyUsage() { + return nullptr; +} + +void GMM_STDCALL GmmClientContext::GetCacheSizes(GMM_CACHE_SIZES *pCacheSizes) { + return; +} + +uint8_t GMM_STDCALL GmmClientContext::GetUseGlobalGtt(GMM_HW_COMMAND_STREAMER cs, + GMM_HW_COMMAND Command, + D3DDDI_PATCHLOCATIONLIST_DRIVERID *pDriverId) { + return 0; +} +GMM_CACHE_POLICY_ELEMENT GMM_STDCALL GmmClientContext::GetCachePolicyElement(GMM_RESOURCE_USAGE_TYPE Usage) { + return {}; +} + +GMM_CACHE_POLICY_TBL_ELEMENT GMM_STDCALL GmmClientContext::GetCachePolicyTlbElement(uint32_t MocsIdx) { + return {}; +} + +GMM_PLATFORM_INFO &GMM_STDCALL GmmClientContext::GetPlatformInfo() { + return *pGlobalPlatformInfo; +} + +uint8_t GMM_STDCALL GmmClientContext::IsPlanar(GMM_RESOURCE_FORMAT Format) { + return 0; +} + +uint8_t GMM_STDCALL GmmClientContext::IsP0xx(GMM_RESOURCE_FORMAT Format) { + return 0; +} + +uint8_t GMM_STDCALL GmmClientContext::IsUVPacked(GMM_RESOURCE_FORMAT Format) { + return 0; +} + +uint8_t GMM_STDCALL GmmClientContext::IsCompressed(GMM_RESOURCE_FORMAT Format) { + return 0; +} + +uint8_t GMM_STDCALL GmmClientContext::IsYUVPacked(GMM_RESOURCE_FORMAT Format) { + return 0; +} + +GMM_STATUS GMM_STDCALL GmmClientContext::GetLogicalTileShape(uint32_t TileMode, + uint32_t *pWidthInBytes, + uint32_t *pHeight, + uint32_t *pDepth) { + return GMM_SUCCESS; +} + +GMM_RESOURCE_INFO *GMM_STDCALL GmmClientContext::CreateResInfoObject(GMM_RESCREATE_PARAMS *pCreateParams) { + return new GMM_RESOURCE_INFO; +} + +GMM_RESOURCE_INFO *GMM_STDCALL GmmClientContext::CopyResInfoObject(GMM_RESOURCE_INFO *pSrcRes) { + return new GMM_RESOURCE_INFO; +} + +void GMM_STDCALL GmmClientContext::ResMemcpy(void *pDst, void *pSrc) { +} + +void GMM_STDCALL GmmClientContext::DestroyResInfoObject(GMM_RESOURCE_INFO *pResInfo) { + delete pResInfo; +} + +GMM_PAGETABLE_MGR *GMM_STDCALL GmmClientContext::CreatePageTblMgrObject( + GMM_DEVICE_CALLBACKS *pDevCb, + GMM_TRANSLATIONTABLE_CALLBACKS *pTTCB, + uint32_t TTFlags) { + return nullptr; +} + +GMM_PAGETABLE_MGR *GMM_STDCALL GmmClientContext::CreatePageTblMgrObject( + GMM_DEVICE_CALLBACKS_INT *pDevCb, + GMM_TRANSLATIONTABLE_CALLBACKS *pTTCB, + uint32_t TTFlags) { + return nullptr; +} + +void GMM_STDCALL GmmClientContext::DestroyPageTblMgrObject(GMM_PAGETABLE_MGR *pPageTableMgr) { +} +GMM_RESOURCE_INFO *GMM_STDCALL GmmClientContext::CreateResInfoObject(GMM_RESCREATE_PARAMS *pCreateParams, + GmmClientAllocationCallbacks *pAllocCbs) { + return nullptr; +} + +void GMM_STDCALL GmmClientContext::DestroyResInfoObject(GMM_RESOURCE_INFO *pResInfo, + GmmClientAllocationCallbacks *pAllocCbs) { +} + +GMM_PAGETABLE_MGR *GMM_STDCALL GmmClientContext::CreatePageTblMgrObject( + GMM_DEVICE_CALLBACKS_INT *pDevCb, + GMM_TRANSLATIONTABLE_CALLBACKS *pTTCB, + uint32_t TTFlags, + GmmClientAllocationCallbacks *pAllocCbs) { + return nullptr; +} + +void GMM_STDCALL GmmClientContext::DestroyPageTblMgrObject(GMM_PAGETABLE_MGR *pPageTableMgr, + GmmClientAllocationCallbacks *pAllocCbs) { +} + +extern "C" GMM_CLIENT_CONTEXT *GMM_STDCALL GmmCreateClientContext(GMM_CLIENT ClientType) { + return nullptr; +} + +extern "C" void GMM_STDCALL GmmDeleteClientContext(GMM_CLIENT_CONTEXT *pGmmClientContext) { +} + +uint8_t GMM_STDCALL GmmClientContext::ConfigureDeviceAddressSpace(GMM_ESCAPE_HANDLE_EXT hAdapter, + GMM_ESCAPE_HANDLE_EXT hDevice, + GMM_ESCAPE_FUNC_TYPE_EXT pfnEscape, + GMM_GFX_SIZE_T SvmSize, + uint8_t FaultableSvm, + uint8_t SparseReady, + uint8_t BDWL3Coherency, + GMM_GFX_SIZE_T SizeOverride, + GMM_GFX_SIZE_T SlmGfxSpaceReserve) { + return 0; +} + +uint32_t GmmClientContext::GetSetProcessGfxPartition(GMM_ESCAPE_HANDLE_EXT hAdapter, + GMM_ESCAPE_HANDLE_EXT hDevice, + GMM_GFX_PARTITIONING *pProcessGfxPart, + uint8_t Get, + GMM_ESCAPE_FUNC_TYPE_EXT pfnEscape) { + + return 0; +} + +GMM_GFX_PARTITIONING GMM_STDCALL GmmClientContext::OverrideGfxPartition(GMM_GFX_PARTITIONING *GfxPartition, + GMM_ESCAPE_HANDLE_EXT hAdapter, + GMM_ESCAPE_HANDLE_EXT hDevice, + GMM_ESCAPE_FUNC_TYPE_EXT pfnEscape) { + return {}; +} + +uint8_t GMM_STDCALL GmmClientContext::EnhancedBufferMap(GMM_ESCAPE_HANDLE_EXT hAdapter, + GMM_ESCAPE_HANDLE_EXT hDevice, + GMM_ESCAPE_FUNC_TYPE_EXT pfnEscape, + D3DKMT_HANDLE hOriginalAllocation, + GMM_ENHANCED_BUFFER_INFO *pEnhancedBufferInfo[GMM_MAX_DISPLAYS]) { + return 0; +} + +GMM_GFX_ADDRESS GMM_STDCALL GmmClientContext::GetHeap32Base(GMM_ESCAPE_HANDLE_EXT hAdapter, + GMM_ESCAPE_HANDLE_EXT hDevice, + uint32_t *pHeapSize, + GMM_ESCAPE_FUNC_TYPE_EXT pfnEscape) { + + return {}; +} + +GMM_GFX_ADDRESS GMM_STDCALL GmmClientContext::GetTrashPageGfxAddress(GMM_ESCAPE_HANDLE_EXT hAdapter, + GMM_ESCAPE_HANDLE_EXT hDevice, + GMM_ESCAPE_FUNC_TYPE_EXT pfnEscape) { + return {}; +} + +GMM_HEAP *GMM_STDCALL GmmClientContext::UmSetupHeap(GMM_ESCAPE_HANDLE_EXT hAdapter, + GMM_ESCAPE_HANDLE_EXT hDevice, + GMM_GFX_ADDRESS GfxAddress, + GMM_GFX_SIZE_T Size, + uint32_t Flags, + GMM_ESCAPE_FUNC_TYPE_EXT pfnEscape) { + + return nullptr; +} + +GMM_STATUS GMM_STDCALL GmmClientContext::UmDestroypHeap(GMM_ESCAPE_HANDLE_EXT hAdapter, + GMM_ESCAPE_HANDLE_EXT hDevice, + GMM_HEAP **pHeapObj, + GMM_ESCAPE_FUNC_TYPE_EXT pfnEscape) { + return GMM_SUCCESS; +} + +GMM_GFX_ADDRESS GMM_STDCALL GmmClientContext::AllocateHeapVA(GMM_HEAP *pHeapObj, + GMM_GFX_SIZE_T AllocSize) { + + return {}; +} + +GMM_STATUS GMM_STDCALL GmmClientContext::FreeHeapVA(GMM_HEAP *pHeapObj, + GMM_GFX_ADDRESS AllocVA, + GMM_GFX_SIZE_T AllocSize) { + return GMM_SUCCESS; +} + +void *GmmClientContext::__GetSharedHeapObject(GMM_ESCAPE_HANDLE_EXT hAdapter, + GMM_ESCAPE_HANDLE_EXT hDevice, + GMM_ESCAPE_FUNC_TYPE_EXT pfnEscape) { + return nullptr; +} + +uint32_t GmmClientContext::__SetSharedHeapObject(GMM_ESCAPE_HANDLE_EXT hAdapter, + GMM_ESCAPE_HANDLE_EXT hDevice, + void **pHeapObj, + GMM_ESCAPE_FUNC_TYPE_EXT pfnEscape) { + return 0; +} + +GMM_GFX_ADDRESS GMM_STDCALL GmmClientContext::GetSLMaddressRange(GMM_ESCAPE_HANDLE_EXT hAdapter, + GMM_ESCAPE_HANDLE_EXT hDevice, + GMM_GFX_SIZE_T Size, + GMM_ESCAPE_FUNC_TYPE_EXT pfnEscape) { + return {}; +} + +uint8_t GMM_STDCALL GmmClientContext::ResDestroySvmAllocation(GMM_ESCAPE_HANDLE_EXT hAdapter, + GMM_ESCAPE_HANDLE_EXT hDevice, + D3DKMT_HANDLE hAllocation, + GMM_ESCAPE_FUNC_TYPE_EXT pfnEscape) { + return 0; +} + +void GMM_STDCALL GmmClientContext::GetD3dSwizzlePattern(const SWIZZLE_DESCRIPTOR *pGmmSwizzle, + uint8_t MSAA, + D3DWDDM2_0DDI_SWIZZLE_PATTERN_DESC *pD3dSwizzle) { +} + +void GMM_STDCALL GmmClientContext::GetD3dSwizzlePattern(const SWIZZLE_DESCRIPTOR *pGmmSwizzle, + uint8_t MSAA, + D3DWDDM2_2DDI_SWIZZLE_PATTERN_DESC *pD3dSwizzle) { +} + +void GMM_STDCALL GmmClientContext::GetD3dSwizzlePattern(const SWIZZLE_DESCRIPTOR *pGmmSwizzle, + uint8_t MSAA, + D3D12DDI_SWIZZLE_PATTERN_DESC_0022 *pD3dSwizzle) { +} + +void GMM_STDCALL GmmClientContext::GetD3dSwizzlePattern(const SWIZZLE_DESCRIPTOR *pGmmSwizzle, + uint8_t MSAA, + D3D12DDI_SWIZZLE_PATTERN_DESC_0004 *pD3dSwizzle) { +} + +GMM_GFX_ADDRESS GMM_STDCALL GmmClientContext::PigmsReserveGpuVA(GMM_ESCAPE_HANDLE_EXT hAdapter, + GMM_ESCAPE_HANDLE_EXT hDevice, + GMM_GFX_SIZE_T Size, + GMM_ESCAPE_FUNC_TYPE_EXT pfnEscape) { + return 0; +} + +uint8_t GMM_STDCALL GmmClientContext::PigmsMapGpuVA(GMM_ESCAPE_HANDLE_EXT hAdapter, + GMM_ESCAPE_HANDLE_EXT hDevice, + GMM_GFX_ADDRESS GfxAddress, + D3DKMT_HANDLE hAllocation, + GMM_RESOURCE_INFO *pGmmResInfo, + GMM_ESCAPE_FUNC_TYPE_EXT pfnEscape) { + return 0; +} + +uint8_t GMM_STDCALL GmmClientContext::PigmsFreeGpuVa(GMM_ESCAPE_HANDLE_EXT hAdapter, + GMM_ESCAPE_HANDLE_EXT hDevice, + GMM_GFX_ADDRESS GfxAddress, + GMM_GFX_SIZE_T Size, + GMM_ESCAPE_FUNC_TYPE_EXT pfnEscape) { + return 0; +} + +GMM_STATUS GMM_STDCALL GmmClientContext::ResUpdateAfterSharedOpen(HANDLE hAdapter, + HANDLE hDevice, + D3DKMT_HANDLE hAllocation, + GMM_RESOURCE_INFO *pGmmResInfo, + GMM_ESCAPE_FUNC_TYPE_EXT pfnEscape) { + return GMM_SUCCESS; +} + +uint8_t GMM_STDCALL GmmClientContext::CreateTiledResource(GMM_HANDLE_EXT hAdapter, + GMM_HANDLE_EXT hDevice, + GMM_UMD_SYNCCONTEXT *pUmdContext, + GMM_TRANSLATIONTABLE_CALLBACKS *pTrTtCallbacks, + GMM_RESOURCE_INFO *pGmmResource, + GMM_ESCAPE_FUNC_TYPE_EXT pfnEscape, + uint32_t NullHw) { + return 0; +} + +uint8_t GMM_STDCALL GmmClientContext::DestroyTiledResource(GMM_HANDLE_EXT hAdapter, + GMM_HANDLE_EXT hDevice, + GMM_UMD_SYNCCONTEXT *pUmdContext, + GMM_TRANSLATIONTABLE_CALLBACKS *pTrTtCallbacks, + GMM_RESOURCE_INFO *pGmmResource, + GMM_ESCAPE_FUNC_TYPE_EXT pfnEscape, + uint32_t NullHw) { + return 0; +} + +GMM_STATUS GMM_STDCALL GmmClientContext::UpdateTiledResourceMapping(GMM_HANDLE_EXT hAdapter, + GMM_HANDLE_EXT hDevice, + GMM_UPDATE_TILE_MAPPINGS_INT Mappings, + uint8_t UseWDDM20, + GMM_UMD_SYNCCONTEXT *pUmdContext, + GMM_TRANSLATIONTABLE_CALLBACKS *CmdBufCallbacks, + GMM_ESCAPE_FUNC_TYPE_EXT pfnEscape, + GMM_DEVICE_CALLBACKS_INT *DeviceCallbacks, + uint32_t NullHw, + uint8_t NewPool) { + return GMM_SUCCESS; +} + +GMM_STATUS GMM_STDCALL GmmClientContext::UpdateSparseResourceOpaqueMapping(GMM_HANDLE_EXT hAdapter, + GMM_HANDLE_EXT hDevice, + GMM_UMD_SYNCCONTEXT *pUmdContext, + GMM_TRANSLATIONTABLE_CALLBACKS *CmdBufCallbacks, + GMM_ESCAPE_FUNC_TYPE_EXT pfnEscape, + uint8_t UseWDDM20, + uint32_t NumMappings, + GMM_UPDATE_SPARSE_RESOURCE_OPAQUE_MAPPINGS *pMappings) { + return GMM_SUCCESS; +} + +GMM_STATUS GMM_STDCALL GmmClientContext::CopyTileMappings(GMM_HANDLE_EXT hAdapter, + GMM_HANDLE_EXT hDevice, + GMM_COPY_TILE_MAPPINGS_INT Mappings, + uint8_t UseWDDM20, + GMM_UMD_SYNCCONTEXT *pUmdContext, + GMM_TRANSLATIONTABLE_CALLBACKS *CmdBufCallbacks, + GMM_ESCAPE_FUNC_TYPE_EXT pfnEscape, + GMM_DEVICE_CALLBACKS_INT *DeviceCallbacks, + uint32_t NullHw, + uint8_t CheckTilePoolAllocs) { + return GMM_SUCCESS; +} + +uint64_t GMM_STDCALL GmmClientContext::GetInternalGpuVaRangeLimit() { + return 0; +} + +bool GmmResourceInfoCommon::IsPresentableformat() { + return false; +} +void GmmResourceInfoCommon::GetGenericRestrictions(__GMM_BUFFER_TYPE *pBuff) { +} +__GMM_BUFFER_TYPE *GmmResourceInfoCommon::GetBestRestrictions(__GMM_BUFFER_TYPE *pFirstBuffer, const __GMM_BUFFER_TYPE *pSecondBuffer) { + return nullptr; +} +bool GmmResourceInfoCommon::CopyClientParams(GMM_RESCREATE_PARAMS &CreateParams) { + return false; +} +bool GmmResourceInfoCommon::RedescribePlanes() { + return false; +} +bool GmmResourceInfoCommon::ReAdjustPlaneProperties(bool IsAuxSurf) { + return false; +} + +const GMM_PLATFORM_INFO &GmmResourceInfoCommon::GetPlatformInfo() { + return *pGlobalPlatformInfo; +} +GMM_STATUS GMM_STDCALL GmmResourceInfoCommon::Create(Context &GmmLibContext, GMM_RESCREATE_PARAMS &CreateParams) { + return GMM_SUCCESS; +} +uint8_t GMM_STDCALL GmmResourceInfoCommon::ValidateParams() { + return 0; +} +GMM_STATUS GMM_STDCALL GmmResourceInfoCommon::Create(GMM_RESCREATE_PARAMS &CreateParams) { + + return GMM_SUCCESS; +} +void GMM_STDCALL GmmResourceInfoCommon::GetRestrictions(__GMM_BUFFER_TYPE &Restrictions) { +} +uint32_t GMM_STDCALL GmmResourceInfoCommon::GetPaddedWidth(uint32_t MipLevel) { + return 0; +} +uint32_t GMM_STDCALL GmmResourceInfoCommon::GetPaddedHeight(uint32_t MipLevel) { + return 0; +} +uint32_t GMM_STDCALL GmmResourceInfoCommon::GetPaddedPitch(uint32_t MipLevel) { + return 0; +} +uint32_t GMM_STDCALL GmmResourceInfoCommon::GetQPitch() { + return 0; +} +GMM_STATUS GMM_STDCALL GmmResourceInfoCommon::GetOffset(GMM_REQ_OFFSET_INFO &ReqInfo) { + + return GMM_SUCCESS; +} +uint8_t GMM_STDCALL GmmResourceInfoCommon::CpuBlt(GMM_RES_COPY_BLT *pBlt) { + return 0; +} +uint8_t GMM_STDCALL GmmResourceInfoCommon::GetMappingSpanDesc(GMM_GET_MAPPING *pMapping) { + return 0; +} +uint8_t GMM_STDCALL GmmResourceInfoCommon::Is64KBPageSuitable() { + return 0; +} +void GMM_STDCALL GmmResourceInfoCommon::GetTiledResourceMipPacking(uint32_t *pNumPackedMips, + uint32_t *pNumTilesForPackedMips) {} +uint32_t GMM_STDCALL GmmResourceInfoCommon::GetPackedMipTailStartLod() { + return 0; +} +bool GMM_STDCALL GmmResourceInfoCommon::IsMipRCCAligned(uint8_t &MisAlignedLod) { + return false; +} +uint8_t GMM_STDCALL GmmResourceInfoCommon::GetDisplayFastClearSupport() { + return 0; +} +uint8_t GMM_STDCALL GmmResourceInfoCommon::GetDisplayCompressionSupport() { + return 0; +} +uint32_t GMM_STDCALL GmmResourceInfoCommon::GetCompressionBlockWidth() { + return 0; +} +uint32_t GMM_STDCALL GmmResourceInfoCommon::GetCompressionBlockHeight() { + return 0; +} +uint32_t GMM_STDCALL GmmResourceInfoCommon::GetCompressionBlockDepth() { + return 0; +} +uint8_t GMM_STDCALL GmmResourceInfoCommon::IsArraySpacingSingleLod() { + return 0; +} +uint8_t GMM_STDCALL GmmResourceInfoCommon::IsASTC() { + return 0; +} +MEMORY_OBJECT_CONTROL_STATE GMM_STDCALL GmmResourceInfoCommon::GetMOCS() { + return {}; +} +uint32_t GMM_STDCALL GmmResourceInfoCommon::GetStdTilingModeExtSurfaceState() { + return 0; +} +GMM_SURFACESTATE_FORMAT GMM_STDCALL GmmResourceInfoCommon::GetResourceFormatSurfaceState() { + return {}; +} +GMM_GFX_SIZE_T GMM_STDCALL GmmResourceInfoCommon::GetMipWidth(uint32_t MipLevel) { + return {}; +} +uint32_t GMM_STDCALL GmmResourceInfoCommon::GetMipHeight(uint32_t MipLevel) { + return 0; +} +uint32_t GMM_STDCALL GmmResourceInfoCommon::GetMipDepth(uint32_t MipLevel) { + return 0; +} +GMM_STATUS GMM_STDCALL GmmResourceInfoWin::GetOffsetFor64KBTiles(GMM_REQ_OFFSET_INFO &ReqInfo) { + return GMM_SUCCESS; +} +uint8_t GMM_STDCALL GmmResourceInfoWin::ApplyExistingSysMem(void *pExistingSysMem, GMM_GFX_SIZE_T ExistingSysMemSize) { + return 0; +} +uint8_t GMM_STDCALL GmmResourceInfoWin::IsPredictedGlobalAliasingParticipant() { + return 0; +} +uint8_t GMM_STDCALL GmmResourceInfoWin::IsSurfaceFaultable() { + return 0; +} +uint32_t GMM_STDCALL GmmResourceInfoWin::GetRenderPitchIn64KBTiles() { + return 0; +} +uint8_t GMM_STDCALL GmmResourceInfoWin::UpdateCacheability(GMM_ESCAPE_HANDLE_EXT hAdapter, + GMM_ESCAPE_HANDLE_EXT hDevice, + D3DKMT_HANDLE hAllocation, + GMM_GPU_CACHE_SETTINGS &CacheSettings, + GMM_ESCAPE_FUNC_TYPE_EXT pfnEscape) { + return 0; +} +uint8_t GMM_STDCALL GmmResourceInfoWin::Alias32bit(GMM_ESCAPE_HANDLE_EXT hAdapter, + GMM_ESCAPE_HANDLE_EXT hDevice, + D3DKMT_HANDLE hAllocation, + uint32_t Size, + uint32_t *pAliasAddress, + GMM_ESCAPE_FUNC_TYPE_EXT pfnEscape) { + return 0; +} +uint8_t GMM_STDCALL GmmResourceInfoWin::KmdGetSetHardwareProtection(GMM_ESCAPE_HANDLE_EXT hAdapter, + GMM_ESCAPE_HANDLE_EXT hDevice, + D3DKMT_HANDLE hAllocation, + uint8_t SetIsEncrypted, + uint8_t *pGetIsEncrypted, + GMM_ESCAPE_FUNC_TYPE_EXT pfnEscape) { + return 0; +} + +uint8_t GMM_STDCALL GmmResourceInfoWin::KmdSetPavpStoutOrIsolatedEncryptionForDisplay(GMM_ESCAPE_HANDLE_EXT hAdapter, + GMM_ESCAPE_HANDLE_EXT hDevice, + D3DKMT_HANDLE hAllocation, + uint8_t bPavpModeIsStoutOrIsolatedDecode, + uint32_t uiPavpSessionId, + GMM_ESCAPE_FUNC_TYPE_EXT pfnEscape) { + return 0; +} + +uint32_t GMM_STDCALL GmmResourceInfoWin::KmdGetSetCpSurfTag(GMM_ESCAPE_HANDLE_EXT hAdapter, + GMM_ESCAPE_HANDLE_EXT hDevice, + D3DKMT_HANDLE hAllocation, + uint8_t IsSet, + uint32_t CpTag, + GMM_ESCAPE_FUNC_TYPE_EXT pfnEscape) { + return 0; +} +bool GmmResourceInfoWin::CopyClientParams(GMM_RESCREATE_PARAMS &CreateParams) { + return false; +} +GMM_GFX_ADDRESS GmmPageTableMgr::GetTRL3TableAddr() { + return {}; +} +GMM_GFX_ADDRESS GmmPageTableMgr::GetAuxL3TableAddr() { + return {}; +} +GMM_STATUS GmmPageTableMgr::InitContextAuxTableRegister(HANDLE initialBBHandle, GMM_ENGINE_TYPE engType) { + return GMM_SUCCESS; +} +GMM_STATUS GmmPageTableMgr::InitContextTRTableRegister(HANDLE initialBBHandle, GMM_ENGINE_TYPE engType) { + return GMM_SUCCESS; +} +void GmmPageTableMgr::InitGpuBBQueueCallbacks(GMM_TRANSLATIONTABLE_CALLBACKS *TTCB) {} + +HRESULT GmmPageTableMgr::ReserveTRGpuVirtualAddress(GMM_UMD_SYNCCONTEXT *, D3DDDI_RESERVEGPUVIRTUALADDRESS *, uint8_t DoNotWait) { + return 0; +} + +HRESULT GmmPageTableMgr::MapTRGpuVirtualAddress(GMM_MAPTRGPUVIRTUALADDRESS *ReserveGpuVa, uint8_t DoNotWait) { + return 0; +} +HRESULT GmmPageTableMgr::UpdateTRGpuVirtualAddress(GMM_UMD_SYNCCONTEXT **, const GMM_UPDATETRGPUVIRTUALADDRESS_INT *, uint8_t DoNotWait) { + return 0; +} +HRESULT GmmPageTableMgr::FreeTRGpuVirtualAddress(GMM_UMD_SYNCCONTEXT *, const GMM_DDI_FREEGPUVIRTUALADDRSS_INT *, uint8_t DoNotWait) { + return 0; +} +GMM_STATUS GmmPageTableMgr::UpdateAuxTable(const GMM_DDI_UPDATEAUXTABLE *) { + return GMM_SUCCESS; +} +void GmmPageTableMgr::EvictPageTablePool(D3DKMT_HANDLE *BBQHandles, int NumBBFenceObj) {} +void GmmPageTableMgr::__ReleaseUnusedPool(GMM_UMD_SYNCCONTEXT *UmdContext) {} +GMM_PAGETABLEPool *GmmPageTableMgr::__GetFreePoolNode(uint32_t *FreePoolNodeIdx, POOL_TYPE PoolType) { return nullptr; } +GmmPageTableMgr::~GmmPageTableMgr() {} +} +uint8_t GMM_STDCALL GmmIsPlanar(GMM_RESOURCE_FORMAT Format) { + return 0; +} +const GMM_PLATFORM_INFO *GMM_STDCALL GmmGetPlatformInfo(GMM_GLOBAL_CONTEXT *pGmmLibContext) { + return nullptr; +} diff --git a/unit_tests/mock_gmm/mock_gmm.h b/unit_tests/mock_gmm/mock_gmm.h new file mode 100644 index 0000000000..7247eae557 --- /dev/null +++ b/unit_tests/mock_gmm/mock_gmm.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2018, Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#include "GmmLib.h" + +void initPlatform(GMM_PLATFORM_INFO *platform); diff --git a/unit_tests/mocks/mock_gmm_page_table_mngr.cpp b/unit_tests/mocks/mock_gmm_page_table_mngr.cpp index 3e503a7fea..63ffbc3e84 100644 --- a/unit_tests/mocks/mock_gmm_page_table_mngr.cpp +++ b/unit_tests/mocks/mock_gmm_page_table_mngr.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2017, Intel Corporation +* Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -27,7 +27,7 @@ namespace OCLRT { using namespace ::testing; -GmmPageTableMngr *GmmPageTableMngr::create(GMM_DEVICE_CALLBACKS *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb) { +GmmPageTableMngr *GmmPageTableMngr::create(GMM_DEVICE_CALLBACKS_INT *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb) { auto pageTableMngr = new ::testing::NiceMock(deviceCb, translationTableFlags, translationTableCb); ON_CALL(*pageTableMngr, initContextAuxTableRegister(_, _)).WillByDefault(Return(GMM_SUCCESS)); ON_CALL(*pageTableMngr, initContextTRTableRegister(_, _)).WillByDefault(Return(GMM_SUCCESS)); diff --git a/unit_tests/mocks/mock_gmm_page_table_mngr.h b/unit_tests/mocks/mock_gmm_page_table_mngr.h index 2ee200b259..e2947e23f3 100644 --- a/unit_tests/mocks/mock_gmm_page_table_mngr.h +++ b/unit_tests/mocks/mock_gmm_page_table_mngr.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2017, Intel Corporation +* Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -30,7 +30,7 @@ class MockGmmPageTableMngr : public GmmPageTableMngr { public: MockGmmPageTableMngr() = default; - MockGmmPageTableMngr(GMM_DEVICE_CALLBACKS *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb) + MockGmmPageTableMngr(GMM_DEVICE_CALLBACKS_INT *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb) : deviceCb(*deviceCb), translationTableFlags(translationTableFlags), translationTableCb(*translationTableCb){}; MOCK_METHOD2(initContextAuxTableRegister, GMM_STATUS(HANDLE initialBBHandle, GMM_ENGINE_TYPE engineType)); @@ -39,7 +39,7 @@ class MockGmmPageTableMngr : public GmmPageTableMngr { MOCK_METHOD1(updateAuxTable, GMM_STATUS(const GMM_DDI_UPDATEAUXTABLE *ddiUpdateAuxTable)); - GMM_DEVICE_CALLBACKS deviceCb = {}; + GMM_DEVICE_CALLBACKS_INT deviceCb = {}; GMM_TRANSLATIONTABLE_CALLBACKS translationTableCb = {}; unsigned int translationTableFlags = 0; }; diff --git a/unit_tests/os_interface/windows/device_command_stream_tests.cpp b/unit_tests/os_interface/windows/device_command_stream_tests.cpp index a2bf5e1e0b..4e8797b134 100644 --- a/unit_tests/os_interface/windows/device_command_stream_tests.cpp +++ b/unit_tests/os_interface/windows/device_command_stream_tests.cpp @@ -788,32 +788,35 @@ HWTEST_F(WddmCsrCompressionTests, givenEnabledCompressionWhenInitializedThenCrea auto mockMngr = reinterpret_cast(myMockWddm->getPageTableManager()); - GMM_DEVICE_CALLBACKS expectedDeviceCb = {}; + GMM_DEVICE_CALLBACKS_INT expectedDeviceCb = {}; GMM_TRANSLATIONTABLE_CALLBACKS expectedTTCallbacks = {}; unsigned int expectedFlags = (TT_TYPE::TRTT | TT_TYPE::AUXTT); auto myGdi = myMockWddm->getGdi(); // clang-format off - expectedDeviceCb.Adapter = myMockWddm->getAdapter(); - expectedDeviceCb.hDevice = myMockWddm->getDevice(); + expectedDeviceCb.Adapter.KmtHandle = myMockWddm->getAdapter(); + expectedDeviceCb.hDevice.KmtHandle = myMockWddm->getDevice(); expectedDeviceCb.PagingQueue = myMockWddm->getPagingQueue(); expectedDeviceCb.PagingFence = myMockWddm->getPagingQueueSyncObject(); - expectedDeviceCb.pfnAllocate = myGdi->createAllocation; - expectedDeviceCb.pfnDeallocate = myGdi->destroyAllocation; - expectedDeviceCb.pfnMapGPUVA = myGdi->mapGpuVirtualAddress; - expectedDeviceCb.pfnMakeResident = myGdi->makeResident; - expectedDeviceCb.pfnEvict = myGdi->evict; - expectedDeviceCb.pfnReserveGPUVA = myGdi->reserveGpuVirtualAddress; - expectedDeviceCb.pfnUpdateGPUVA = myGdi->updateGpuVirtualAddress; - expectedDeviceCb.pfnWaitFromCpu = myGdi->waitForSynchronizationObjectFromCpu; - expectedDeviceCb.pfnLock = myGdi->lock2; - expectedDeviceCb.pfnUnLock = myGdi->unlock2; - expectedDeviceCb.pfnEscape = myGdi->escape; + expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnAllocate = myGdi->createAllocation; + expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnDeallocate = myGdi->destroyAllocation; + expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnMapGPUVA = myGdi->mapGpuVirtualAddress; + expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnMakeResident = myGdi->makeResident; + expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnEvict = myGdi->evict; + expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnReserveGPUVA = myGdi->reserveGpuVirtualAddress; + expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnUpdateGPUVA = myGdi->updateGpuVirtualAddress; + expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnWaitFromCpu = myGdi->waitForSynchronizationObjectFromCpu; + expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnLock = myGdi->lock2; + expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnUnLock = myGdi->unlock2; + expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnEscape = myGdi->escape; expectedTTCallbacks.pfWriteL3Adr = TTCallbacks::writeL3Address; // clang-format on - EXPECT_TRUE(memcmp(&expectedDeviceCb, &mockMngr->deviceCb, sizeof(GMM_DEVICE_CALLBACKS)) == 0); + EXPECT_TRUE(memcmp(&expectedDeviceCb, &mockMngr->deviceCb, sizeof(GMM_DEVICE_CALLBACKS_INT)) == 0); + EXPECT_TRUE(memcmp(&expectedDeviceCb.Adapter, &mockMngr->deviceCb.Adapter, sizeof(GMM_HANDLE_EXT)) == 0); + EXPECT_TRUE(memcmp(&expectedDeviceCb.hDevice, &mockMngr->deviceCb.hDevice, sizeof(GMM_HANDLE_EXT)) == 0); + EXPECT_TRUE(memcmp(&expectedDeviceCb.DevCbPtrs.KmtCbPtrs, &mockMngr->deviceCb.DevCbPtrs.KmtCbPtrs, sizeof(GMM_DEVICE_CB_PTRS::KmtCbPtrs)) == 0); EXPECT_TRUE(memcmp(&expectedTTCallbacks, &mockMngr->translationTableCb, sizeof(GMM_TRANSLATIONTABLE_CALLBACKS)) == 0); EXPECT_TRUE(memcmp(&expectedFlags, &mockMngr->translationTableFlags, sizeof(unsigned int)) == 0); } diff --git a/unit_tests/os_interface/windows/options.cpp b/unit_tests/os_interface/windows/options.cpp index 1768e3c47e..5b7f5d8c7e 100644 --- a/unit_tests/os_interface/windows/options.cpp +++ b/unit_tests/os_interface/windows/options.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -32,6 +32,7 @@ namespace Os { const char *frontEndDllName = "mock_igdfcl.dll"; const char *igcDllName = "mock_igc.dll"; const char *gdiDllName = "gdi32_mock.dll"; +const char *gmmDllName = "mock_gmm.dll"; const char *testDllName = "test_dynamic_lib.dll"; } diff --git a/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp b/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp index 2c247a3ee8..a5ecdb0b22 100644 --- a/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp @@ -38,7 +38,7 @@ void WddmMemoryManagerFixture::SetUp() { wddm = static_cast(Wddm::createWddm(WddmInterfaceVersion::Wddm20)); ASSERT_NE(nullptr, wddm); if (platformDevices[0]->capabilityTable.ftrCompression) { - GMM_DEVICE_CALLBACKS dummyDeviceCallbacks = {}; + GMM_DEVICE_CALLBACKS_INT dummyDeviceCallbacks = {}; GMM_TRANSLATIONTABLE_CALLBACKS dummyTTCallbacks = {}; wddm->resetPageTableManager(GmmPageTableMngr::create(&dummyDeviceCallbacks, 0, &dummyTTCallbacks)); } diff --git a/unit_tests/tbx/CMakeLists.txt b/unit_tests/tbx/CMakeLists.txt index 6d8939e8c9..44c0653bb1 100644 --- a/unit_tests/tbx/CMakeLists.txt +++ b/unit_tests/tbx/CMakeLists.txt @@ -46,6 +46,7 @@ else() ) endif() +copy_gmm_dll_for(igdrcl_tbx_tests) create_project_source_tree(igdrcl_tbx_tests ${IGDRCL_SOURCE_DIR}/runtime ${IGDRCL_SOURCE_DIR}/unit_tests) add_custom_target(run_tbx_tests ALL DEPENDS unit_tests igdrcl_tbx_tests) diff --git a/unit_tests/ult_configuration.cpp b/unit_tests/ult_configuration.cpp index e68bccba0e..5775665ccf 100644 --- a/unit_tests/ult_configuration.cpp +++ b/unit_tests/ult_configuration.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -22,4 +22,5 @@ namespace OCLRT { unsigned int ultIterationMaxTime = 45; +bool useMockGmm = true; } diff --git a/unit_tests/windows/CMakeLists.txt b/unit_tests/windows/CMakeLists.txt index 25c8c423ee..f77c762e47 100644 --- a/unit_tests/windows/CMakeLists.txt +++ b/unit_tests/windows/CMakeLists.txt @@ -23,6 +23,7 @@ project(igdrcl_windows_dll_tests) add_executable(igdrcl_windows_dll_tests ${IGDRCL_SOURCE_DIR}/runtime/os_interface/windows/wddm/wddm_create.cpp + ${IGDRCL_SOURCE_DIR}/unit_tests/ult_configuration.cpp ${CMAKE_CURRENT_SOURCE_DIR}/wddm_create_tests.cpp $ $