mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-22 17:51:16 +00:00
vulkan: add source pipeline stage to _operation_add_frame_barrier()
Instead of dragging the last destination pipeline stage as current barrier source pipeline stage (which isn't a valid semantic) this patch adds a parameter to gst_vulkan_operation_add_frame_barrier() to set the source pipeline stage to define the barrier. The previous logic brought problems particularly with queue transfers, when the new queue doesn't support the stage set during a previous operation in a different queue. Now the operation API is closer to Vulkan semantics. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7165>
This commit is contained in:
parent
dd4027388e
commit
2990cc5f71
11 changed files with 35 additions and 19 deletions
|
@ -4636,6 +4636,11 @@ gst_vulkan_operation_update_frame().</doc>
|
||||||
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkoperation.c">a Vulkan Image #GstBuffer</doc>
|
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkoperation.c">a Vulkan Image #GstBuffer</doc>
|
||||||
<type name="Gst.Buffer" c:type="GstBuffer*"/>
|
<type name="Gst.Buffer" c:type="GstBuffer*"/>
|
||||||
</parameter>
|
</parameter>
|
||||||
|
<parameter name="src_stage" transfer-ownership="none">
|
||||||
|
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkoperation.c">source pipeline stage (VkPipelineStageFlags or
|
||||||
|
VkPipelineStageFlags2)</doc>
|
||||||
|
<type name="guint64" c:type="guint64"/>
|
||||||
|
</parameter>
|
||||||
<parameter name="dst_stage" transfer-ownership="none">
|
<parameter name="dst_stage" transfer-ownership="none">
|
||||||
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkoperation.c">destination pipeline stage (VkPipelineStageFlags or
|
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkoperation.c">destination pipeline stage (VkPipelineStageFlags or
|
||||||
VkPipelineStageFlags2)</doc>
|
VkPipelineStageFlags2)</doc>
|
||||||
|
|
|
@ -197,8 +197,9 @@ _image_to_raw_perform (gpointer impl, GstBuffer * inbuf, GstBuffer ** outbuf)
|
||||||
cmd_buf = raw->exec->cmd_buf;
|
cmd_buf = raw->exec->cmd_buf;
|
||||||
|
|
||||||
if (!gst_vulkan_operation_add_frame_barrier (raw->exec, inbuf,
|
if (!gst_vulkan_operation_add_frame_barrier (raw->exec, inbuf,
|
||||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT,
|
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, NULL))
|
VK_ACCESS_TRANSFER_READ_BIT, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||||
|
NULL))
|
||||||
goto unlock_error;
|
goto unlock_error;
|
||||||
|
|
||||||
barriers = gst_vulkan_operation_retrieve_image_barriers (raw->exec);
|
barriers = gst_vulkan_operation_retrieve_image_barriers (raw->exec);
|
||||||
|
|
|
@ -423,8 +423,9 @@ _buffer_to_image_perform (gpointer impl, GstBuffer * inbuf, GstBuffer ** outbuf)
|
||||||
cmd_buf = raw->exec->cmd_buf;
|
cmd_buf = raw->exec->cmd_buf;
|
||||||
|
|
||||||
if (!gst_vulkan_operation_add_frame_barrier (raw->exec, *outbuf,
|
if (!gst_vulkan_operation_add_frame_barrier (raw->exec, *outbuf,
|
||||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT,
|
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, NULL))
|
VK_ACCESS_TRANSFER_WRITE_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||||
|
NULL))
|
||||||
goto unlock_error;
|
goto unlock_error;
|
||||||
|
|
||||||
barriers = gst_vulkan_operation_retrieve_image_barriers (raw->exec);
|
barriers = gst_vulkan_operation_retrieve_image_barriers (raw->exec);
|
||||||
|
@ -685,8 +686,9 @@ _raw_to_image_perform (gpointer impl, GstBuffer * inbuf, GstBuffer ** outbuf)
|
||||||
cmd_buf = raw->exec->cmd_buf;
|
cmd_buf = raw->exec->cmd_buf;
|
||||||
|
|
||||||
if (!gst_vulkan_operation_add_frame_barrier (raw->exec, *outbuf,
|
if (!gst_vulkan_operation_add_frame_barrier (raw->exec, *outbuf,
|
||||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT,
|
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, NULL))
|
VK_ACCESS_TRANSFER_WRITE_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||||
|
NULL))
|
||||||
goto unlock_error;
|
goto unlock_error;
|
||||||
|
|
||||||
barriers = gst_vulkan_operation_retrieve_image_barriers (raw->exec);
|
barriers = gst_vulkan_operation_retrieve_image_barriers (raw->exec);
|
||||||
|
|
|
@ -692,7 +692,8 @@ gst_vulkan_decoder_decode (GstVulkanDecoder * self,
|
||||||
VK_IMAGE_LAYOUT_VIDEO_DECODE_DST_KHR :
|
VK_IMAGE_LAYOUT_VIDEO_DECODE_DST_KHR :
|
||||||
VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR;
|
VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR;
|
||||||
gst_vulkan_operation_add_frame_barrier (priv->exec, pic->out,
|
gst_vulkan_operation_add_frame_barrier (priv->exec, pic->out,
|
||||||
VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
|
VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
|
||||||
|
VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
|
||||||
VK_ACCESS_2_VIDEO_DECODE_WRITE_BIT_KHR, new_layout, NULL);
|
VK_ACCESS_2_VIDEO_DECODE_WRITE_BIT_KHR, new_layout, NULL);
|
||||||
|
|
||||||
/* Reference for the current image, if existing and not layered */
|
/* Reference for the current image, if existing and not layered */
|
||||||
|
@ -719,7 +720,8 @@ gst_vulkan_decoder_decode (GstVulkanDecoder * self,
|
||||||
|
|
||||||
if (!ref_pic->dpb) {
|
if (!ref_pic->dpb) {
|
||||||
gst_vulkan_operation_add_frame_barrier (priv->exec, ref_buf,
|
gst_vulkan_operation_add_frame_barrier (priv->exec, ref_buf,
|
||||||
VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
|
VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
|
||||||
|
VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR,
|
||||||
VK_ACCESS_2_VIDEO_DECODE_WRITE_BIT_KHR
|
VK_ACCESS_2_VIDEO_DECODE_WRITE_BIT_KHR
|
||||||
| VK_ACCESS_2_VIDEO_DECODE_READ_BIT_KHR,
|
| VK_ACCESS_2_VIDEO_DECODE_READ_BIT_KHR,
|
||||||
VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR, NULL);
|
VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR, NULL);
|
||||||
|
|
|
@ -1303,6 +1303,7 @@ gst_vulkan_encoder_encode (GstVulkanEncoder * self,
|
||||||
VK_PIPELINE_STAGE_2_VIDEO_ENCODE_BIT_KHR);
|
VK_PIPELINE_STAGE_2_VIDEO_ENCODE_BIT_KHR);
|
||||||
gst_vulkan_operation_add_frame_barrier (priv->exec, pic->in_buffer,
|
gst_vulkan_operation_add_frame_barrier (priv->exec, pic->in_buffer,
|
||||||
VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
|
VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
|
||||||
|
VK_PIPELINE_STAGE_2_VIDEO_ENCODE_BIT_KHR,
|
||||||
VK_ACCESS_2_VIDEO_ENCODE_READ_BIT_KHR,
|
VK_ACCESS_2_VIDEO_ENCODE_READ_BIT_KHR,
|
||||||
VK_IMAGE_LAYOUT_VIDEO_ENCODE_SRC_KHR, NULL);
|
VK_IMAGE_LAYOUT_VIDEO_ENCODE_SRC_KHR, NULL);
|
||||||
|
|
||||||
|
@ -1311,6 +1312,7 @@ gst_vulkan_encoder_encode (GstVulkanEncoder * self,
|
||||||
VK_PIPELINE_STAGE_2_VIDEO_ENCODE_BIT_KHR);
|
VK_PIPELINE_STAGE_2_VIDEO_ENCODE_BIT_KHR);
|
||||||
gst_vulkan_operation_add_frame_barrier (priv->exec, pic->dpb_buffer,
|
gst_vulkan_operation_add_frame_barrier (priv->exec, pic->dpb_buffer,
|
||||||
VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
|
VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
|
||||||
|
VK_PIPELINE_STAGE_2_VIDEO_ENCODE_BIT_KHR,
|
||||||
VK_ACCESS_2_VIDEO_ENCODE_READ_BIT_KHR,
|
VK_ACCESS_2_VIDEO_ENCODE_READ_BIT_KHR,
|
||||||
VK_IMAGE_LAYOUT_VIDEO_ENCODE_DPB_KHR, NULL);
|
VK_IMAGE_LAYOUT_VIDEO_ENCODE_DPB_KHR, NULL);
|
||||||
|
|
||||||
|
|
|
@ -428,8 +428,8 @@ prepare_buffer (GstVulkanImageBufferPool * vk_pool, GstBuffer * buffer)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (!gst_vulkan_operation_add_frame_barrier (priv->exec, buffer,
|
if (!gst_vulkan_operation_add_frame_barrier (priv->exec, buffer,
|
||||||
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, priv->initial_access,
|
VK_PIPELINE_STAGE_NONE_KHR, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
||||||
priv->initial_layout, NULL))
|
priv->initial_access, priv->initial_layout, NULL))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
barriers = gst_vulkan_operation_retrieve_image_barriers (priv->exec);
|
barriers = gst_vulkan_operation_retrieve_image_barriers (priv->exec);
|
||||||
|
|
|
@ -859,6 +859,8 @@ gst_vulkan_operation_add_extra_image_barriers (GstVulkanOperation * self,
|
||||||
* gst_vulkan_operation_add_frame_barrier:
|
* gst_vulkan_operation_add_frame_barrier:
|
||||||
* @self: a #GstVulkanOperation
|
* @self: a #GstVulkanOperation
|
||||||
* @frame: a Vulkan Image #GstBuffer
|
* @frame: a Vulkan Image #GstBuffer
|
||||||
|
* @src_stage: source pipeline stage (VkPipelineStageFlags or
|
||||||
|
* VkPipelineStageFlags2)
|
||||||
* @dst_stage: destination pipeline stage (VkPipelineStageFlags or
|
* @dst_stage: destination pipeline stage (VkPipelineStageFlags or
|
||||||
* VkPipelineStageFlags2)
|
* VkPipelineStageFlags2)
|
||||||
* @new_access: the new access flags (VkAccessFlags2 or VkAccessFlags)
|
* @new_access: the new access flags (VkAccessFlags2 or VkAccessFlags)
|
||||||
|
@ -876,7 +878,7 @@ gst_vulkan_operation_add_extra_image_barriers (GstVulkanOperation * self,
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gst_vulkan_operation_add_frame_barrier (GstVulkanOperation * self,
|
gst_vulkan_operation_add_frame_barrier (GstVulkanOperation * self,
|
||||||
GstBuffer * frame, guint64 dst_stage, guint64 new_access,
|
GstBuffer * frame, guint64 src_stage, guint64 dst_stage, guint64 new_access,
|
||||||
VkImageLayout new_layout, GstVulkanQueue * new_queue)
|
VkImageLayout new_layout, GstVulkanQueue * new_queue)
|
||||||
{
|
{
|
||||||
guint i, n_mems;
|
guint i, n_mems;
|
||||||
|
@ -932,8 +934,7 @@ gst_vulkan_operation_add_frame_barrier (GstVulkanOperation * self,
|
||||||
VkImageMemoryBarrier2KHR barrier2 = {
|
VkImageMemoryBarrier2KHR barrier2 = {
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2_KHR,
|
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2_KHR,
|
||||||
.pNext = NULL,
|
.pNext = NULL,
|
||||||
.srcStageMask = dep_frame ?
|
.srcStageMask = src_stage,
|
||||||
dep_frame->dst_stage : vkmem->barrier.parent.pipeline_stages,
|
|
||||||
.dstStageMask = dst_stage,
|
.dstStageMask = dst_stage,
|
||||||
.srcAccessMask = dep_frame ?
|
.srcAccessMask = dep_frame ?
|
||||||
dep_frame->new_access : vkmem->barrier.parent.access_flags,
|
dep_frame->new_access : vkmem->barrier.parent.access_flags,
|
||||||
|
|
|
@ -103,6 +103,7 @@ GArray * gst_vulkan_operation_new_extra_image_barriers
|
||||||
GST_VULKAN_API
|
GST_VULKAN_API
|
||||||
gboolean gst_vulkan_operation_add_frame_barrier (GstVulkanOperation * self,
|
gboolean gst_vulkan_operation_add_frame_barrier (GstVulkanOperation * self,
|
||||||
GstBuffer * frame,
|
GstBuffer * frame,
|
||||||
|
guint64 src_stage,
|
||||||
guint64 dst_stage,
|
guint64 dst_stage,
|
||||||
guint64 new_access,
|
guint64 new_access,
|
||||||
VkImageLayout new_layout,
|
VkImageLayout new_layout,
|
||||||
|
|
|
@ -188,8 +188,8 @@ download_and_check_output_buffer (GstVulkanDecoder * dec, VkFormat vk_format,
|
||||||
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
|
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
|
||||||
|
|
||||||
gst_vulkan_operation_add_frame_barrier (exec, pic->out,
|
gst_vulkan_operation_add_frame_barrier (exec, pic->out,
|
||||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT,
|
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, NULL);
|
VK_ACCESS_TRANSFER_READ_BIT, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, NULL);
|
||||||
|
|
||||||
barriers = gst_vulkan_operation_retrieve_image_barriers (exec);
|
barriers = gst_vulkan_operation_retrieve_image_barriers (exec);
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
|
|
|
@ -240,8 +240,9 @@ upload_buffer_to_image (GstBufferPool * pool, GstBuffer * inbuf,
|
||||||
cmd_buf = exec->cmd_buf;
|
cmd_buf = exec->cmd_buf;
|
||||||
|
|
||||||
if (!gst_vulkan_operation_add_frame_barrier (exec, *outbuf,
|
if (!gst_vulkan_operation_add_frame_barrier (exec, *outbuf,
|
||||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT,
|
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, NULL))
|
VK_ACCESS_TRANSFER_WRITE_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||||
|
NULL))
|
||||||
goto unlock_error;
|
goto unlock_error;
|
||||||
|
|
||||||
barriers = gst_vulkan_operation_retrieve_image_barriers (exec);
|
barriers = gst_vulkan_operation_retrieve_image_barriers (exec);
|
||||||
|
|
|
@ -245,8 +245,9 @@ upload_buffer_to_image (GstBufferPool * pool, GstBuffer * inbuf,
|
||||||
cmd_buf = exec->cmd_buf;
|
cmd_buf = exec->cmd_buf;
|
||||||
|
|
||||||
if (!gst_vulkan_operation_add_frame_barrier (exec, *outbuf,
|
if (!gst_vulkan_operation_add_frame_barrier (exec, *outbuf,
|
||||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT,
|
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, NULL))
|
VK_ACCESS_TRANSFER_WRITE_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||||
|
NULL))
|
||||||
goto unlock_error;
|
goto unlock_error;
|
||||||
|
|
||||||
barriers = gst_vulkan_operation_retrieve_image_barriers (exec);
|
barriers = gst_vulkan_operation_retrieve_image_barriers (exec);
|
||||||
|
|
Loading…
Reference in a new issue