/* * 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"), * 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 "gdi_interface.h" namespace OCLRT { Gdi::Gdi() : gdiDll(Os::gdiDllName), 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 OCLRT