rework gpu selection

This commit is contained in:
Samuliak 2024-12-15 13:18:24 +01:00
parent ba9a9370fe
commit d64e0c9b6f
No known key found for this signature in database
7 changed files with 105 additions and 41 deletions

View file

@ -91,7 +91,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL DebugUtilsCallback(VkDebugUtilsMessageSeverityFla
return VK_FALSE;
}
std::vector<VulkanRenderer::DeviceInfo> VulkanRenderer::GetDevices()
std::vector<std::string> VulkanRenderer::GetDevices()
{
if(!vkEnumerateInstanceVersion)
{
@ -105,7 +105,7 @@ std::vector<VulkanRenderer::DeviceInfo> VulkanRenderer::GetDevices()
apiVersion = VK_API_VERSION_1_1;
}
std::vector<DeviceInfo> result;
std::vector<std::string> result;
std::vector<const char*> requiredExtensions;
requiredExtensions.clear();
@ -168,7 +168,7 @@ std::vector<VulkanRenderer::DeviceInfo> VulkanRenderer::GetDevices()
physDeviceProps.pNext = &physDeviceIDProps;
vkGetPhysicalDeviceProperties2(device, &physDeviceProps);
result.emplace_back(physDeviceProps.properties.deviceName, physDeviceIDProps.deviceUUID);
result.emplace_back(physDeviceProps.properties.deviceName);
}
}
vkDestroySurfaceKHR(instance, surface, nullptr);
@ -181,7 +181,6 @@ std::vector<VulkanRenderer::DeviceInfo> VulkanRenderer::GetDevices()
vkDestroyInstance(instance, nullptr);
return result;
}
void VulkanRenderer::DetermineVendor()
@ -389,8 +388,7 @@ VulkanRenderer::VulkanRenderer()
auto surface = CreateFramebufferSurface(m_instance, gui_getWindowInfo().window_main);
auto& config = GetConfig();
decltype(config.graphic_device_uuid) zero{};
const bool has_device_set = config.graphic_device_uuid != zero;
const bool has_device_set = !config.graphic_device_name.empty();
VkPhysicalDevice fallbackDevice = VK_NULL_HANDLE;
@ -410,7 +408,7 @@ VulkanRenderer::VulkanRenderer()
physDeviceProps.pNext = &physDeviceIDProps;
vkGetPhysicalDeviceProperties2(device, &physDeviceProps);
if (memcmp(config.graphic_device_uuid.data(), physDeviceIDProps.deviceUUID, VK_UUID_SIZE) != 0)
if (config.graphic_device_name != physDeviceProps.properties.deviceName)
continue;
}
@ -423,7 +421,7 @@ VulkanRenderer::VulkanRenderer()
{
cemuLog_log(LogType::Force, "The selected GPU could not be found or is not suitable. Falling back to first available device instead");
m_physicalDevice = fallbackDevice;
config.graphic_device_uuid = {}; // resetting device selection
config.graphic_device_name = ""; // resetting device selection
}
else if (m_physicalDevice == VK_NULL_HANDLE)
{