mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-01-22 09:22:04 +00:00
- improve the queue family selection process to pick first entry in the list over later ones
This commit is contained in:
parent
0be5cc7d1d
commit
954b72915c
1 changed files with 31 additions and 9 deletions
|
@ -120,23 +120,45 @@ void VulkanDevice::SelectPhysicalDevice()
|
||||||
VulkanCompatibleDevice dev;
|
VulkanCompatibleDevice dev;
|
||||||
dev.device = &AvailableDevices[idx];
|
dev.device = &AvailableDevices[idx];
|
||||||
|
|
||||||
int i = 0;
|
// Figure out what can present
|
||||||
for (const auto& queueFamily : info.QueueFamilies)
|
for (int i = 0; i < (int)info.QueueFamilies.size(); i++)
|
||||||
{
|
{
|
||||||
// Only accept a decent GPU for now..
|
VkBool32 presentSupport = false;
|
||||||
|
VkResult result = vkGetPhysicalDeviceSurfaceSupportKHR(info.Device, i, surface, &presentSupport);
|
||||||
|
if (result == VK_SUCCESS && info.QueueFamilies[i].queueCount > 0 && presentSupport)
|
||||||
|
{
|
||||||
|
dev.presentFamily = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look for family that can do both graphics and transfer
|
||||||
|
for (int i = 0; i < (int)info.QueueFamilies.size(); i++)
|
||||||
|
{
|
||||||
|
const auto &queueFamily = info.QueueFamilies[i];
|
||||||
VkQueueFlags gpuFlags = (VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_TRANSFER_BIT);
|
VkQueueFlags gpuFlags = (VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_TRANSFER_BIT);
|
||||||
if (queueFamily.queueCount > 0 && (queueFamily.queueFlags & gpuFlags) == gpuFlags)
|
if (queueFamily.queueCount > 0 && (queueFamily.queueFlags & gpuFlags) == gpuFlags)
|
||||||
{
|
{
|
||||||
dev.graphicsFamily = i;
|
dev.graphicsFamily = i;
|
||||||
dev.transferFamily = i;
|
dev.transferFamily = i;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
VkBool32 presentSupport = false;
|
// OK we didn't find any. Look for any match now.
|
||||||
VkResult result = vkGetPhysicalDeviceSurfaceSupportKHR(info.Device, i, surface, &presentSupport);
|
if (dev.graphicsFamily == -1)
|
||||||
if (result == VK_SUCCESS && queueFamily.queueCount > 0 && presentSupport)
|
{
|
||||||
dev.presentFamily = i;
|
for (int i = 0; i < (int)info.QueueFamilies.size(); i++)
|
||||||
|
{
|
||||||
i++;
|
const auto &queueFamily = info.QueueFamilies[i];
|
||||||
|
if (queueFamily.queueCount > 0)
|
||||||
|
{
|
||||||
|
if (dev.graphicsFamily == -1 && (queueFamily.queueFlags & VK_QUEUE_GRAPHICS_BIT))
|
||||||
|
dev.graphicsFamily = i;
|
||||||
|
if (dev.transferFamily == -1 && (queueFamily.queueFlags & VK_QUEUE_TRANSFER_BIT))
|
||||||
|
dev.transferFamily = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<std::string> requiredExtensionSearch(EnabledDeviceExtensions.begin(), EnabledDeviceExtensions.end());
|
std::set<std::string> requiredExtensionSearch(EnabledDeviceExtensions.begin(), EnabledDeviceExtensions.end());
|
||||||
|
|
Loading…
Reference in a new issue