[metacity] vulkan: create command pool



commit a3bca526be228f2e56fecb00f5280183a81757e8
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Thu Mar 16 17:27:36 2017 +0200

    vulkan: create command pool

 src/compositor/meta-compositor-vulkan.c |   37 +++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/src/compositor/meta-compositor-vulkan.c b/src/compositor/meta-compositor-vulkan.c
index 1a53554..45d3d30 100644
--- a/src/compositor/meta-compositor-vulkan.c
+++ b/src/compositor/meta-compositor-vulkan.c
@@ -49,6 +49,8 @@ struct _MetaCompositorVulkan
 
   VkQueue                  graphics_queue;
   VkQueue                  present_queue;
+
+  VkCommandPool            command_pool;
 #endif
 };
 
@@ -629,6 +631,32 @@ create_logical_device (MetaCompositorVulkan  *vulkan,
 
   return TRUE;
 }
+
+static gboolean
+create_command_pool (MetaCompositorVulkan  *vulkan,
+                     GError               **error)
+{
+  VkCommandPoolCreateInfo info;
+  VkResult result;
+
+  info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
+  info.pNext = NULL;
+  info.flags = 0;
+  info.queueFamilyIndex = vulkan->graphics_family_index;
+
+  result = vkCreateCommandPool (vulkan->device, &info, NULL,
+                                &vulkan->command_pool);
+
+  if (result != VK_SUCCESS)
+    {
+      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                   "Failed to create command pool");
+
+      return FALSE;
+    }
+
+  return TRUE;
+}
 #endif
 
 static void
@@ -639,6 +667,12 @@ meta_compositor_vulkan_finalize (GObject *object)
 
   vulkan = META_COMPOSITOR_VULKAN (object);
 
+  if (vulkan->command_pool != VK_NULL_HANDLE)
+    {
+      vkDestroyCommandPool (vulkan->device, vulkan->command_pool, NULL);
+      vulkan->command_pool = VK_NULL_HANDLE;
+    }
+
   if (vulkan->device != VK_NULL_HANDLE)
     {
       vkDestroyDevice (vulkan->device, NULL);
@@ -724,6 +758,9 @@ meta_compositor_vulkan_manage (MetaCompositor  *compositor,
   if (!create_logical_device (vulkan, error))
     return FALSE;
 
+  if (!create_command_pool (vulkan, error))
+    return FALSE;
+
   g_timeout_add (10000, (GSourceFunc) not_implemented_cb, vulkan);
 
   return TRUE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]