diff --git a/docs/envvars.rst b/docs/envvars.rst index 36390855366..2ee7ce10b04 100644 --- a/docs/envvars.rst +++ b/docs/envvars.rst @@ -337,10 +337,18 @@ Core Mesa environment variables them to use a submit thread from the beginning, regardless of whether or not they ever see a wait-before-signal condition. +.. envvar:: MESA_VK_DEVICE_SELECT_DEBUG + + print debug info about device selection decision-making + .. envvar:: MESA_LOADER_DRIVER_OVERRIDE chooses a different driver binary such as ``etnaviv`` or ``zink``. +.. envvar:: DRI_PRIME_DEBUG + + print debug info about device selection decision-making + .. envvar:: DRI_PRIME the default GPU is the one used by Wayland/Xorg or the one connected to a diff --git a/src/vulkan/device-select-layer/device_select_layer.c b/src/vulkan/device-select-layer/device_select_layer.c index a25d0690891..ac9fe8826c1 100644 --- a/src/vulkan/device-select-layer/device_select_layer.c +++ b/src/vulkan/device-select-layer/device_select_layer.c @@ -542,19 +542,21 @@ static VkResult device_select_EnumeratePhysicalDevices(VkInstance instance, free(extensions); } } - if (selection && strcmp(selection, "list") == 0) { + if (should_debug_device_selection() || (selection && strcmp(selection, "list") == 0)) { fprintf(stderr, "selectable devices:\n"); for (unsigned i = 0; i < physical_device_count; ++i) print_gpu(info, i, physical_devices[i]); - exit(0); - } else { - unsigned selected_index = get_default_device(info, selection, physical_device_count, physical_devices); - selected_physical_device_count = physical_device_count; - selected_physical_devices[0] = physical_devices[selected_index]; - for (unsigned i = 0; i < physical_device_count - 1; ++i) { - unsigned this_idx = i < selected_index ? i : i + 1; - selected_physical_devices[i + 1] = physical_devices[this_idx]; - } + + if (selection && strcmp(selection, "list") == 0) + exit(0); + } + + unsigned selected_index = get_default_device(info, selection, physical_device_count, physical_devices); + selected_physical_device_count = physical_device_count; + selected_physical_devices[0] = physical_devices[selected_index]; + for (unsigned i = 0; i < physical_device_count - 1; ++i) { + unsigned this_idx = i < selected_index ? i : i + 1; + selected_physical_devices[i + 1] = physical_devices[this_idx]; } if (selected_physical_device_count == 0) {