Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/CIL/common/directml/adapter_enumeration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,12 @@ std::vector<AdapterInfo> EnumerateDirectMLAdapters(
const std::string& directml_directory) {
LibraryPathHandle path_handle;

if (!directml_directory.empty()) {
// Only add to DLL search path if directory is not empty and contains actual DLL files
// Skip for current directory "." as it may interfere with system DLL loading
if (!directml_directory.empty() &&
fs::exists(fs::path(directml_directory) / "DirectML.dll")) {
path_handle = AddLibraryPath(directml_directory);
if (!path_handle.IsValid()) return {};
// Don't fail if AddLibraryPath returns invalid handle, just proceed without it
};

ScopeExit library_path_cleanup([path_handle]() {
Expand Down Expand Up @@ -239,9 +242,12 @@ std::vector<AdapterInfo> EnumerateDXCoreAdapters(
const std::string& dxcore_directory) {
LibraryPathHandle path_handle;

if (!dxcore_directory.empty()) {
// Only add to DLL search path if directory is not empty and contains actual DLL files
// Skip for current directory "." as it may interfere with system DLL loading
if (!dxcore_directory.empty() &&
fs::exists(fs::path(dxcore_directory) / "DXCore.dll")) {
path_handle = AddLibraryPath(dxcore_directory);
if (!path_handle.IsValid()) return {};
// Don't fail if AddLibraryPath returns invalid handle, just proceed without it
};

ScopeExit library_path_cleanup([path_handle]() {
Expand Down Expand Up @@ -367,4 +373,4 @@ const DeviceEnumeration::DeviceList& DeviceEnumeration::EnumerateDevices(
} // namespace common
} // namespace cil

#endif
#endif