vkimagebufferpool: expose config_get_allocation_params()

Also enhanced the documentation and added a config parameter check for
gst_vulkan_image_buffer_pool_config_set_allocation_params()

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7219>
This commit is contained in:
Víctor Manuel Jáquez Leal 2024-07-29 19:06:34 +02:00
parent 7576d14762
commit baac191d13
3 changed files with 94 additions and 19 deletions

View file

@ -3513,8 +3513,40 @@ inside @handle.</doc>
</parameter>
</parameters>
</constructor>
<function name="config_get_allocation_params" c:identifier="gst_vulkan_image_buffer_pool_config_get_allocation_params" version="1.26">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagebufferpool.c">Gets the configuration of the Vulkan image buffer pool.</doc>
<source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagebufferpool.h"/>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<parameter name="config" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagebufferpool.c">the #GstStructure with the pool's configuration.</doc>
<type name="Gst.Structure" c:type="GstStructure*"/>
</parameter>
<parameter name="usage" direction="out" caller-allocates="1" transfer-ownership="none" optional="1" allow-none="1">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagebufferpool.c">The Vulkan image usage flags.</doc>
<type name="Vulkan.ImageUsageFlags" c:type="VkImageUsageFlags*"/>
</parameter>
<parameter name="mem_props" transfer-ownership="none">
<type name="Vulkan.MemoryPropertyFlags" c:type="VkMemoryPropertyFlags*"/>
</parameter>
<parameter name="initial_layout" direction="out" caller-allocates="1" transfer-ownership="none" optional="1" allow-none="1">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagebufferpool.c">Initial Vulkan image layout.</doc>
<type name="Vulkan.ImageLayout" c:type="VkImageLayout*"/>
</parameter>
<parameter name="initial_access" direction="out" caller-allocates="0" transfer-ownership="full" optional="1" allow-none="1">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagebufferpool.c">Initial Vulkan access flags.</doc>
<type name="guint64" c:type="guint64*"/>
</parameter>
</parameters>
</function>
<function name="config_set_allocation_params" c:identifier="gst_vulkan_image_buffer_pool_config_set_allocation_params" version="1.24">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagebufferpool.c">Sets the @usage and @mem_properties of the images to setup.</doc>
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagebufferpool.c">Sets the @usage and @mem_properties, @initial_layout and @initial_access of
the images to setup.
If @initial_access is VK_IMAGE_LAYOUT_UNDEFINED or
VK_IMAGE_LAYOUT_PREINITIALIZED images does not do layout initialization.</doc>
<source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagebufferpool.h"/>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>

View file

