[gtk/wip/otte/paintable: 12/15] vulkan: Keep track of command buffers
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/paintable: 12/15] vulkan: Keep track of command buffers
- Date: Sat, 17 Feb 2018 06:52:09 +0000 (UTC)
commit aff8e75ecfba141b7f4f67678c608c649fa02e70
Author: Benjamin Otte <otte redhat com>
Date: Sat Feb 17 07:14:04 2018 +0100
vulkan: Keep track of command buffers
Fixes a rather large memleak.
gsk/vulkan/gskvulkancommandpool.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
---
diff --git a/gsk/vulkan/gskvulkancommandpool.c b/gsk/vulkan/gskvulkancommandpool.c
index bcba6a9fc1..03d4bdc6ed 100644
--- a/gsk/vulkan/gskvulkancommandpool.c
+++ b/gsk/vulkan/gskvulkancommandpool.c
@@ -8,6 +8,7 @@ struct _GskVulkanCommandPool
GdkVulkanContext *vulkan;
VkCommandPool vk_command_pool;
+ GPtrArray *buffers;
};
GskVulkanCommandPool *
@@ -28,12 +29,28 @@ gsk_vulkan_command_pool_new (GdkVulkanContext *context)
NULL,
&self->vk_command_pool);
+ self->buffers = g_ptr_array_new ();
+
return self;
}
+static void
+gsk_vulkan_command_pool_free_buffers (GskVulkanCommandPool *self)
+{
+ vkFreeCommandBuffers (gdk_vulkan_context_get_device (self->vulkan),
+ self->vk_command_pool,
+ self->buffers->len,
+ (VkCommandBuffer *) self->buffers->pdata);
+
+ g_ptr_array_set_size (self->buffers, 0);
+}
+
void
gsk_vulkan_command_pool_free (GskVulkanCommandPool *self)
{
+ gsk_vulkan_command_pool_free_buffers (self);
+ g_ptr_array_unref (self->buffers);
+
vkDestroyCommandPool (gdk_vulkan_context_get_device (self->vulkan),
self->vk_command_pool,
NULL);
@@ -44,6 +61,8 @@ gsk_vulkan_command_pool_free (GskVulkanCommandPool *self)
void
gsk_vulkan_command_pool_reset (GskVulkanCommandPool *self)
{
+ gsk_vulkan_command_pool_free_buffers (self);
+
GSK_VK_CHECK (vkResetCommandPool, gdk_vulkan_context_get_device (self->vulkan),
self->vk_command_pool,
0);
@@ -62,6 +81,7 @@ gsk_vulkan_command_pool_get_buffer (GskVulkanCommandPool *self)
.commandBufferCount = 1,
},
&command_buffer);
+ g_ptr_array_add (self->buffers, command_buffer);
GSK_VK_CHECK (vkBeginCommandBuffer, command_buffer,
&(VkCommandBufferBeginInfo) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]