aux/vk: Print available GPUs with XRT_COMPOSITOR_PRINT_DEBUG

Useful for finding out a gpu index to use for XRT_COMPOSITOR_FORCE_GPU_INDEX.
This commit is contained in:
Christoph Haag 2020-05-05 01:06:11 +02:00
parent d95c77ad54
commit 344846b3e2

View file

@ -784,6 +784,28 @@ vk_get_device_functions(struct vk_bundle *vk)
}
static void
vk_print_device_info_debug(struct vk_bundle *vk,
VkPhysicalDeviceProperties *pdp,
uint32_t gpu_index,
const char *title)
{
VK_DEBUG(vk,
"%s"
"\tname: %s\n"
"\tvendor: 0x%04x\n"
"\tproduct: 0x%04x\n"
"\tapiVersion: %u.%u.%u\n"
"\tdriverVersion: %u.%u.%u",
title, pdp->deviceName, pdp->vendorID, pdp->deviceID,
VK_VERSION_MAJOR(pdp->apiVersion),
VK_VERSION_MINOR(pdp->apiVersion),
VK_VERSION_PATCH(pdp->apiVersion),
VK_VERSION_MAJOR(pdp->driverVersion),
VK_VERSION_MINOR(pdp->driverVersion),
VK_VERSION_PATCH(pdp->driverVersion));
}
/*
*
* Creation code.
@ -828,12 +850,18 @@ vk_select_physical_device(struct vk_bundle *vk, int forced_index)
VK_DEBUG(vk, "Forced use of Vulkan device index %d.",
gpu_index);
} else {
VK_DEBUG(vk, "Available GPUs");
// as a first-step to 'intelligent' selection, prefer a
// 'discrete' gpu if it is present
for (uint32_t i = 0; i < gpu_count; i++) {
VkPhysicalDeviceProperties pdp;
vk->vkGetPhysicalDeviceProperties(physical_devices[i],
&pdp);
char title[20];
snprintf(title, 20, "GPU index %d\n", i);
vk_print_device_info_debug(vk, &pdp, i, title);
if (pdp.deviceType ==
VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) {
gpu_index = i;
@ -843,23 +871,10 @@ vk_select_physical_device(struct vk_bundle *vk, int forced_index)
vk->physical_device = physical_devices[gpu_index];
// Debug print info.
VkPhysicalDeviceProperties pdp;
vk->vkGetPhysicalDeviceProperties(physical_devices[gpu_index], &pdp);
VK_DEBUG(vk,
"Selected device:\n"
"\tname: %s\n"
"\tvendor: 0x%04x\n"
"\tproduct: 0x%04x\n"
"\tapiVersion: %u.%u.%u\n"
"\tdriverVersion: %u.%u.%u",
pdp.deviceName, pdp.vendorID, pdp.deviceID,
VK_VERSION_MAJOR(pdp.apiVersion),
VK_VERSION_MINOR(pdp.apiVersion),
VK_VERSION_PATCH(pdp.apiVersion),
VK_VERSION_MAJOR(pdp.driverVersion),
VK_VERSION_MINOR(pdp.driverVersion),
VK_VERSION_PATCH(pdp.driverVersion));
vk_print_device_info_debug(vk, &pdp, gpu_index, "Selected device:\n");
// Fill out the device memory props as well.
vk->vkGetPhysicalDeviceMemoryProperties(vk->physical_device,