@ -81,7 +81,11 @@ G_DEFINE_TYPE_WITH_CODE (GstVulkanImageBufferPool, gst_vulkan_image_buffer_pool,
* @initial_access: Access flags for the layout transition if @initial_layout is
* not VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.
*
* Sets the @usage and @mem_properties of the images to setup.
* Sets the @usage and @mem_properties, @initial_layout and @initial_access of
* the images to setup.
*
* If @initial_access is VK_IMAGE_LAYOUT_UNDEFINED or
* VK_IMAGE_LAYOUT_PREINITIALIZED images does not do layout initialization.
*
* Since: 1.24
*/
@ -90,6 +94,8 @@ gst_vulkan_image_buffer_pool_config_set_allocation_params (GstStructure *
config, VkImageUsageFlags usage, VkMemoryPropertyFlags mem_properties,
VkImageLayout initial_layout, guint64 initial_access)
{
g_return_if_fail (GST_IS_STRUCTURE (config));
/* assumption: G_TYPE_UINT is compatible with uint32_t (VkFlags) */
gst_structure_set (config, "usage", G_TYPE_UINT, usage, "memory-properties",
G_TYPE_UINT, mem_properties, "initial-layout", G_TYPE_UINT,
@ -134,23 +140,54 @@ gst_vulkan_image_buffer_pool_config_set_encode_caps (GstStructure * config,
gst_structure_set (config, "encode-caps", GST_TYPE_CAPS, caps, NULL);
}
static inline gboolean
/**
* gst_vulkan_image_buffer_pool_config_get_allocation_params:
* @config: the #GstStructure with the pool's configuration.
* @usage: (out) (optional): The Vulkan image usage flags.
* @mem_properties: (out) (optional): Vulkan memory property flags.
* @initial_layout: (out) (optional): Initial Vulkan image layout.
* @initial_access: (out) (optional): Initial Vulkan access flags.
*
* Gets the configuration of the Vulkan image buffer pool.
*
* Since: 1.26
*/
void
gst_vulkan_image_buffer_pool_config_get_allocation_params (GstStructure *
config, VkImageUsageFlags * usage, VkMemoryPropertyFlags * mem_props,
VkImageLayout * initial_layout, guint64 * initial_access)
{
g_return_if_fail (GST_IS_STRUCTURE (config));
if (usage) {
if (!gst_structure_get_uint (config, "usage", usage))
*usage = default_usage;
}
if (mem_props) {
if (!gst_structure_get_uint (config, "memory-properties", mem_props))
*mem_props = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
}
if (initial_layout) {
if (!gst_structure_get_uint (config, "initial-layout", initial_layout))
*initial_layout = VK_IMAGE_LAYOUT_UNDEFINED;
}
if (initial_access) {
if (!gst_structure_get_uint64 (config, "initial-access", initial_access))
*initial_access = 0; /* VK_ACCESS_NONE */
}
}
static inline void
internal_config_get_allocation_params (GstStructure * config,
VkImageUsageFlags * usage, VkMemoryPropertyFlags * mem_props,
VkImageLayout * initial_layout, guint64 * initial_access,
guint32 * n_layers, GstCaps ** decode_caps, GstCaps ** encode_caps)
{
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;
if (!gst_structure_get_uint (config, "initial-layout", initial_layout))
*initial_layout = VK_IMAGE_LAYOUT_UNDEFINED;
if (!gst_structure_get_uint64 (config, "initial-access", initial_access))
*initial_access = 0;
gst_vulkan_image_buffer_pool_config_get_allocation_params (config, usage,
mem_props, initial_layout, initial_access);
if (!gst_structure_get_uint (config, "num-layers", n_layers))
*n_layers = 1;
@ -160,8 +197,6 @@ gst_vulkan_image_buffer_pool_config_get_allocation_params (GstStructure *
if (encode_caps)
gst_structure_get (config, "encode-caps", GST_TYPE_CAPS, encode_caps, NULL);
return TRUE;
}
static gboolean
@ -199,9 +234,9 @@ gst_vulkan_image_buffer_pool_set_config (GstBufferPool * pool,
priv->raw_caps = features == NULL || gst_caps_features_is_equal (features,
GST_CAPS_FEATURES_MEMORY_SYSTEM_MEMORY);
gst_vulkan_image_buffer_pool_config_get_allocation_params (config,
&requested_usage, &priv->mem_props, &priv->initial_layout,
&priv->initial_access, &priv->n_layers, &decode_caps, &encode_caps);
internal_config_get_allocation_params (config, &requested_usage,
&priv->mem_props, &priv->initial_layout, &priv->initial_access,
&priv->n_layers, &decode_caps, &encode_caps);
#if GST_VULKAN_HAVE_VIDEO_EXTENSIONS
{

View file

@ -88,6 +88,14 @@ void gst_vulkan_image_buffer_pool_config_set_allocation_params
VkImageLayout initial_layout,
guint64 initial_access);
GST_VULKAN_API
void gst_vulkan_image_buffer_pool_config_get_allocation_params
(GstStructure * config,
VkImageUsageFlags * usage,
VkMemoryPropertyFlags * mem_props,
VkImageLayout * initial_layout,
guint64 * initial_access);
GST_VULKAN_API
void gst_vulkan_image_buffer_pool_config_set_decode_caps
(GstStructure * config,