/* * Copyright (C) 2017-2019 Intel Corporation * * SPDX-License-Identifier: MIT * */ #include "gdi_interface.h" namespace NEO { inline const std::string getGdiName() { if (DebugManager.flags.OverrideGdiPath.get() != "unk") { return DebugManager.flags.OverrideGdiPath.get(); } else { return Os::gdiDllName; } } Gdi::Gdi() : gdiDll(getGdiName()), initialized(false) { if (gdiDll.isLoaded()) { initialized = getAllProcAddresses(); } } bool Gdi::setupHwQueueProcAddresses() { createHwQueue = reinterpret_cast(gdiDll.getProcAddress("D3DKMTCreateHwQueue")); destroyHwQueue = reinterpret_cast(gdiDll.getProcAddress("D3DKMTDestroyHwQueue")); submitCommandToHwQueue = reinterpret_cast(gdiDll.getProcAddress("D3DKMTSubmitCommandToHwQueue")); if (!createHwQueue || !destroyHwQueue || !submitCommandToHwQueue) { return false; } return true; } bool Gdi::getAllProcAddresses() { openAdapterFromHdc = reinterpret_cast(gdiDll.getProcAddress("D3DKMTOpenAdapterFromHdc")); openAdapterFromLuid = reinterpret_cast(gdiDll.getProcAddress("D3DKMTOpenAdapterFromLuid")); createAllocation = reinterpret_cast(gdiDll.getProcAddress("D3DKMTCreateAllocation")); destroyAllocation = reinterpret_cast(gdiDll.getProcAddress("D3DKMTDestroyAllocation")); destroyAllocation2 = reinterpret_cast(gdiDll.getProcAddress("D3DKMTDestroyAllocation2")); queryAdapterInfo = reinterpret_cast(gdiDll.getProcAddress("D3DKMTQueryAdapterInfo")); closeAdapter = reinterpret_cast(gdiDll.getProcAddress("D3DKMTCloseAdapter")); createDevice = reinterpret_cast(gdiDll.getProcAddress("D3DKMTCreateDevice")); destroyDevice = reinterpret_cast(gdiDll.getProcAddress("D3DKMTDestroyDevice")); escape = reinterpret_cast(gdiDll.getProcAddress("D3DKMTEscape")); createContext = reinterpret_cast(gdiDll.getProcAddress("D3DKMTCreateContextVirtual")); destroyContext = reinterpret_cast(gdiDll.getProcAddress("D3DKMTDestroyContext")); openResource = reinterpret_cast(gdiDll.getProcAddress("D3DKMTOpenResource")); openResourceFromNtHandle = reinterpret_cast(gdiDll.getProcAddress("D3DKMTOpenResourceFromNtHandle")); queryResourceInfo = reinterpret_cast(gdiDll.getProcAddress("D3DKMTQueryResourceInfo")); queryResourceInfoFromNtHandle = reinterpret_cast(gdiDll.getProcAddress("D3DKMTQueryResourceInfoFromNtHandle")); lock = reinterpret_cast(gdiDll.getProcAddress("D3DKMTLock")); unlock = reinterpret_cast(gdiDll.getProcAddress("D3DKMTUnlock")); render = reinterpret_cast(gdiDll.getProcAddress("D3DKMTRender")); createSynchronizationObject = reinterpret_cast(gdiDll.getProcAddress("D3DKMTCreateSynchronizationObject")); createSynchronizationObject2 = reinterpret_cast(gdiDll.getProcAddress("D3DKMTCreateSynchronizationObject2")); destroySynchronizationObject = reinterpret_cast(gdiDll.getProcAddress("D3DKMTDestroySynchronizationObject")); signalSynchronizationObject = reinterpret_cast(gdiDll.getProcAddress("D3DKMTSignalSynchronizationObject")); waitForSynchronizationObject = reinterpret_cast(gdiDll.getProcAddress("D3DKMTWaitForSynchronizationObject")); waitForSynchronizationObjectFromCpu = reinterpret_cast(gdiDll.getProcAddress("D3DKMTWaitForSynchronizationObjectFromCpu")); signalSynchronizationObjectFromCpu = reinterpret_cast(gdiDll.getProcAddress("D3DKMTSignalSynchronizationObjectFromCpu")); waitForSynchronizationObjectFromGpu = reinterpret_cast(gdiDll.getProcAddress("D3DKMTWaitForSynchronizationObjectFromGpu")); signalSynchronizationObjectFromGpu = reinterpret_cast(gdiDll.getProcAddress("D3DKMTSignalSynchronizationObjectFromGpu")); createPagingQueue = reinterpret_cast(gdiDll.getProcAddress("D3DKMTCreatePagingQueue")); destroyPagingQueue = reinterpret_cast(gdiDll.getProcAddress("D3DKMTDestroyPagingQueue")); lock2 = reinterpret_cast(gdiDll.getProcAddress("D3DKMTLock2")); unlock2 = reinterpret_cast(gdiDll.getProcAddress("D3DKMTUnlock2")); mapGpuVirtualAddress = reinterpret_cast(gdiDll.getProcAddress("D3DKMTMapGpuVirtualAddress")); reserveGpuVirtualAddress = reinterpret_cast(gdiDll.getProcAddress("D3DKMTReserveGpuVirtualAddress")); freeGpuVirtualAddress = reinterpret_cast(gdiDll.getProcAddress("D3DKMTFreeGpuVirtualAddress")); updateGpuVirtualAddress = reinterpret_cast(gdiDll.getProcAddress("D3DKMTUpdateGpuVirtualAddress")); submitCommand = reinterpret_cast(gdiDll.getProcAddress("D3DKMTSubmitCommand")); makeResident = reinterpret_cast(gdiDll.getProcAddress("D3DKMTMakeResident")); evict = reinterpret_cast(gdiDll.getProcAddress("D3DKMTEvict")); registerTrimNotification = reinterpret_cast(gdiDll.getProcAddress("D3DKMTRegisterTrimNotification")); unregisterTrimNotification = reinterpret_cast(gdiDll.getProcAddress("D3DKMTUnregisterTrimNotification")); // For debug purposes getDeviceState = reinterpret_cast(gdiDll.getProcAddress("D3DKMTGetDeviceState")); // clang-format off if (openAdapterFromHdc && openAdapterFromLuid && createAllocation && destroyAllocation && destroyAllocation2 && queryAdapterInfo && closeAdapter && createDevice && destroyDevice && escape && createContext && destroyContext && openResource && queryResourceInfo && lock && unlock && render && createSynchronizationObject && createSynchronizationObject2 && destroySynchronizationObject && signalSynchronizationObject && waitForSynchronizationObject && waitForSynchronizationObjectFromCpu && signalSynchronizationObjectFromCpu && waitForSynchronizationObjectFromGpu && signalSynchronizationObjectFromGpu && createPagingQueue && destroyPagingQueue && lock2 && unlock2 && mapGpuVirtualAddress && reserveGpuVirtualAddress && freeGpuVirtualAddress && updateGpuVirtualAddress &&submitCommand && makeResident && evict && registerTrimNotification && unregisterTrimNotification){ return true; } // clang-format on return false; } } // namespace NEO