Skip to content

Commit 12427a1

Browse files
committed
Merge branch 'hlsl-compiler-impl' of github.com:Devsh-Graphics-Programming/Nabla into hlsl-compiler-impl
2 parents 5095747 + 20eb1d7 commit 12427a1

File tree

2 files changed

+37
-13
lines changed

2 files changed

+37
-13
lines changed

cmake/common.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ macro(nbl_create_executable_project _EXTRA_SOURCES _EXTRA_OPTIONS _EXTRA_INCLUDE
6060
else()
6161
set_property(TARGET ${EXECUTABLE_NAME} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
6262
endif()
63+
64+
if(WIN32 AND MSVC)
65+
target_link_options(${EXECUTABLE_NAME} PUBLIC "/DELAYLOAD:dxcompiler.dll")
66+
target_compile_definitions(${EXECUTABLE_NAME} PUBLIC
67+
_DXC_DLL_="${DXC_DLL}"
68+
)
69+
endif()
6370
endif()
6471

6572
# EXTRA_SOURCES is var containing non-common names of sources (if any such sources, then EXTRA_SOURCES must be set before including this cmake code)

include/nbl/system/IApplicationFramework.h

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,39 @@ class NBL_API IApplicationFramework
2525
localInputCWD(_localInputCWD), localOutputCWD(_localOutputCWD), sharedInputCWD(_sharedInputCWD), sharedOutputCWD(_sharedOutputCWD)
2626
{
2727
#if defined(_NBL_PLATFORM_WINDOWS_) && defined(_NBL_SHARED_BUILD_)
28-
HMODULE res = LoadLibraryExA(_NABLA_DLL_NAME_, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR);
29-
if (!res)
3028
{
31-
const auto nablaBuiltDLL = (system::path(_NABLA_OUTPUT_DIR_).make_preferred() / _NABLA_DLL_NAME_).string();
32-
res = LoadLibraryExA(nablaBuiltDLL.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
33-
}
34-
if (!res)
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+
3547
{
36-
const auto nablaInstalledDLL = (system::path(_NABLA_INSTALL_DIR_).make_preferred() / _NABLA_DLL_NAME_).string();
37-
res = LoadLibraryExA(nablaInstalledDLL.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
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));
3860
}
39-
if (!res)
40-
res = LoadLibraryExA(_NABLA_DLL_NAME_, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
41-
HRESULT hr = __HrLoadAllImportsForDll(_NABLA_DLL_NAME_);
42-
assert(res && SUCCEEDED(hr));
43-
#endif // _NBL_PLATFORM_WINDOWS_ && _NBL_SHARED_BUILD_
4461
}
4562

4663
void onAppInitialized()

0 commit comments

Comments
 (0)