From 2d17bba6f1b17dfbc1900e90636a9c0ede1e1c1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Mon, 22 Jan 2024 17:28:06 +0100 Subject: [PATCH] vkimagebufferpool: define a default usage Define a default usage and use it instead of repeating the same bitwise addition. Therefore, when usage is defined as zero, the usage is defined with the format's supported usage and the default usage, now without the storage bit, but with color and input attachment bits. Part-of: --- .../gst-libs/gst/vulkan/gstvkimagebufferpool.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagebufferpool.c b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagebufferpool.c index f07ab428fa..65eec056bb 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagebufferpool.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagebufferpool.c @@ -35,6 +35,11 @@ * A #GstVulkanImageBufferPool is created with gst_vulkan_image_buffer_pool_new() */ +const static VkImageUsageFlags default_usage = + VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT + | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT + | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; + /* bufferpool */ struct _GstVulkanImageBufferPoolPrivate { @@ -134,11 +139,8 @@ gst_vulkan_image_buffer_pool_config_get_allocation_params (GstStructure * VkImageLayout * initial_layout, guint64 * initial_access, guint32 * n_layers, GstCaps ** decode_caps, GstCaps ** encode_caps) { - if (!gst_structure_get_uint (config, "usage", usage)) { - *usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT - | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT - | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT; - } + if (!gst_structure_get_uint (config, "usage", usage)) + *usage = default_usage; if (!gst_structure_get_uint (config, "memory-properties", mem_props)) *mem_props = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; @@ -248,9 +250,7 @@ gst_vulkan_image_buffer_pool_set_config (GstBufferPool * pool, goto no_vk_format; if (priv->usage == 0) { - priv->usage = supported_usage & (VK_BUFFER_USAGE_TRANSFER_DST_BIT - | VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_STORAGE_BIT - | VK_IMAGE_USAGE_SAMPLED_BIT); + priv->usage = supported_usage & default_usage; } /* get the size of the buffer to allocate */