Skip to content

Commit

Permalink
Use ICD lib_name in error reporting instead of index
Browse files Browse the repository at this point in the history
The index must be referenced against the loader's internal index of each
ICD. Instead, we should print the lib_name in the error message, making
it more clear which driver the error is coming from.
  • Loading branch information
charles-lunarg committed Mar 21, 2024
1 parent acefb06 commit 5fed115
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions loader/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -6135,7 +6135,6 @@ VkResult check_and_add_to_new_phys_devs(struct loader_instance *inst, VkPhysical
VkResult setup_loader_term_phys_devs(struct loader_instance *inst) {
VkResult res = VK_SUCCESS;
struct loader_icd_term *icd_term;
uint32_t icd_idx = 0;
uint32_t windows_sorted_devices_count = 0;
struct loader_icd_physical_devices *windows_sorted_devices_array = NULL;
uint32_t icd_count = 0;
Expand Down Expand Up @@ -6169,21 +6168,22 @@ VkResult setup_loader_term_phys_devs(struct loader_instance *inst) {
// For each ICD, query the number of physical devices, and then get an
// internal value for those physical devices.
icd_term = inst->icd_terms;
uint32_t icd_idx = 0;
while (NULL != icd_term) {
res = icd_term->dispatch.EnumeratePhysicalDevices(icd_term->instance, &icd_phys_dev_array[icd_idx].device_count, NULL);
if (VK_SUCCESS != res) {
loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
"setup_loader_term_phys_devs: Call to ICD %d's \'vkEnumeratePhysicalDevices\' failed with error 0x%08x",
icd_idx, res);
"setup_loader_term_phys_devs: Call to ICD %s's \'vkEnumeratePhysicalDevices\' failed with error 0x%08x",
icd_term->scanned_icd->lib_name, res);
goto out;
}

icd_phys_dev_array[icd_idx].physical_devices =
(VkPhysicalDevice *)loader_stack_alloc(icd_phys_dev_array[icd_idx].device_count * sizeof(VkPhysicalDevice));
if (NULL == icd_phys_dev_array[icd_idx].physical_devices) {
loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
"setup_loader_term_phys_devs: Failed to allocate temporary ICD Physical device array for ICD %d of size %d",
icd_idx, icd_phys_dev_array[icd_idx].device_count);
"setup_loader_term_phys_devs: Failed to allocate temporary ICD Physical device array for ICD %s of size %d",
icd_term->scanned_icd->lib_name, icd_phys_dev_array[icd_idx].device_count);
res = VK_ERROR_OUT_OF_HOST_MEMORY;
goto out;
}
Expand Down Expand Up @@ -6867,7 +6867,7 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumeratePhysicalDeviceGroups(
// For each ICD, query the number of physical device groups, and then get an
// internal value for those physical devices.
icd_term = inst->icd_terms;
for (uint32_t icd_idx = 0; NULL != icd_term; icd_term = icd_term->next, icd_idx++) {
while (NULL != icd_term) {
cur_icd_group_count = 0;

// Get the function pointer to use to call into the ICD. This could be the core or KHR version
Expand All @@ -6883,8 +6883,8 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumeratePhysicalDeviceGroups(
if (res != VK_SUCCESS) {
loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
"terminator_EnumeratePhysicalDeviceGroups: Failed during dispatch call of \'EnumeratePhysicalDevices\' "
"to ICD %d to get plain phys dev count.",
icd_idx);
"to ICD %s to get plain phys dev count.",
icd_term->scanned_icd->lib_name);
continue;
}
} else {
Expand All @@ -6893,12 +6893,13 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumeratePhysicalDeviceGroups(
if (res != VK_SUCCESS) {
loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
"terminator_EnumeratePhysicalDeviceGroups: Failed during dispatch call of "
"\'EnumeratePhysicalDeviceGroups\' to ICD %d to get count.",
icd_idx);
"\'EnumeratePhysicalDeviceGroups\' to ICD %s to get count.",
icd_term->scanned_icd->lib_name);
continue;
}
}
total_count += cur_icd_group_count;
icd_term = icd_term->next;
}

// If GPUs not sorted yet, look through them and generate list of all available GPUs
Expand Down Expand Up @@ -6965,8 +6966,8 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumeratePhysicalDeviceGroups(
if (res != VK_SUCCESS) {
loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
"terminator_EnumeratePhysicalDeviceGroups: Failed during dispatch call of "
"\'EnumeratePhysicalDevices\' to ICD %d to get plain phys dev count.",
icd_idx);
"\'EnumeratePhysicalDevices\' to ICD %s to get plain phys dev count.",
icd_term->scanned_icd->lib_name);
goto out;
}

Expand All @@ -6984,8 +6985,8 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumeratePhysicalDeviceGroups(
if (res != VK_SUCCESS) {
loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
"terminator_EnumeratePhysicalDeviceGroups: Failed during dispatch call of "
"\'EnumeratePhysicalDeviceGroups\' to ICD %d to get group count.",
icd_idx);
"\'EnumeratePhysicalDeviceGroups\' to ICD %s to get group count.",
icd_term->scanned_icd->lib_name);
goto out;
}
if (cur_icd_group_count + count_this_time < *pPhysicalDeviceGroupCount) {
Expand All @@ -6997,8 +6998,8 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumeratePhysicalDeviceGroups(
if (res != VK_SUCCESS) {
loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
"terminator_EnumeratePhysicalDeviceGroups: Failed during dispatch call of "
"\'EnumeratePhysicalDeviceGroups\' to ICD %d to get group information.",
icd_idx);
"\'EnumeratePhysicalDeviceGroups\' to ICD %s to get group information.",
icd_term->scanned_icd->lib_name);
goto out;
}
for (uint32_t group = 0; group < count_this_time; ++group) {
Expand Down Expand Up @@ -7028,8 +7029,8 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumeratePhysicalDeviceGroups(
if (res != VK_SUCCESS) {
loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
"terminator_EnumeratePhysicalDeviceGroups: Failed during dispatch call of "
"\'EnumeratePhysicalDeviceGroups\' to ICD %d to get group information for temp data.",
icd_idx);
"\'EnumeratePhysicalDeviceGroups\' to ICD %s to get group information for temp data.",
icd_term->scanned_icd->lib_name);
goto out;
}
for (uint32_t group = 0; group < count_this_time; ++group) {
Expand All @@ -7042,8 +7043,8 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumeratePhysicalDeviceGroups(
if (VK_SUCCESS != res) {
loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
"terminator_EnumeratePhysicalDeviceGroups: Failed during dispatch call of "
"\'EnumeratePhysicalDeviceGroups\' to ICD %d to get content.",
icd_idx);
"\'EnumeratePhysicalDeviceGroups\' to ICD %s to get content.",
icd_term->scanned_icd->lib_name);
goto out;
}
}
Expand Down

0 comments on commit 5fed115

Please sign in to comment.