Dynamic loading dxcore instead of linking

Signed-off-by: Krystian Chmielewski <krystian.chmielewski@intel.com>
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Krystian Chmielewski
2021-05-18 15:19:50 +00:00
committed by Compute-Runtime-Automation
parent 1673738dc7
commit 3d7b1abe80
4 changed files with 16 additions and 3 deletions

View File

@ -695,7 +695,7 @@ if(MSVC)
set(LINKER_FLAGS "${LINKER_FLAGS} /OPT:NOICF")
# Support for WUD
set(CMAKE_CXX_STANDARD_LIBRARIES "onecore.lib dxcore.lib")
set(CMAKE_CXX_STANDARD_LIBRARIES "onecore.lib")
foreach(IT kernel32.lib;user32.lib;gdi32.lib;advapi32.lib;ole32.lib;)
set(LINKER_FLAGS "${LINKER_FLAGS} /NODEFAULTLIB:${IT}")
endforeach()

View File

@ -10,6 +10,7 @@
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/os_interface/windows/gdi_interface.h"
#include "shared/source/os_interface/windows/os_library_win.h"
#include "shared/source/utilities/stackvec.h"
#include <memory>
@ -222,4 +223,10 @@ bool DxgiAdapterFactory::createSnapshotOfAvailableAdapters() {
return true;
}
void WddmAdapterFactory::loadDxCore(DxCoreAdapterFactory::CreateAdapterFactoryFcn &outDxCoreCreateAdapterFactoryF) {
dxCoreLibrary.reset(OsLibrary::load("dxcore.dll"));
if (dxCoreLibrary && dxCoreLibrary->isLoaded()) {
outDxCoreCreateAdapterFactoryF = reinterpret_cast<DxCoreAdapterFactory::CreateAdapterFactoryFcn>(dxCoreLibrary->getProcAddress("DXCoreCreateAdapterFactory"));
}
}
} // namespace NEO

View File

@ -22,6 +22,7 @@ typedef unsigned int D3DKMT_HANDLE;
namespace NEO {
class Gdi;
class OsLibrary;
std::wstring queryAdapterDriverStorePath(const Gdi &gdi, D3DKMT_HANDLE adapter);
@ -115,6 +116,9 @@ class WddmAdapterFactory : public AdapterFactory {
public:
WddmAdapterFactory(AdapterFactory::CreateAdapterFactoryFcn dxCoreCreateAdapterFactoryF,
AdapterFactory::CreateAdapterFactoryFcn dxgiCreateAdapterFactoryF) {
if (nullptr == dxCoreCreateAdapterFactoryF) {
loadDxCore(dxCoreCreateAdapterFactoryF);
}
underlyingFactory = std::make_unique<DxCoreAdapterFactory>(dxCoreCreateAdapterFactoryF);
if (false == underlyingFactory->isSupported()) {
underlyingFactory = std::make_unique<DxgiAdapterFactory>(dxgiCreateAdapterFactoryF);
@ -141,6 +145,8 @@ class WddmAdapterFactory : public AdapterFactory {
protected:
std::unique_ptr<AdapterFactory> underlyingFactory;
};
std::unique_ptr<OsLibrary> dxCoreLibrary;
void loadDxCore(DxCoreAdapterFactory::CreateAdapterFactoryFcn &outDxCoreCreateAdapterFactoryF);
};
} // namespace NEO

View File

@ -16,7 +16,7 @@ Wddm::CreateDXGIFactoryFcn getCreateDxgiFactory() {
}
Wddm::DXCoreCreateAdapterFactoryFcn getDXCoreCreateAdapterFactory() {
return DXCoreCreateAdapterFactory;
return nullptr;
}
Wddm::GetSystemInfoFcn getGetSystemInfo() {