mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 01:30:38 +00:00
vktrash: add more destruction of vulkan types
This commit is contained in:
parent
d61e771c37
commit
ca38c2f25e
2 changed files with 128 additions and 57 deletions
|
@ -138,58 +138,106 @@ gst_vulkan_trash_list_wait (GList * trash_list, guint64 timeout)
|
||||||
return err == VK_SUCCESS;
|
return err == VK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_buffer_free_info
|
#define FREE_DESTROY_FUNC(func, type, type_name) \
|
||||||
{
|
static void \
|
||||||
GstVulkanCommandPool *pool;
|
G_PASTE(_free_,type_name) (GstVulkanDevice * device, type resource) \
|
||||||
VkCommandBuffer cmd;
|
{ \
|
||||||
};
|
GST_TRACE_OBJECT (device, "Freeing vulkan " G_STRINGIFY (type) " %p", resource); \
|
||||||
|
func (device->device, resource, NULL); \
|
||||||
|
} \
|
||||||
|
GstVulkanTrash * \
|
||||||
|
G_PASTE(gst_vulkan_trash_new_free_,type_name) (GstVulkanFence * fence, \
|
||||||
|
type type_name) \
|
||||||
|
{ \
|
||||||
|
GstVulkanTrash *trash; \
|
||||||
|
g_return_val_if_fail (type_name != NULL, NULL); \
|
||||||
|
trash = gst_vulkan_trash_new (fence, \
|
||||||
|
(GstVulkanTrashNotify) G_PASTE(_free_,type_name), type_name); \
|
||||||
|
return trash; \
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
FREE_DESTROY_FUNC (vkDestroyDescriptorPool, VkDescriptorPool, descriptor_pool)
|
||||||
_free_command_buffer (GstVulkanDevice * device,
|
FREE_DESTROY_FUNC (vkDestroyDescriptorSetLayout, VkDescriptorSetLayout,
|
||||||
struct cmd_buffer_free_info *info)
|
descriptor_set_layout)
|
||||||
{
|
FREE_DESTROY_FUNC (vkDestroyFramebuffer, VkFramebuffer, framebuffer)
|
||||||
vkFreeCommandBuffers (device->device, info->pool->pool, 1, &info->cmd);
|
FREE_DESTROY_FUNC (vkDestroyPipeline, VkPipeline, pipeline)
|
||||||
gst_object_unref (info->pool);
|
FREE_DESTROY_FUNC (vkDestroyPipelineLayout, VkPipelineLayout, pipeline_layout)
|
||||||
|
FREE_DESTROY_FUNC (vkDestroyRenderPass, VkRenderPass, render_pass)
|
||||||
|
FREE_DESTROY_FUNC (vkDestroySemaphore, VkSemaphore, semaphore)
|
||||||
|
FREE_DESTROY_FUNC (vkDestroySampler, VkSampler, sampler)
|
||||||
|
#define FREE_WITH_GST_PARENT(func, type, type_name, parent_type, parent_resource) \
|
||||||
|
struct G_PASTE(free_parent_info_,type_name) \
|
||||||
|
{ \
|
||||||
|
parent_type parent; \
|
||||||
|
type resource; \
|
||||||
|
}; \
|
||||||
|
static void \
|
||||||
|
G_PASTE(_free_,type_name) (GstVulkanDevice * device, struct G_PASTE(free_parent_info_,type_name) *info) \
|
||||||
|
{ \
|
||||||
|
GST_TRACE_OBJECT (device, "Freeing vulkan " G_STRINGIFY (type) " %p", info->resource); \
|
||||||
|
func (device->device, info->parent parent_resource, 1, &info->resource); \
|
||||||
|
gst_object_unref (info->parent); \
|
||||||
|
g_free (info); \
|
||||||
|
} \
|
||||||
|
GstVulkanTrash * \
|
||||||
|
G_PASTE(gst_vulkan_trash_new_free_,type_name) (GstVulkanFence * fence, \
|
||||||
|
parent_type parent, type type_name) \
|
||||||
|
{ \
|
||||||
|
struct G_PASTE(free_parent_info_,type_name) *info; \
|
||||||
|
GstVulkanTrash *trash; \
|
||||||
|
g_return_val_if_fail (type_name != NULL, NULL); \
|
||||||
|
info = g_new0 (struct G_PASTE(free_parent_info_,type_name), 1); \
|
||||||
|
info->parent = gst_object_ref (parent); \
|
||||||
|
info->resource = (gpointer) type_name; \
|
||||||
|
trash = gst_vulkan_trash_new (fence, \
|
||||||
|
(GstVulkanTrashNotify) G_PASTE(_free_,type_name), info); \
|
||||||
|
return trash; \
|
||||||
|
}
|
||||||
|
FREE_WITH_GST_PARENT (vkFreeCommandBuffers, VkCommandBuffer, command_buffer,
|
||||||
|
GstVulkanCommandPool *,->pool)
|
||||||
|
#define FREE_WITH_VK_PARENT(func, type, type_name, parent_type) \
|
||||||
|
struct G_PASTE(free_parent_info_,type_name) \
|
||||||
|
{ \
|
||||||
|
parent_type parent; \
|
||||||
|
type resource; \
|
||||||
|
}; \
|
||||||
|
static void \
|
||||||
|
G_PASTE(_free_,type_name) (GstVulkanDevice * device, struct G_PASTE(free_parent_info_,type_name) *info) \
|
||||||
|
{ \
|
||||||
|
GST_TRACE_OBJECT (device, "Freeing vulkan " G_STRINGIFY (type) " %p", info->resource); \
|
||||||
|
func (device->device, info->parent, 1, &info->resource); \
|
||||||
|
g_free (info); \
|
||||||
|
} \
|
||||||
|
GstVulkanTrash * \
|
||||||
|
G_PASTE(gst_vulkan_trash_new_free_,type_name) (GstVulkanFence * fence, \
|
||||||
|
parent_type parent, type type_name) \
|
||||||
|
{ \
|
||||||
|
struct G_PASTE(free_parent_info_,type_name) *info; \
|
||||||
|
GstVulkanTrash *trash; \
|
||||||
|
g_return_val_if_fail (type_name != NULL, NULL); \
|
||||||
|
info = g_new0 (struct G_PASTE(free_parent_info_,type_name), 1); \
|
||||||
|
/* FIXME: keep parent alive ? */\
|
||||||
|
info->parent = parent; \
|
||||||
|
info->resource = (gpointer) type_name; \
|
||||||
|
trash = gst_vulkan_trash_new (fence, \
|
||||||
|
(GstVulkanTrashNotify) G_PASTE(_free_,type_name), info); \
|
||||||
|
return trash; \
|
||||||
|
}
|
||||||
|
FREE_WITH_VK_PARENT (vkFreeDescriptorSets, VkDescriptorSet, descriptor_set,
|
||||||
|
VkDescriptorPool)
|
||||||
|
|
||||||
g_free (info);
|
static void
|
||||||
|
_trash_object_unref (GstVulkanDevice * device, GstObject * object)
|
||||||
|
{
|
||||||
|
gst_object_unref (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
GstVulkanTrash *
|
GstVulkanTrash *
|
||||||
gst_vulkan_trash_new_free_command_buffer (GstVulkanFence * fence,
|
gst_vulkan_trash_new_object_unref (GstVulkanFence * fence, GstObject * object)
|
||||||
GstVulkanCommandPool * pool, VkCommandBuffer cmd)
|
|
||||||
{
|
{
|
||||||
struct cmd_buffer_free_info *info;
|
|
||||||
GstVulkanTrash *trash;
|
GstVulkanTrash *trash;
|
||||||
|
g_return_val_if_fail (GST_IS_OBJECT (object), NULL);
|
||||||
info = g_new0 (struct cmd_buffer_free_info, 1);
|
|
||||||
info->pool = gst_object_ref (pool);
|
|
||||||
info->cmd = cmd;
|
|
||||||
trash = gst_vulkan_trash_new (fence,
|
trash = gst_vulkan_trash_new (fence,
|
||||||
(GstVulkanTrashNotify) _free_command_buffer, info);
|
(GstVulkanTrashNotify) _trash_object_unref, object);
|
||||||
|
|
||||||
return trash;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_free_semaphore (GstVulkanDevice * device, VkSemaphore * semaphore)
|
|
||||||
{
|
|
||||||
if (semaphore)
|
|
||||||
vkDestroySemaphore (device->device, *semaphore, NULL);
|
|
||||||
|
|
||||||
g_free (semaphore);
|
|
||||||
}
|
|
||||||
|
|
||||||
GstVulkanTrash *
|
|
||||||
gst_vulkan_trash_new_free_semaphore (GstVulkanFence * fence,
|
|
||||||
VkSemaphore semaphore)
|
|
||||||
{
|
|
||||||
VkSemaphore *data;
|
|
||||||
GstVulkanTrash *trash;
|
|
||||||
|
|
||||||
data = g_new0 (VkSemaphore, 1);
|
|
||||||
*data = semaphore;
|
|
||||||
trash = gst_vulkan_trash_new (fence,
|
|
||||||
(GstVulkanTrashNotify) _free_semaphore, data);
|
|
||||||
|
|
||||||
return trash;
|
return trash;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,11 +40,34 @@ struct _GstVulkanTrash
|
||||||
GstVulkanTrash * gst_vulkan_trash_new (GstVulkanFence * fence,
|
GstVulkanTrash * gst_vulkan_trash_new (GstVulkanFence * fence,
|
||||||
GstVulkanTrashNotify notify,
|
GstVulkanTrashNotify notify,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
GstVulkanTrash * gst_vulkan_trash_new_free_command_buffer (GstVulkanFence * fence,
|
|
||||||
GstVulkanCommandPool * pool,
|
GstVulkanTrash * gst_vulkan_trash_new_free_descriptor_pool (GstVulkanFence * fence,
|
||||||
VkCommandBuffer cmd);
|
VkDescriptorPool descriptor_pool);
|
||||||
|
GstVulkanTrash * gst_vulkan_trash_new_free_descriptor_set_layout (GstVulkanFence * fence,
|
||||||
|
VkDescriptorSetLayout descriptor_set_layout);
|
||||||
|
GstVulkanTrash * gst_vulkan_trash_new_free_framebuffer (GstVulkanFence * fence,
|
||||||
|
VkFramebuffer framebuffer);
|
||||||
|
GstVulkanTrash * gst_vulkan_trash_new_free_pipeline (GstVulkanFence * fence,
|
||||||
|
VkPipeline pipeline);
|
||||||
|
GstVulkanTrash * gst_vulkan_trash_new_free_pipeline_layout (GstVulkanFence * fence,
|
||||||
|
VkPipelineLayout pipeline_layout);
|
||||||
|
GstVulkanTrash * gst_vulkan_trash_new_free_render_pass (GstVulkanFence * fence,
|
||||||
|
VkRenderPass render_pass);
|
||||||
|
GstVulkanTrash * gst_vulkan_trash_new_free_sampler (GstVulkanFence * fence,
|
||||||
|
VkSampler sampler);
|
||||||
GstVulkanTrash * gst_vulkan_trash_new_free_semaphore (GstVulkanFence * fence,
|
GstVulkanTrash * gst_vulkan_trash_new_free_semaphore (GstVulkanFence * fence,
|
||||||
VkSemaphore cmd);
|
VkSemaphore semaphore);
|
||||||
|
|
||||||
|
GstVulkanTrash * gst_vulkan_trash_new_free_command_buffer (GstVulkanFence * fence,
|
||||||
|
GstVulkanCommandPool * parent,
|
||||||
|
VkCommandBuffer command_buffer);
|
||||||
|
GstVulkanTrash * gst_vulkan_trash_new_free_descriptor_set (GstVulkanFence * fence,
|
||||||
|
VkDescriptorPool parent,
|
||||||
|
VkDescriptorSet descriptor_set);
|
||||||
|
|
||||||
|
GstVulkanTrash * gst_vulkan_trash_new_object_unref (GstVulkanFence * fence,
|
||||||
|
GstObject * object);
|
||||||
|
|
||||||
void gst_vulkan_trash_free (GstVulkanTrash * trash);
|
void gst_vulkan_trash_free (GstVulkanTrash * trash);
|
||||||
|
|
||||||
GList * gst_vulkan_trash_list_gc (GList * trash_list);
|
GList * gst_vulkan_trash_list_gc (GList * trash_list);
|
||||||
|
|
Loading…
Reference in a new issue