[metacity] vulkan: select physical device and queue families
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] vulkan: select physical device and queue families
- Date: Thu, 16 Mar 2017 13:02:51 +0000 (UTC)
commit 638ef369d9d8c1820c5353fd37aa8ca17a756e35
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Thu Mar 16 14:30:57 2017 +0200
vulkan: select physical device and queue families
src/compositor/meta-compositor-vulkan.c | 44 +++++++++++++++++++++++++++++++
1 files changed, 44 insertions(+), 0 deletions(-)
---
diff --git a/src/compositor/meta-compositor-vulkan.c b/src/compositor/meta-compositor-vulkan.c
index 127b225..c3a1e9d 100644
--- a/src/compositor/meta-compositor-vulkan.c
+++ b/src/compositor/meta-compositor-vulkan.c
@@ -40,6 +40,10 @@ struct _MetaCompositorVulkan
VkDebugReportCallbackEXT debug_callback;
VkSurfaceKHR surface;
+
+ VkPhysicalDevice physical_device;
+ uint32_t graphics_family_index;
+ uint32_t present_family_index;
#endif
};
@@ -443,6 +447,8 @@ enumerate_physical_devices (MetaCompositorVulkan *vulkan,
{
uint32_t n_family_properties;
VkQueueFamilyProperties *family_properties;
+ uint32_t graphics_family_index;
+ uint32_t present_family_index;
uint32_t j;
if (meta_check_debug_flags (META_DEBUG_VULKAN))
@@ -471,6 +477,9 @@ enumerate_physical_devices (MetaCompositorVulkan *vulkan,
&n_family_properties,
family_properties);
+ graphics_family_index = n_family_properties;
+ present_family_index = n_family_properties;
+
for (j = 0; j < n_family_properties; j++)
{
if (meta_check_debug_flags (META_DEBUG_VULKAN))
@@ -484,6 +493,33 @@ enumerate_physical_devices (MetaCompositorVulkan *vulkan,
g_free (operations);
}
+
+ if (family_properties[j].queueFlags & VK_QUEUE_GRAPHICS_BIT &&
+ graphics_family_index == n_family_properties)
+ {
+ graphics_family_index = j;
+ }
+
+ if (present_family_index == n_family_properties)
+ {
+ VkBool32 supported;
+
+ result = vkGetPhysicalDeviceSurfaceSupportKHR (devices[i], j,
+ vulkan->surface,
+ &supported);
+
+ if (result == VK_SUCCESS && supported)
+ present_family_index = j;
+ }
+ }
+
+ if (graphics_family_index != n_family_properties &&
+ present_family_index != n_family_properties &&
+ vulkan->physical_device == VK_NULL_HANDLE)
+ {
+ vulkan->physical_device = devices[i];
+ vulkan->graphics_family_index = graphics_family_index;
+ vulkan->present_family_index = present_family_index;
}
g_free (family_properties);
@@ -493,6 +529,14 @@ enumerate_physical_devices (MetaCompositorVulkan *vulkan,
g_free (devices);
+ if (vulkan->physical_device == VK_NULL_HANDLE)
+ {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "Failed to find a suitable GPU");
+
+ return FALSE;
+ }
+
return TRUE;
}
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]