From ddb9b9d9ca48fe07e653a4896b4cb48a1233092d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Tue, 30 Apr 2024 16:55:05 +0200 Subject: [PATCH] vkdecoder: change dstmask in decoder frame barrier Use of VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT instead of specific VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR Fix for VUID-vkCmdPipelineBarrier2-srcStageMask-03849 pDependencyInfo->pImageMemoryBarriers[0].srcStageMask (VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR) is not compatible with the queue family properties (VK_QUEUE_GRAPHICS_BIT|VK_QUEUE_COMPUTE_BIT|VK_QUEUE_TRANSFER_BIT| VK_QUEUE_SPARSE_BINDING_BIT|VK_QUEUE_PROTECTED_BIT) of this command buffer. The Vulkan spec states: The srcStageMask member of any element of the pMemoryBarriers, pBufferMemoryBarriers, or pImageMemoryBarriers members of pDependencyInfo must only include pipeline stages valid for the queue family that was used to create the command pool that commandBuffer was allocated from ( https://www.khronos.org/registry/vulkan/specs/1.3-extensions/ html/vkspec.html#VUID-vkCmdPipelineBarrier2-srcStageMask-03849) The frame barrier should use a compatible srcStageMask for all the queues. Remove reset_pipeline_stage_mask as it is redundant Part-of: --- .../gst-plugins-bad/ext/vulkan/vkh264dec.c | 17 ----------------- .../gst-plugins-bad/ext/vulkan/vkh265dec.c | 17 ----------------- .../gst-libs/gst/vulkan/gstvkdecoder-private.c | 4 ++-- 3 files changed, 2 insertions(+), 36 deletions(-) diff --git a/subprojects/gst-plugins-bad/ext/vulkan/vkh264dec.c b/subprojects/gst-plugins-bad/ext/vulkan/vkh264dec.c index 6366732b06..bf35e7a42e 100644 --- a/subprojects/gst-plugins-bad/ext/vulkan/vkh264dec.c +++ b/subprojects/gst-plugins-bad/ext/vulkan/vkh264dec.c @@ -384,20 +384,6 @@ bail: } } -/* set a common pipeline stage valid for any queue to avoid Vulkan Validation - * errors */ -static void -reset_pipeline_stage_mask (GstBuffer * buf) -{ - guint i, n = gst_buffer_n_memory (buf); - - for (i = 0; i < n; i++) { - GstVulkanImageMemory *vk_mem = - (GstVulkanImageMemory *) gst_buffer_peek_memory (buf, i); - vk_mem->barrier.parent.pipeline_stages = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT; - } -} - static GstVulkanH264Picture * gst_vulkan_h264_picture_new (GstVulkanH264Decoder * self, GstBuffer * out) { @@ -405,7 +391,6 @@ gst_vulkan_h264_picture_new (GstVulkanH264Decoder * self, GstBuffer * out) pic = g_new0 (GstVulkanH264Picture, 1); gst_vulkan_decoder_picture_init (self->decoder, &pic->base, out); - reset_pipeline_stage_mask (out); return pic; } @@ -1288,8 +1273,6 @@ gst_vulkan_h264_decoder_output_picture (GstH264Decoder * decoder, gst_h264_picture_unref (picture); - reset_pipeline_stage_mask (frame->output_buffer); - return gst_video_decoder_finish_frame (vdec, frame); } diff --git a/subprojects/gst-plugins-bad/ext/vulkan/vkh265dec.c b/subprojects/gst-plugins-bad/ext/vulkan/vkh265dec.c index 703d6bd9c1..64d53d8876 100644 --- a/subprojects/gst-plugins-bad/ext/vulkan/vkh265dec.c +++ b/subprojects/gst-plugins-bad/ext/vulkan/vkh265dec.c @@ -567,20 +567,6 @@ gst_vulkan_h265_decoder_new_sequence (GstH265Decoder * decoder, return GST_FLOW_OK; } -/* set a common pipeline stage valid for any queue to avoid Vulkan Validation - * errors */ -static void -reset_pipeline_stage_mask (GstBuffer * buf) -{ - guint i, n = gst_buffer_n_memory (buf); - - for (i = 0; i < n; i++) { - GstVulkanImageMemory *vk_mem = - (GstVulkanImageMemory *) gst_buffer_peek_memory (buf, i); - vk_mem->barrier.parent.pipeline_stages = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT; - } -} - static GstVulkanH265Picture * gst_vulkan_h265_picture_new (GstVulkanH265Decoder * self, GstBuffer * out) { @@ -588,7 +574,6 @@ gst_vulkan_h265_picture_new (GstVulkanH265Decoder * self, GstBuffer * out) pic = g_new0 (GstVulkanH265Picture, 1); gst_vulkan_decoder_picture_init (self->decoder, &pic->base, out); - reset_pipeline_stage_mask (out); return pic; } @@ -1630,8 +1615,6 @@ gst_vulkan_h265_decoder_output_picture (GstH265Decoder * decoder, gst_h265_picture_unref (picture); - reset_pipeline_stage_mask (frame->output_buffer); - return gst_video_decoder_finish_frame (vdec, frame); } diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkdecoder-private.c b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkdecoder-private.c index 77709fc04a..1a19b7c66f 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkdecoder-private.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkdecoder-private.c @@ -701,7 +701,7 @@ gst_vulkan_decoder_decode (GstVulkanDecoder * self, VK_IMAGE_LAYOUT_VIDEO_DECODE_DST_KHR : VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR; gst_vulkan_operation_add_frame_barrier (priv->exec, pic->out, - VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR, + VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT, VK_ACCESS_2_VIDEO_DECODE_WRITE_BIT_KHR, new_layout, NULL); /* Reference for the current image, if existing and not layered */ @@ -728,7 +728,7 @@ gst_vulkan_decoder_decode (GstVulkanDecoder * self, if (!ref_pic->dpb) { gst_vulkan_operation_add_frame_barrier (priv->exec, ref_buf, - VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR, + VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT, VK_ACCESS_2_VIDEO_DECODE_WRITE_BIT_KHR | VK_ACCESS_2_VIDEO_DECODE_READ_BIT_KHR, VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR, NULL);