|
1 | 1 | #ifndef _NBL_SYSTEM_I_APPLICATION_FRAMEWORK_H_INCLUDED_ |
2 | 2 | #define _NBL_SYSTEM_I_APPLICATION_FRAMEWORK_H_INCLUDED_ |
3 | 3 |
|
| 4 | + |
4 | 5 | #include "nbl/core/declarations.h" |
5 | 6 |
|
6 | 7 | #include "nbl/system/declarations.h" |
7 | 8 | #include "nbl/system/definitions.h" |
8 | 9 |
|
9 | | -#ifdef _NBL_PLATFORM_WINDOWS_ |
10 | | -#include <delayimp.h> |
11 | | -#endif // _NBL_PLATFORM_WINDOWS_ |
12 | 10 |
|
13 | 11 | namespace nbl::system |
14 | 12 | { |
15 | 13 |
|
16 | 14 | class NBL_API IApplicationFramework |
17 | 15 | { |
18 | 16 | public: |
19 | | - virtual void setSystem(core::smart_refctd_ptr<nbl::system::ISystem>&& system) = 0; |
20 | 17 | IApplicationFramework( |
21 | 18 | const system::path& _localInputCWD, |
22 | 19 | const system::path& _localOutputCWD, |
23 | 20 | const system::path& _sharedInputCWD, |
24 | 21 | const system::path& _sharedOutputCWD) : |
25 | 22 | localInputCWD(_localInputCWD), localOutputCWD(_localOutputCWD), sharedInputCWD(_sharedInputCWD), sharedOutputCWD(_sharedOutputCWD) |
26 | 23 | { |
27 | | -#if defined(_NBL_PLATFORM_WINDOWS_) && defined(_NBL_SHARED_BUILD_) |
28 | | - { |
29 | | - HMODULE res = LoadLibraryExA(_NABLA_DLL_NAME_, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR); |
30 | | - if (!res) |
31 | | - { |
32 | | - const auto nablaBuiltDLL = (system::path(_NABLA_OUTPUT_DIR_).make_preferred() / _NABLA_DLL_NAME_).string(); |
33 | | - res = LoadLibraryExA(nablaBuiltDLL.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH); |
34 | | - } |
35 | | - if (!res) |
36 | | - { |
37 | | - const auto nablaInstalledDLL = (system::path(_NABLA_INSTALL_DIR_).make_preferred() / _NABLA_DLL_NAME_).string(); |
38 | | - res = LoadLibraryExA(nablaInstalledDLL.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH); |
39 | | - } |
40 | | - if (!res) |
41 | | - res = LoadLibraryExA(_NABLA_DLL_NAME_, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); |
42 | | - HRESULT hr = __HrLoadAllImportsForDll(_NABLA_DLL_NAME_); |
43 | | - assert(res && SUCCEEDED(hr)); |
44 | | - } |
45 | | -#endif // _NBL_PLATFORM_WINDOWS_ && _NBL_SHARED_BUILD_ |
46 | | - |
47 | | - { |
48 | | - constexpr std::string_view DXCOMPILER_DLL_NAME = "dxcompiler.dll"; |
49 | | - |
50 | | - HMODULE res = LoadLibraryExA(DXCOMPILER_DLL_NAME.data(), NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR); |
51 | | - if (!res) |
52 | | - { |
53 | | - const auto dxcBuiltDLL = (system::path(_DXC_DLL_).make_preferred()).string(); |
54 | | - res = LoadLibraryExA(dxcBuiltDLL.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH); |
55 | | - } |
56 | | - if (!res) |
57 | | - res = LoadLibraryExA(DXCOMPILER_DLL_NAME.data(), NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); |
58 | | - HRESULT hr = __HrLoadAllImportsForDll(DXCOMPILER_DLL_NAME.data()); |
59 | | - assert(res && SUCCEEDED(hr)); |
60 | | - } |
| 24 | + #ifdef _NBL_PLATFORM_WINDOWS_ |
| 25 | + // TODO: @AnastaZIuk also provide define constants for DXC install dir! |
| 26 | + const HRESULT dxcLoad = CSystemWin32::delayLoadDLL("dxcompiler.dll",{_DXC_DLL_}); |
| 27 | + assert(SUCCEEDED(dxcLoad)); |
| 28 | + #ifdef _NBL_SHARED_BUILD_ |
| 29 | + // if there was no DLL next to the executable, then try from the Nabla build directory |
| 30 | + // else if nothing in the build dir, then try looking for Nabla in the CURRENT BUILD'S INSTALL DIR |
| 31 | + const HRESULT nablaLoad = CSystemWin32::delayLoadDLL(_NABLA_DLL_NAME_,{_NABLA_OUTPUT_DIR_,_NABLA_INSTALL_DIR_}); |
| 32 | + assert(SUCCEEDED(nablaLoad)); |
| 33 | + #endif |
| 34 | + #endif |
61 | 35 | } |
62 | 36 |
|
| 37 | + virtual void setSystem(core::smart_refctd_ptr<nbl::system::ISystem>&& system) = 0; |
| 38 | + |
63 | 39 | void onAppInitialized() |
64 | 40 | { |
65 | 41 | return onAppInitialized_impl(); |
|
0 commit comments