From efe8e41b6162559ea8c6df529f93f166b76c1f0c Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Mon, 23 May 2022 11:26:24 +1000 Subject: [PATCH] vkfullscreenquad: add support for disabling clearing e.g. if drawing over the top of an existing image, we don'w want to clear. Part-of: --- .../gst-libs/gst/vulkan/gstvkfullscreenquad.c | 30 ++++++++++++++++++- .../gst-libs/gst/vulkan/gstvkfullscreenquad.h | 3 ++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkfullscreenquad.c b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkfullscreenquad.c index 40dcd85b4e..816b8d64d9 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkfullscreenquad.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkfullscreenquad.c @@ -65,6 +65,8 @@ struct _GstVulkanFullScreenQuadPrivate VkBlendFactor dst_alpha_blend_factor; VkBlendOp colour_blend_op; VkBlendOp alpha_blend_op; + + gboolean enable_clear; }; G_DEFINE_TYPE_WITH_CODE (GstVulkanFullScreenQuad, gst_vulkan_full_screen_quad, @@ -300,7 +302,7 @@ create_render_pass (GstVulkanFullScreenQuad * self, GError ** error) color_attachments[i] = (VkAttachmentDescription) { .format = gst_vulkan_format_from_video_info (&self->out_info, i), .samples = VK_SAMPLE_COUNT_1_BIT, - .loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR, + .loadOp = priv->enable_clear ? VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_LOAD, .storeOp = VK_ATTACHMENT_STORE_OP_STORE, .stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE, .stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE, @@ -1326,6 +1328,32 @@ gst_vulkan_full_screen_quad_set_blend_operation (GstVulkanFullScreenQuad * self, clear_graphics_pipeline (self); } +/** + * gst_vulkan_full_screen_quad_enable_clear: + * @self: the #GstVulkanFullScreenQuad + * @enable_clear: whether to clear the framebuffer on load + * + * Since: 1.22 + */ +void +gst_vulkan_full_screen_quad_enable_clear (GstVulkanFullScreenQuad * self, + gboolean enable_clear) +{ + GstVulkanFullScreenQuadPrivate *priv; + + g_return_if_fail (GST_IS_VULKAN_FULL_SCREEN_QUAD (self)); + + priv = GET_PRIV (self); + + if (priv->enable_clear == enable_clear) + return; + + priv->enable_clear = enable_clear; + + clear_graphics_pipeline (self); + clear_render_pass (self); +} + /** * gst_vulkan_full_screen_quad_prepare_draw: * @self: the #GstVulkanFullScreenQuad diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkfullscreenquad.h b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkfullscreenquad.h index c99358cb8b..8710074656 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkfullscreenquad.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkfullscreenquad.h @@ -132,6 +132,9 @@ void gst_vulkan_full_screen_quad_set_blend_factors (GstVulkanFu VkBlendFactor dst_blend_factor, VkBlendFactor src_alpha_blend_factor, VkBlendFactor dst_alpha_blend_factor); +GST_VULKAN_API +void gst_vulkan_full_screen_quad_enable_clear (GstVulkanFullScreenQuad * self, + gboolean enable_clear); GST_VULKAN_API gboolean gst_vulkan_full_screen_quad_prepare_draw (GstVulkanFullScreenQuad * self, GstVulkanFence * fence, GError ** error);