Skip to content

Commit 0db9a0d

Browse files
Remove duplicate driver workaround for macOS
On macOS, applications can bundle drivers with themselves. When they do this and also install the same driver to a global location, the loader will load 2 separate drivers which happen to be the same binary, causing the linker to emit warnings. The fix was to simply only load one driver if the app was bundled. Because there was only one macOS driver available, this worked. Now that both KosmicKrisp and LavaPipe are available, this workaround is no longer appropriate. If apps bundle multiple drivers, they would be unable to use more than 1.
1 parent 918e869 commit 0db9a0d

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

loader/loader.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3354,8 +3354,7 @@ VkResult prepend_if_manifest_file(const struct loader_instance *inst, const char
33543354

33553355
// Add any files found in the search_path. If any path in the search path points to a specific JSON, attempt to
33563356
// only open that one JSON. Otherwise, if the path is a folder, search the folder for JSON files.
3357-
VkResult add_data_files(const struct loader_instance *inst, char *search_path, struct loader_string_list *out_files,
3358-
bool use_first_found_manifest) {
3357+
VkResult add_data_files(const struct loader_instance *inst, char *search_path, struct loader_string_list *out_files) {
33593358
VkResult vk_result = VK_SUCCESS;
33603359
char full_path[2048];
33613360
#if !defined(_WIN32)
@@ -3442,9 +3441,6 @@ VkResult add_data_files(const struct loader_instance *inst, char *search_path, s
34423441
goto out;
34433442
}
34443443
}
3445-
if (use_first_found_manifest && out_files->count > 0) {
3446-
break;
3447-
}
34483444
}
34493445

34503446
out:
@@ -3463,7 +3459,6 @@ VkResult read_data_files_in_search_paths(const struct loader_instance *inst, enu
34633459
size_t search_path_size = 0;
34643460
char *search_path = NULL;
34653461
char *cur_path_ptr = NULL;
3466-
bool use_first_found_manifest = false;
34673462
#if COMMON_UNIX_PLATFORMS
34683463
const char *relative_location = NULL; // Only used on unix platforms
34693464
size_t rel_size = 0; // unused in windows, dont declare so no compiler warnings are generated
@@ -3684,9 +3679,6 @@ VkResult read_data_files_in_search_paths(const struct loader_instance *inst, enu
36843679
memcpy(cur_path_ptr, relative_location, rel_size);
36853680
cur_path_ptr += rel_size;
36863681
*cur_path_ptr++ = PATH_SEPARATOR;
3687-
if (manifest_type == LOADER_DATA_FILE_MANIFEST_DRIVER) {
3688-
use_first_found_manifest = true;
3689-
}
36903682
}
36913683
CFRelease(ref);
36923684
}
@@ -3781,7 +3773,7 @@ VkResult read_data_files_in_search_paths(const struct loader_instance *inst, enu
37813773
}
37823774

37833775
// Now, parse the paths and add any manifest files found in them.
3784-
vk_result = add_data_files(inst, search_path, out_files, use_first_found_manifest);
3776+
vk_result = add_data_files(inst, search_path, out_files);
37853777

37863778
if (log_flags != 0 && out_files->count > 0) {
37873779
loader_log(inst, log_flags, 0, " Found the following files:");

loader/loader.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,7 @@ VkStringErrorFlags vk_string_validate(const int max_length, const char *char_arr
228228
char *loader_get_next_path(char *path);
229229
VkResult add_if_manifest_file(const struct loader_instance *inst, const char *file_name, struct loader_string_list *out_files);
230230
VkResult prepend_if_manifest_file(const struct loader_instance *inst, const char *file_name, struct loader_string_list *out_files);
231-
VkResult add_data_files(const struct loader_instance *inst, char *search_path, struct loader_string_list *out_files,
232-
bool use_first_found_manifest);
231+
VkResult add_data_files(const struct loader_instance *inst, char *search_path, struct loader_string_list *out_files);
233232

234233
loader_api_version loader_make_version(uint32_t version);
235234
loader_api_version loader_combine_version(uint32_t major, uint32_t minor, uint32_t patch);

loader/loader_windows.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ VkResult windows_read_data_files_in_registry(const struct loader_instance *inst,
788788
}
789789

790790
// Now, parse the paths and add any manifest files found in them.
791-
vk_result = add_data_files(inst, search_path, out_files, false);
791+
vk_result = add_data_files(inst, search_path, out_files);
792792

793793
out:
794794

tests/loader_regression_tests.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4458,11 +4458,13 @@ TEST(ManifestDiscovery, AppleBundles) {
44584458
InstWrapper inst{env.vulkan_functions};
44594459
ASSERT_NO_FATAL_FAILURE(inst.CheckCreate());
44604460
auto physical_devices = inst.GetPhysDevs();
4461-
ASSERT_EQ(1, physical_devices.size());
4461+
ASSERT_EQ(2, physical_devices.size());
44624462

4463-
// Verify that this is the 'right' GPU, aka the one from the bundle
4463+
// Should get both GPUs, in reverse order to driver enumeration (due to enumerating the last driver first)
44644464
VkPhysicalDeviceProperties props{};
44654465
inst->vkGetPhysicalDeviceProperties(physical_devices[0], &props);
4466+
ASSERT_EQ(test_physical_device_1.properties.deviceID, props.deviceID);
4467+
inst->vkGetPhysicalDeviceProperties(physical_devices[1], &props);
44664468
ASSERT_EQ(test_physical_device_0.properties.deviceID, props.deviceID);
44674469
}
44684470

0 commit comments

Comments
 (0)