MCPcopy Create free account
hub / github.com/SaschaWillems/VulkanCapsViewer / getGPUs

Method getGPUs

vulkanCapsViewer.cpp:1021–1070  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1019}
1020
1021void VulkanCapsViewer::getGPUs()
1022{
1023 VkResult vkRes;
1024 uint32_t numGPUs;
1025
1026 // Enumerate devices
1027 vkRes = vkEnumeratePhysicalDevices(vulkanContext.instance, &numGPUs, NULL);
1028 if (vkRes != VK_SUCCESS)
1029 {
1030 QMessageBox::warning(this, tr("Error"), "Could not enumerate device count!");
1031 return;
1032 }
1033 std::vector<VkPhysicalDevice> vulkanDevices;
1034 vulkanDevices.resize(numGPUs);
1035
1036 vkRes = vkEnumeratePhysicalDevices(vulkanContext.instance, &numGPUs, &vulkanDevices.front());
1037 if (vkRes != VK_SUCCESS)
1038 {
1039 QMessageBox::warning(this, tr("Error"), "Could not enumerate physical devices!");
1040 return;
1041 }
1042
1043 vulkanGPUs.resize(numGPUs);
1044
1045 for (uint32_t i = 0; i < numGPUs; i++)
1046 {
1047 getGPUinfo(&vulkanGPUs[i], i, vulkanDevices[i]);
1048 }
1049
1050 ui.comboBoxGPU->clear();
1051 for (auto& GPU : vulkanGPUs)
1052 {
1053 QString deviceName = QString::fromStdString("[GPU" + std::to_string(GPU.id) + "] " + GPU.props.deviceName);
1054 ui.comboBoxGPU->addItem(deviceName);
1055 }
1056
1057 if (vulkanGPUs.size() > 0)
1058 {
1059 displayDevice(0);
1060 }
1061 else
1062 {
1063 QMessageBox::warning(this, tr("Error"), "Could not find a GPU with Vulkan support!");
1064 }
1065
1066 // Only display device selection of more than once device is present (Android only)
1067#ifdef __ANDROID__
1068 ui.widgetDeviceSelection->setVisible(vulkanGPUs.size() > 1);
1069#endif
1070}
1071
1072void VulkanCapsViewer::connectFilterAndModel(QStandardItemModel& model, CustomFilterProxyModel& filter)
1073{

Callers

nothing calls this directly

Calls 1

to_stringFunction · 0.85

Tested by

no test coverage detected