mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
vulkan/fence: add always-signalled fence type
Allows a cleaner control flow when there is no fence available for use with the trash list. An always signalled fence type will always return TRUE for gst_vulkan_fence_is_signalled.
This commit is contained in:
parent
212b313e29
commit
1c89096b4f
6 changed files with 211 additions and 211 deletions
|
@ -1498,6 +1498,7 @@ gst_vulkan_color_convert_set_caps (GstBaseTransform * bt, GstCaps * in_caps,
|
|||
GstVulkanColorConvert *conv = GST_VULKAN_COLOR_CONVERT (bt);
|
||||
GstVulkanFullScreenRender *render = GST_VULKAN_FULL_SCREEN_RENDER (bt);
|
||||
GstVideoInfo in_info, out_info;
|
||||
GstVulkanFence *last_fence;
|
||||
int i;
|
||||
|
||||
conv->current_shader = NULL;
|
||||
|
@ -1531,28 +1532,24 @@ gst_vulkan_color_convert_set_caps (GstBaseTransform * bt, GstCaps * in_caps,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (render->last_fence) {
|
||||
if (conv->descriptor_pool)
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_descriptor_pool (gst_vulkan_fence_ref
|
||||
(render->last_fence), conv->descriptor_pool));
|
||||
conv->descriptor_set = VK_NULL_HANDLE;
|
||||
conv->descriptor_pool = VK_NULL_HANDLE;
|
||||
if (conv->uniform)
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_mini_object_unref (gst_vulkan_fence_ref
|
||||
(render->last_fence), (GstMiniObject *) conv->uniform));
|
||||
conv->uniform = NULL;
|
||||
} else {
|
||||
if (conv->descriptor_pool)
|
||||
vkDestroyDescriptorPool (render->device->device,
|
||||
conv->descriptor_pool, NULL);
|
||||
conv->descriptor_set = VK_NULL_HANDLE;
|
||||
conv->descriptor_pool = VK_NULL_HANDLE;
|
||||
if (conv->uniform)
|
||||
gst_memory_unref (conv->uniform);
|
||||
conv->uniform = NULL;
|
||||
}
|
||||
if (render->last_fence)
|
||||
last_fence = gst_vulkan_fence_ref (render->last_fence);
|
||||
else
|
||||
last_fence = gst_vulkan_fence_new_always_signalled (render->device);
|
||||
|
||||
if (conv->descriptor_pool)
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_descriptor_pool (gst_vulkan_fence_ref
|
||||
(last_fence), conv->descriptor_pool));
|
||||
conv->descriptor_set = VK_NULL_HANDLE;
|
||||
conv->descriptor_pool = VK_NULL_HANDLE;
|
||||
if (conv->uniform)
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_mini_object_unref (gst_vulkan_fence_ref
|
||||
(last_fence), (GstMiniObject *) conv->uniform));
|
||||
conv->uniform = NULL;
|
||||
|
||||
gst_vulkan_fence_unref (last_fence);
|
||||
|
||||
if (!GST_BASE_TRANSFORM_CLASS (parent_class)->set_caps (bt, in_caps,
|
||||
out_caps))
|
||||
|
@ -1575,45 +1572,40 @@ gst_vulkan_color_convert_stop (GstBaseTransform * bt)
|
|||
GstVulkanColorConvert *conv = GST_VULKAN_COLOR_CONVERT (bt);
|
||||
GstVulkanFullScreenRender *render = GST_VULKAN_FULL_SCREEN_RENDER (bt);
|
||||
|
||||
conv->current_shader = NULL;
|
||||
|
||||
if (render->device) {
|
||||
if (render->last_fence) {
|
||||
if (conv->descriptor_pool)
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_descriptor_pool (gst_vulkan_fence_ref
|
||||
(render->last_fence), conv->descriptor_pool));
|
||||
conv->descriptor_set = VK_NULL_HANDLE;
|
||||
conv->descriptor_pool = VK_NULL_HANDLE;
|
||||
if (conv->sampler)
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_sampler (gst_vulkan_fence_ref
|
||||
(render->last_fence), conv->sampler));
|
||||
conv->sampler = VK_NULL_HANDLE;
|
||||
if (conv->uniform)
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_mini_object_unref (gst_vulkan_fence_ref
|
||||
(render->last_fence), (GstMiniObject *) conv->uniform));
|
||||
conv->uniform = VK_NULL_HANDLE;
|
||||
} else {
|
||||
if (conv->descriptor_pool)
|
||||
vkDestroyDescriptorPool (render->device->device,
|
||||
conv->descriptor_pool, NULL);
|
||||
conv->descriptor_set = VK_NULL_HANDLE;
|
||||
conv->descriptor_pool = VK_NULL_HANDLE;
|
||||
if (conv->sampler)
|
||||
vkDestroySampler (render->device->device, conv->sampler, NULL);
|
||||
conv->sampler = VK_NULL_HANDLE;
|
||||
if (conv->uniform)
|
||||
gst_memory_unref (conv->uniform);
|
||||
conv->uniform = VK_NULL_HANDLE;
|
||||
}
|
||||
GstVulkanFence *last_fence;
|
||||
|
||||
if (render->last_fence)
|
||||
last_fence = gst_vulkan_fence_ref (render->last_fence);
|
||||
else
|
||||
last_fence = gst_vulkan_fence_new_always_signalled (render->device);
|
||||
|
||||
if (conv->descriptor_pool)
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_descriptor_pool (gst_vulkan_fence_ref
|
||||
(last_fence), conv->descriptor_pool));
|
||||
conv->descriptor_set = VK_NULL_HANDLE;
|
||||
conv->descriptor_pool = VK_NULL_HANDLE;
|
||||
if (conv->sampler)
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_sampler (gst_vulkan_fence_ref
|
||||
(last_fence), conv->sampler));
|
||||
conv->sampler = VK_NULL_HANDLE;
|
||||
if (conv->uniform)
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_mini_object_unref (gst_vulkan_fence_ref
|
||||
(last_fence), (GstMiniObject *) conv->uniform));
|
||||
conv->uniform = NULL;
|
||||
|
||||
gst_vulkan_fence_unref (last_fence);
|
||||
}
|
||||
|
||||
if (conv->cmd_pool)
|
||||
gst_object_unref (conv->cmd_pool);
|
||||
conv->cmd_pool = NULL;
|
||||
|
||||
conv->current_shader = NULL;
|
||||
|
||||
return GST_BASE_TRANSFORM_CLASS (parent_class)->stop (bt);
|
||||
}
|
||||
|
||||
|
|
|
@ -554,6 +554,7 @@ gst_vulkan_full_screen_render_set_caps (GstBaseTransform * bt,
|
|||
GstCaps * in_caps, GstCaps * out_caps)
|
||||
{
|
||||
GstVulkanFullScreenRender *render = GST_VULKAN_FULL_SCREEN_RENDER (bt);
|
||||
GstVulkanFence *last_fence;
|
||||
|
||||
if (!gst_video_info_from_caps (&render->in_info, in_caps))
|
||||
return FALSE;
|
||||
|
@ -563,51 +564,37 @@ gst_vulkan_full_screen_render_set_caps (GstBaseTransform * bt,
|
|||
gst_caps_replace (&render->in_caps, in_caps);
|
||||
gst_caps_replace (&render->out_caps, out_caps);
|
||||
|
||||
if (render->last_fence) {
|
||||
if (render->descriptor_set_layout) {
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_descriptor_set_layout (gst_vulkan_fence_ref
|
||||
(render->last_fence), render->descriptor_set_layout));
|
||||
render->descriptor_set_layout = VK_NULL_HANDLE;
|
||||
}
|
||||
if (render->pipeline_layout) {
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_pipeline_layout (gst_vulkan_fence_ref
|
||||
(render->last_fence), render->pipeline_layout));
|
||||
render->pipeline_layout = VK_NULL_HANDLE;
|
||||
}
|
||||
if (render->render_pass) {
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_render_pass (gst_vulkan_fence_ref
|
||||
(render->last_fence), render->render_pass));
|
||||
render->render_pass = VK_NULL_HANDLE;
|
||||
}
|
||||
if (render->graphics_pipeline) {
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_pipeline (gst_vulkan_fence_ref
|
||||
(render->last_fence), render->graphics_pipeline));
|
||||
render->graphics_pipeline = VK_NULL_HANDLE;
|
||||
}
|
||||
} else {
|
||||
if (render->graphics_pipeline)
|
||||
vkDestroyPipeline (render->device->device,
|
||||
render->graphics_pipeline, NULL);
|
||||
render->graphics_pipeline = VK_NULL_HANDLE;
|
||||
if (render->last_fence)
|
||||
last_fence = gst_vulkan_fence_ref (render->last_fence);
|
||||
else
|
||||
last_fence = gst_vulkan_fence_new_always_signalled (render->device);
|
||||
|
||||
if (render->pipeline_layout)
|
||||
vkDestroyPipelineLayout (render->device->device,
|
||||
render->pipeline_layout, NULL);
|
||||
render->pipeline_layout = VK_NULL_HANDLE;
|
||||
|
||||
if (render->render_pass)
|
||||
vkDestroyRenderPass (render->device->device, render->render_pass, NULL);
|
||||
render->render_pass = VK_NULL_HANDLE;
|
||||
|
||||
if (render->descriptor_set_layout)
|
||||
vkDestroyDescriptorSetLayout (render->device->device,
|
||||
render->descriptor_set_layout, NULL);
|
||||
if (render->descriptor_set_layout) {
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_descriptor_set_layout (gst_vulkan_fence_ref
|
||||
(last_fence), render->descriptor_set_layout));
|
||||
render->descriptor_set_layout = VK_NULL_HANDLE;
|
||||
}
|
||||
if (render->pipeline_layout) {
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_pipeline_layout (gst_vulkan_fence_ref
|
||||
(last_fence), render->pipeline_layout));
|
||||
render->pipeline_layout = VK_NULL_HANDLE;
|
||||
}
|
||||
if (render->render_pass) {
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_render_pass (gst_vulkan_fence_ref
|
||||
(last_fence), render->render_pass));
|
||||
render->render_pass = VK_NULL_HANDLE;
|
||||
}
|
||||
if (render->graphics_pipeline) {
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_pipeline (gst_vulkan_fence_ref
|
||||
(last_fence), render->graphics_pipeline));
|
||||
render->graphics_pipeline = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
gst_vulkan_fence_unref (last_fence);
|
||||
|
||||
if (!(render->descriptor_set_layout = _create_descriptor_set_layout (render)))
|
||||
return FALSE;
|
||||
|
@ -767,42 +754,35 @@ gst_vulkan_full_screen_render_stop (GstBaseTransform * bt)
|
|||
GstVulkanFullScreenRender *render = GST_VULKAN_FULL_SCREEN_RENDER (bt);
|
||||
|
||||
if (render->device) {
|
||||
if (render->last_fence) {
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_pipeline (gst_vulkan_fence_ref
|
||||
(render->last_fence), render->graphics_pipeline));
|
||||
render->graphics_pipeline = VK_NULL_HANDLE;
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_pipeline_layout (gst_vulkan_fence_ref
|
||||
(render->last_fence), render->pipeline_layout));
|
||||
render->pipeline_layout = VK_NULL_HANDLE;
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_render_pass (gst_vulkan_fence_ref
|
||||
(render->last_fence), render->render_pass));
|
||||
render->render_pass = VK_NULL_HANDLE;
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_descriptor_set_layout (gst_vulkan_fence_ref
|
||||
(render->last_fence), render->descriptor_set_layout));
|
||||
render->descriptor_set_layout = VK_NULL_HANDLE;
|
||||
GstVulkanFence *last_fence;
|
||||
|
||||
if (render->last_fence)
|
||||
last_fence = gst_vulkan_fence_ref (render->last_fence);
|
||||
else
|
||||
last_fence = gst_vulkan_fence_new_always_signalled (render->device);
|
||||
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_pipeline (gst_vulkan_fence_ref
|
||||
(last_fence), render->graphics_pipeline));
|
||||
render->graphics_pipeline = VK_NULL_HANDLE;
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_pipeline_layout (gst_vulkan_fence_ref
|
||||
(last_fence), render->pipeline_layout));
|
||||
render->pipeline_layout = VK_NULL_HANDLE;
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_render_pass (gst_vulkan_fence_ref
|
||||
(last_fence), render->render_pass));
|
||||
render->render_pass = VK_NULL_HANDLE;
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_descriptor_set_layout (gst_vulkan_fence_ref
|
||||
(last_fence), render->descriptor_set_layout));
|
||||
render->descriptor_set_layout = VK_NULL_HANDLE;
|
||||
|
||||
gst_vulkan_fence_unref (last_fence);
|
||||
|
||||
if (render->last_fence)
|
||||
gst_vulkan_fence_unref (render->last_fence);
|
||||
render->last_fence = NULL;
|
||||
} else {
|
||||
vkDestroyPipeline (render->device->device,
|
||||
render->graphics_pipeline, NULL);
|
||||
render->graphics_pipeline = VK_NULL_HANDLE;
|
||||
|
||||
vkDestroyPipelineLayout (render->device->device,
|
||||
render->pipeline_layout, NULL);
|
||||
render->pipeline_layout = VK_NULL_HANDLE;
|
||||
|
||||
vkDestroyRenderPass (render->device->device, render->render_pass, NULL);
|
||||
render->render_pass = VK_NULL_HANDLE;
|
||||
|
||||
vkDestroyDescriptorSetLayout (render->device->device,
|
||||
render->descriptor_set_layout, NULL);
|
||||
render->descriptor_set_layout = VK_NULL_HANDLE;
|
||||
}
|
||||
render->last_fence = NULL;
|
||||
|
||||
if (!gst_vulkan_trash_list_wait (render->trash_list, -1))
|
||||
GST_WARNING_OBJECT (render,
|
||||
|
|
|
@ -350,23 +350,24 @@ gst_vulkan_image_identity_set_caps (GstBaseTransform * bt, GstCaps * in_caps,
|
|||
{
|
||||
GstVulkanImageIdentity *vk_identity = GST_VULKAN_IMAGE_IDENTITY (bt);
|
||||
GstVulkanFullScreenRender *render = GST_VULKAN_FULL_SCREEN_RENDER (bt);
|
||||
GstVulkanFence *last_fence;
|
||||
|
||||
if (!GST_BASE_TRANSFORM_CLASS (parent_class)->set_caps (bt, in_caps,
|
||||
out_caps))
|
||||
return FALSE;
|
||||
|
||||
if (render->last_fence) {
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_descriptor_pool (gst_vulkan_fence_ref
|
||||
(render->last_fence), vk_identity->descriptor_pool));
|
||||
vk_identity->descriptor_set = VK_NULL_HANDLE;
|
||||
vk_identity->descriptor_pool = VK_NULL_HANDLE;
|
||||
} else {
|
||||
vkDestroyDescriptorPool (render->device->device,
|
||||
vk_identity->descriptor_pool, NULL);
|
||||
vk_identity->descriptor_set = VK_NULL_HANDLE;
|
||||
vk_identity->descriptor_pool = VK_NULL_HANDLE;
|
||||
}
|
||||
if (render->last_fence)
|
||||
last_fence = gst_vulkan_fence_ref (render->last_fence);
|
||||
else
|
||||
last_fence = gst_vulkan_fence_new_always_signalled (render->device);
|
||||
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_descriptor_pool (gst_vulkan_fence_ref
|
||||
(last_fence), vk_identity->descriptor_pool));
|
||||
vk_identity->descriptor_set = VK_NULL_HANDLE;
|
||||
vk_identity->descriptor_pool = VK_NULL_HANDLE;
|
||||
|
||||
gst_vulkan_fence_unref (last_fence);
|
||||
|
||||
if (!(vk_identity->descriptor_pool = _create_descriptor_pool (vk_identity)))
|
||||
return FALSE;
|
||||
|
@ -438,24 +439,25 @@ gst_vulkan_image_identity_stop (GstBaseTransform * bt)
|
|||
GstVulkanFullScreenRender *render = GST_VULKAN_FULL_SCREEN_RENDER (bt);
|
||||
|
||||
if (render->device) {
|
||||
if (render->last_fence) {
|
||||
GstVulkanFence *last_fence;
|
||||
|
||||
if (render->last_fence)
|
||||
last_fence = gst_vulkan_fence_ref (render->last_fence);
|
||||
else
|
||||
last_fence = gst_vulkan_fence_new_always_signalled (render->device);
|
||||
|
||||
if (vk_identity->descriptor_pool)
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_descriptor_pool (gst_vulkan_fence_ref
|
||||
(render->last_fence), vk_identity->descriptor_pool));
|
||||
vk_identity->descriptor_set = VK_NULL_HANDLE;
|
||||
vk_identity->descriptor_pool = VK_NULL_HANDLE;
|
||||
vk_identity->descriptor_pool = VK_NULL_HANDLE;
|
||||
if (vk_identity->sampler)
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_sampler (gst_vulkan_fence_ref
|
||||
(render->last_fence), vk_identity->sampler));
|
||||
vk_identity->sampler = VK_NULL_HANDLE;
|
||||
} else {
|
||||
vkDestroyDescriptorPool (render->device->device,
|
||||
vk_identity->descriptor_pool, NULL);
|
||||
vk_identity->descriptor_set = VK_NULL_HANDLE;
|
||||
vk_identity->descriptor_pool = VK_NULL_HANDLE;
|
||||
vkDestroySampler (render->device->device, vk_identity->sampler, NULL);
|
||||
vk_identity->sampler = VK_NULL_HANDLE;
|
||||
}
|
||||
vk_identity->sampler = VK_NULL_HANDLE;
|
||||
|
||||
gst_vulkan_fence_unref (last_fence);
|
||||
}
|
||||
|
||||
if (vk_identity->cmd_pool)
|
||||
|
|
|
@ -2105,29 +2105,26 @@ gst_vulkan_view_convert_set_caps (GstBaseTransform * bt, GstCaps * in_caps,
|
|||
{
|
||||
GstVulkanViewConvert *conv = GST_VULKAN_VIEW_CONVERT (bt);
|
||||
GstVulkanFullScreenRender *render = GST_VULKAN_FULL_SCREEN_RENDER (bt);
|
||||
GstVulkanFence *last_fence;
|
||||
|
||||
if (render->last_fence) {
|
||||
if (conv->descriptor_pool)
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_descriptor_pool (gst_vulkan_fence_ref
|
||||
(render->last_fence), conv->descriptor_pool));
|
||||
conv->descriptor_set = VK_NULL_HANDLE;
|
||||
conv->descriptor_pool = VK_NULL_HANDLE;
|
||||
if (conv->uniform)
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_mini_object_unref (gst_vulkan_fence_ref
|
||||
(render->last_fence), (GstMiniObject *) conv->uniform));
|
||||
conv->uniform = NULL;
|
||||
} else {
|
||||
if (conv->descriptor_pool)
|
||||
vkDestroyDescriptorPool (render->device->device,
|
||||
conv->descriptor_pool, NULL);
|
||||
conv->descriptor_set = VK_NULL_HANDLE;
|
||||
conv->descriptor_pool = VK_NULL_HANDLE;
|
||||
if (conv->uniform)
|
||||
gst_memory_unref (conv->uniform);
|
||||
conv->uniform = NULL;
|
||||
}
|
||||
if (render->last_fence)
|
||||
last_fence = gst_vulkan_fence_ref (render->last_fence);
|
||||
else
|
||||
last_fence = gst_vulkan_fence_new_always_signalled (render->device);
|
||||
|
||||
if (conv->descriptor_pool)
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_descriptor_pool (gst_vulkan_fence_ref
|
||||
(last_fence), conv->descriptor_pool));
|
||||
conv->descriptor_set = VK_NULL_HANDLE;
|
||||
conv->descriptor_pool = VK_NULL_HANDLE;
|
||||
if (conv->uniform)
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_mini_object_unref (gst_vulkan_fence_ref
|
||||
(last_fence), (GstMiniObject *) conv->uniform));
|
||||
conv->uniform = NULL;
|
||||
|
||||
gst_vulkan_fence_unref (last_fence);
|
||||
|
||||
if (!GST_BASE_TRANSFORM_CLASS (parent_class)->set_caps (bt, in_caps,
|
||||
out_caps))
|
||||
|
@ -2153,36 +2150,31 @@ gst_vulkan_view_convert_stop (GstBaseTransform * bt)
|
|||
conv->descriptor_up_to_date = FALSE;
|
||||
|
||||
if (render->device) {
|
||||
if (render->last_fence) {
|
||||
if (conv->descriptor_pool)
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_descriptor_pool (gst_vulkan_fence_ref
|
||||
(render->last_fence), conv->descriptor_pool));
|
||||
conv->descriptor_set = VK_NULL_HANDLE;
|
||||
conv->descriptor_pool = VK_NULL_HANDLE;
|
||||
if (conv->sampler)
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_sampler (gst_vulkan_fence_ref
|
||||
(render->last_fence), conv->sampler));
|
||||
conv->sampler = VK_NULL_HANDLE;
|
||||
if (conv->uniform)
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_mini_object_unref (gst_vulkan_fence_ref
|
||||
(render->last_fence), (GstMiniObject *) conv->uniform));
|
||||
conv->uniform = NULL;
|
||||
} else {
|
||||
if (conv->descriptor_pool)
|
||||
vkDestroyDescriptorPool (render->device->device,
|
||||
conv->descriptor_pool, NULL);
|
||||
conv->descriptor_set = VK_NULL_HANDLE;
|
||||
conv->descriptor_pool = VK_NULL_HANDLE;
|
||||
if (conv->sampler)
|
||||
vkDestroySampler (render->device->device, conv->sampler, NULL);
|
||||
conv->sampler = VK_NULL_HANDLE;
|
||||
if (conv->uniform)
|
||||
gst_memory_unref (conv->uniform);
|
||||
conv->uniform = VK_NULL_HANDLE;
|
||||
}
|
||||
GstVulkanFence *last_fence;
|
||||
|
||||
if (render->last_fence)
|
||||
last_fence = gst_vulkan_fence_ref (render->last_fence);
|
||||
else
|
||||
last_fence = gst_vulkan_fence_new_always_signalled (render->device);
|
||||
|
||||
if (conv->descriptor_pool)
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_descriptor_pool (gst_vulkan_fence_ref
|
||||
(last_fence), conv->descriptor_pool));
|
||||
conv->descriptor_set = VK_NULL_HANDLE;
|
||||
conv->descriptor_pool = VK_NULL_HANDLE;
|
||||
if (conv->sampler)
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_free_sampler (gst_vulkan_fence_ref
|
||||
(last_fence), conv->sampler));
|
||||
conv->sampler = VK_NULL_HANDLE;
|
||||
if (conv->uniform)
|
||||
gst_vulkan_trash_list_add (render->trash_list,
|
||||
gst_vulkan_trash_new_mini_object_unref (gst_vulkan_fence_ref
|
||||
(last_fence), (GstMiniObject *) conv->uniform));
|
||||
conv->uniform = NULL;
|
||||
|
||||
gst_vulkan_fence_unref (last_fence);
|
||||
}
|
||||
|
||||
if (conv->cmd_pool)
|
||||
|
@ -2244,6 +2236,10 @@ gst_vulkan_view_convert_transform (GstBaseTransform * bt, GstBuffer * inbuf,
|
|||
VkResult err;
|
||||
int i;
|
||||
|
||||
fence = gst_vulkan_fence_new (render->device, 0, &error);
|
||||
if (!fence)
|
||||
goto error;
|
||||
|
||||
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&render->in_info); i++) {
|
||||
GstMemory *mem = gst_buffer_peek_memory (inbuf, i);
|
||||
if (!gst_is_vulkan_image_memory (mem)) {
|
||||
|
@ -2281,10 +2277,6 @@ gst_vulkan_view_convert_transform (GstBaseTransform * bt, GstBuffer * inbuf,
|
|||
if (!(cmd_buf = gst_vulkan_command_pool_create (conv->cmd_pool, &error)))
|
||||
goto error;
|
||||
|
||||
fence = gst_vulkan_fence_new (render->device, 0, &error);
|
||||
if (!fence)
|
||||
goto error;
|
||||
|
||||
{
|
||||
VkCommandBufferBeginInfo cmd_buf_info = { 0, };
|
||||
|
||||
|
|
|
@ -56,7 +56,8 @@ gst_vulkan_fence_free (GstVulkanFence * fence)
|
|||
|
||||
GST_TRACE ("Freeing fence %p", fence);
|
||||
|
||||
vkDestroyFence (fence->device->device, fence->fence, NULL);
|
||||
if (fence->fence)
|
||||
vkDestroyFence (fence->device->device, fence->fence, NULL);
|
||||
|
||||
gst_object_unref (fence->device);
|
||||
|
||||
|
@ -95,6 +96,7 @@ gst_vulkan_fence_new (GstVulkanDevice * device, VkFenceCreateFlags flags,
|
|||
|
||||
err = vkCreateFence (device->device, &fence_info, NULL, &fence->fence);
|
||||
if (gst_vulkan_error_to_g_error (err, error, "vkCreateFence") < 0) {
|
||||
gst_clear_object (&fence->device);
|
||||
g_free (fence);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -105,6 +107,32 @@ gst_vulkan_fence_new (GstVulkanDevice * device, VkFenceCreateFlags flags,
|
|||
return fence;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vulkan_fence_new_always_signalled:
|
||||
*
|
||||
* Returns: a new #GstVulkanFence that is always in the signalled state
|
||||
*/
|
||||
GstVulkanFence *
|
||||
gst_vulkan_fence_new_always_signalled (GstVulkanDevice * device)
|
||||
{
|
||||
GstVulkanFence *fence;
|
||||
|
||||
g_return_val_if_fail (GST_IS_VULKAN_DEVICE (device), FALSE);
|
||||
|
||||
_init_debug ();
|
||||
|
||||
fence = g_new0 (GstVulkanFence, 1);
|
||||
GST_TRACE ("Creating always-signalled fence %p with device %" GST_PTR_FORMAT,
|
||||
fence, device);
|
||||
fence->device = gst_object_ref (device);
|
||||
fence->fence = VK_NULL_HANDLE;
|
||||
|
||||
gst_mini_object_init (GST_MINI_OBJECT_CAST (fence), 0, GST_TYPE_VULKAN_FENCE,
|
||||
NULL, NULL, (GstMiniObjectFreeFunction) gst_vulkan_fence_free);
|
||||
|
||||
return fence;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vulkan_fence_is_signaled:
|
||||
* @fence: a #GstVulkanFence
|
||||
|
@ -118,6 +146,9 @@ gst_vulkan_fence_is_signaled (GstVulkanFence * fence)
|
|||
{
|
||||
g_return_val_if_fail (fence != NULL, FALSE);
|
||||
|
||||
if (!fence->fence)
|
||||
return TRUE;
|
||||
|
||||
return vkGetFenceStatus (fence->device->device, fence->fence) == VK_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,9 @@ GST_VULKAN_API
|
|||
GstVulkanFence * gst_vulkan_fence_new (GstVulkanDevice * device,
|
||||
VkFenceCreateFlags flags,
|
||||
GError ** error);
|
||||
GST_VULKAN_API
|
||||
GstVulkanFence * gst_vulkan_fence_new_always_signalled (GstVulkanDevice *device);
|
||||
|
||||
GST_VULKAN_API
|
||||
gboolean gst_vulkan_fence_is_signaled (GstVulkanFence * fence);
|
||||
|
||||
|
|
Loading…
Reference in a new issue