diff --git a/ext/vulkan/meson.build b/ext/vulkan/meson.build index 351192b1f0..f1f0f23b92 100644 --- a/ext/vulkan/meson.build +++ b/ext/vulkan/meson.build @@ -5,6 +5,7 @@ endif vulkan_sources = [ 'gstvulkan.c', 'vksink.c', + 'vkshader.c', 'vkswapper.c', 'vktrash.c', 'vkupload.c', diff --git a/ext/vulkan/vkupload.c b/ext/vulkan/vkupload.c index 256dff94b9..725b8e9913 100644 --- a/ext/vulkan/vkupload.c +++ b/ext/vulkan/vkupload.c @@ -32,6 +32,7 @@ #include #include "vkupload.h" +#include "vktrash.h" GST_DEBUG_CATEGORY (gst_debug_vulkan_upload); #define GST_CAT_DEFAULT gst_debug_vulkan_upload @@ -367,9 +368,266 @@ static const struct UploadMethod raw_to_buffer_upload = { _raw_to_buffer_free, }; +struct BufferToImageUpload +{ + GstVulkanUpload *upload; + + GstVideoInfo in_info; + GstVideoInfo out_info; + + GstBufferPool *pool; + gboolean pool_active; + + GstVulkanCommandPool *cmd_pool; + GList *trash_list; +}; + +static gpointer +_buffer_to_image_new_impl (GstVulkanUpload * upload) +{ + struct BufferToImageUpload *raw = g_new0 (struct BufferToImageUpload, 1); + + raw->upload = upload; + + return raw; +} + +static GstCaps * +_buffer_to_image_transform_caps (gpointer impl, GstPadDirection direction, + GstCaps * caps) +{ + GstCaps *ret; + + if (direction == GST_PAD_SINK) { + ret = + _set_caps_features_with_passthrough (caps, + GST_CAPS_FEATURE_MEMORY_VULKAN_IMAGE, NULL); + } else { + ret = + _set_caps_features_with_passthrough (caps, + GST_CAPS_FEATURE_MEMORY_VULKAN_BUFFER, NULL); + } + + return ret; +} + +static gboolean +_buffer_to_image_set_caps (gpointer impl, GstCaps * in_caps, GstCaps * out_caps) +{ + struct BufferToImageUpload *raw = impl; + + if (!gst_video_info_from_caps (&raw->in_info, in_caps)) + return FALSE; + + if (!gst_video_info_from_caps (&raw->out_info, out_caps)) + return FALSE; + + return TRUE; +} + +static void +_buffer_to_image_propose_allocation (gpointer impl, GstQuery * decide_query, + GstQuery * query) +{ + /* a little trickery with the impl pointer */ + _buffer_propose_allocation (impl, decide_query, query); +} + +static GstFlowReturn +_buffer_to_image_perform (gpointer impl, GstBuffer * inbuf, GstBuffer ** outbuf) +{ + struct BufferToImageUpload *raw = impl; + GstFlowReturn ret; + GError *error = NULL; + VkResult err; + VkCommandBuffer cmd; + guint i; + + if (!raw->cmd_pool) { + if (!(raw->cmd_pool = + gst_vulkan_queue_create_command_pool (raw->upload->queue, + &error))) { + goto error; + } + } + + if (!(cmd = gst_vulkan_command_pool_create (raw->cmd_pool, &error))) + goto error; + + if (!raw->pool) { + GstStructure *config; + guint min = 0, max = 0; + gsize size = 1; + + raw->pool = gst_vulkan_image_buffer_pool_new (raw->upload->device); + config = gst_buffer_pool_get_config (raw->pool); + gst_buffer_pool_config_set_params (config, raw->upload->out_caps, size, min, + max); + gst_buffer_pool_set_config (raw->pool, config); + } + if (!raw->pool_active) { + gst_buffer_pool_set_active (raw->pool, TRUE); + raw->pool_active = TRUE; + } + + if ((ret = + gst_buffer_pool_acquire_buffer (raw->pool, outbuf, + NULL)) != GST_FLOW_OK) + goto out; + + { + VkCommandBufferInheritanceInfo buf_inh = { 0, }; + VkCommandBufferBeginInfo cmd_buf_info = { 0, }; + + buf_inh.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO; + buf_inh.pNext = NULL; + buf_inh.renderPass = VK_NULL_HANDLE; + buf_inh.subpass = 0; + buf_inh.framebuffer = VK_NULL_HANDLE; + buf_inh.occlusionQueryEnable = FALSE; + buf_inh.queryFlags = 0; + buf_inh.pipelineStatistics = 0; + + cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; + cmd_buf_info.pNext = NULL; + cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; + cmd_buf_info.pInheritanceInfo = &buf_inh; + + err = vkBeginCommandBuffer (cmd, &cmd_buf_info); + if (gst_vulkan_error_to_g_error (err, &error, "vkBeginCommandBuffer") < 0) + return FALSE; + } + + for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&raw->out_info); i++) { + VkBufferImageCopy region = { 0, }; + GstMemory *in_mem, *out_mem; + GstVulkanBufferMemory *buf_mem; + GstVulkanImageMemory *img_mem; + + in_mem = gst_buffer_peek_memory (inbuf, i); + if (!gst_is_vulkan_buffer_memory (in_mem)) { + GST_WARNING_OBJECT (raw->upload, "Input is not a GstVulkanBufferMemory"); + goto error; + } + buf_mem = (GstVulkanBufferMemory *) in_mem; + + out_mem = gst_buffer_peek_memory (*outbuf, i); + if (!gst_is_vulkan_image_memory (out_mem)) { + GST_WARNING_OBJECT (raw->upload, "Output is not a GstVulkanImageMemory"); + goto error; + } + img_mem = (GstVulkanImageMemory *) out_mem; + + GST_VK_BUFFER_IMAGE_COPY (region, 0, + GST_VIDEO_INFO_COMP_WIDTH (&raw->in_info, i), + GST_VIDEO_INFO_COMP_HEIGHT (&raw->in_info, i), + GST_VK_IMAGE_SUBRESOURCE_LAYERS_INIT (VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, + 1), GST_VK_OFFSET3D_INIT (0, 0, 0), + GST_VK_EXTENT3D_INIT (GST_VIDEO_INFO_COMP_WIDTH (&raw->out_info, i), + GST_VIDEO_INFO_COMP_HEIGHT (&raw->out_info, i), 1)); + + vkCmdCopyBufferToImage (cmd, buf_mem->buffer, img_mem->image, + img_mem->image_layout, 1, ®ion); + } + + err = vkEndCommandBuffer (cmd); + if (gst_vulkan_error_to_g_error (err, &error, "vkEndCommandBuffer") < 0) + return FALSE; + + { + VkSubmitInfo submit_info = { 0, }; + VkPipelineStageFlags stages = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; + GstVulkanFence *fence; + + submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; + submit_info.pNext = NULL; + submit_info.waitSemaphoreCount = 0; + submit_info.pWaitSemaphores = NULL; + submit_info.pWaitDstStageMask = &stages; + submit_info.commandBufferCount = 1; + submit_info.pCommandBuffers = &cmd; + submit_info.signalSemaphoreCount = 0; + submit_info.pSignalSemaphores = NULL; + + fence = gst_vulkan_fence_new (raw->upload->device, 0, &error); + if (!fence) + goto error; + + err = + vkQueueSubmit (raw->upload->queue->queue, 1, &submit_info, + GST_VULKAN_FENCE_FENCE (fence)); + if (gst_vulkan_error_to_g_error (err, &error, "vkQueueSubmit") < 0) + goto error; + + raw->trash_list = g_list_prepend (raw->trash_list, + gst_vulkan_trash_new_free_command_buffer (fence, raw->cmd_pool, cmd)); + } + + raw->trash_list = gst_vulkan_trash_list_gc (raw->trash_list); + + ret = GST_FLOW_OK; + +out: + return ret; + +error: + if (error) { + GST_WARNING_OBJECT (raw->upload, "Error: %s", error->message); + g_clear_error (&error); + } + gst_buffer_unref (*outbuf); + *outbuf = NULL; + ret = GST_FLOW_ERROR; + goto out; +} + +static void +_buffer_to_image_free (gpointer impl) +{ + struct BufferToImageUpload *raw = impl; + + if (raw->pool) { + if (raw->pool_active) { + gst_buffer_pool_set_active (raw->pool, FALSE); + } + raw->pool_active = FALSE; + gst_object_unref (raw->pool); + raw->pool = NULL; + } + + if (raw->cmd_pool) + gst_object_unref (raw->cmd_pool); + raw->cmd_pool = NULL; + + if (!gst_vulkan_trash_list_wait (raw->trash_list, -1)) + GST_WARNING_OBJECT (raw->upload, + "Failed to wait for all fences to complete " "before shutting down"); + raw->trash_list = NULL; + + g_free (impl); +} + +static GstStaticCaps _buffer_to_image_in_templ = +GST_STATIC_CAPS ("video/x-raw(" GST_CAPS_FEATURE_MEMORY_VULKAN_BUFFER ")"); +static GstStaticCaps _buffer_to_image_out_templ = +GST_STATIC_CAPS ("video/x-raw(" GST_CAPS_FEATURE_MEMORY_VULKAN_IMAGE ")"); + +static const struct UploadMethod buffer_to_image_upload = { + "BufferToVulkanImage", + &_buffer_to_image_in_templ, + &_buffer_to_image_out_templ, + _buffer_to_image_new_impl, + _buffer_to_image_transform_caps, + _buffer_to_image_set_caps, + _buffer_to_image_propose_allocation, + _buffer_to_image_perform, + _buffer_to_image_free, +}; + static const struct UploadMethod *upload_methods[] = { &buffer_upload, &raw_to_buffer_upload, + &buffer_to_image_upload, }; static GstCaps * @@ -559,15 +817,17 @@ gst_vulkan_upload_query (GstBaseTransform * bt, GstPadDirection direction, GstQuery * query) { GstVulkanUpload *vk_upload = GST_VULKAN_UPLOAD (bt); - gboolean res = FALSE; switch (GST_QUERY_TYPE (query)) { case GST_QUERY_CONTEXT:{ - res = gst_vulkan_handle_context_query (GST_ELEMENT (vk_upload), query, - NULL, &vk_upload->instance, &vk_upload->device); + if (gst_vulkan_handle_context_query (GST_ELEMENT (vk_upload), query, + NULL, &vk_upload->instance, &vk_upload->device)) + return TRUE; + + if (gst_vulkan_queue_handle_context_query (GST_ELEMENT (vk_upload), query, + &vk_upload->queue)) + return TRUE; - if (res) - return res; break; } default: @@ -587,6 +847,44 @@ gst_vulkan_upload_set_context (GstElement * element, GstContext * context) GST_ELEMENT_CLASS (parent_class)->set_context (element, context); } +struct choose_data +{ + GstVulkanUpload *upload; + GstVulkanQueue *queue; +}; + +static gboolean +_choose_queue (GstVulkanDevice * device, GstVulkanQueue * queue, + struct choose_data *data) +{ + guint flags = device->queue_family_props[queue->family].queueFlags; + + GST_ERROR ("flags 0x%x", flags); + + if ((flags & VK_QUEUE_GRAPHICS_BIT) != 0) { + if (data->queue) + gst_object_unref (data->queue); + data->queue = gst_object_ref (queue); + return FALSE; + } + + return TRUE; +} + +static GstVulkanQueue * +_find_graphics_queue (GstVulkanUpload * upload) +{ + struct choose_data data; + + data.upload = upload; + data.queue = NULL; + + gst_vulkan_device_foreach_queue (upload->device, + (GstVulkanDeviceForEachQueueFunc) _choose_queue, &data); + + return data.queue; +} + static GstStateChangeReturn gst_vulkan_upload_change_state (GstElement * element, GstStateChange transition) { @@ -619,6 +917,12 @@ gst_vulkan_upload_change_state (GstElement * element, GstStateChange transition) return GST_STATE_CHANGE_FAILURE; } } + + if (!gst_vulkan_queue_run_context_query (GST_ELEMENT (vk_upload), + &vk_upload->queue)) { + GST_DEBUG_OBJECT (vk_upload, "No queue retrieved from peer elements"); + vk_upload->queue = _find_graphics_queue (vk_upload); + } break; case GST_STATE_CHANGE_PAUSED_TO_PLAYING: break; diff --git a/ext/vulkan/vkupload.h b/ext/vulkan/vkupload.h index 11d65bcd56..1eb77911dc 100644 --- a/ext/vulkan/vkupload.h +++ b/ext/vulkan/vkupload.h @@ -65,6 +65,7 @@ struct _GstVulkanUpload GstVulkanInstance *instance; GstVulkanDevice *device; + GstVulkanQueue *queue; GstCaps *in_caps; GstCaps *out_caps; diff --git a/gst-libs/gst/vulkan/gstvkbufferpool.c b/gst-libs/gst/vulkan/gstvkbufferpool.c index d55a1b5bfb..bdaed4e7c7 100644 --- a/gst-libs/gst/vulkan/gstvkbufferpool.c +++ b/gst-libs/gst/vulkan/gstvkbufferpool.c @@ -169,7 +169,9 @@ gst_vulkan_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer, mem = gst_vulkan_buffer_memory_alloc (vk_pool->device, vk_format, priv->alloc_sizes[i], + /* FIXME: choose from outside */ VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT, + /* FIXME: choosefrom outside */ VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); if (!mem) { gst_buffer_unref (buf); diff --git a/gst-libs/gst/vulkan/gstvkimagebufferpool.c b/gst-libs/gst/vulkan/gstvkimagebufferpool.c new file mode 100644 index 0000000000..c889293647 --- /dev/null +++ b/gst-libs/gst/vulkan/gstvkimagebufferpool.c @@ -0,0 +1,263 @@ +/* + * GStreamer + * Copyright (C) 2016 Matthew Waters + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "gstvkimagebufferpool.h" + +/** + * SECTION:vkimagebufferpool + * @title: GstVulkanImageBufferPool + * @short_description: buffer pool for #GstVulkanImageMemory objects + * @see_also: #GstBufferPool, #GstVulkanImageMemory + * + * a #GstVulkanImageBufferPool is an object that allocates buffers with #GstVulkanImageMemory + * + * A #GstVulkanImageBufferPool is created with gst_vulkan_image_buffer_pool_new() + * + * #GstVulkanImageBufferPool implements the VideoMeta buffer pool option + * #GST_BUFFER_POOL_OPTION_VIDEO_META + */ + +/* bufferpool */ +struct _GstVulkanImageBufferPoolPrivate +{ + GstCaps *caps; + GstVideoInfo v_info; + gboolean add_videometa; +}; + +static void gst_vulkan_image_buffer_pool_finalize (GObject * object); + +GST_DEBUG_CATEGORY_STATIC (GST_CAT_VULKAN_IMAGE_BUFFER_POOL); +#define GST_CAT_DEFAULT GST_CAT_VULKAN_IMAGE_BUFFER_POOL + +#define gst_vulkan_image_buffer_pool_parent_class parent_class +G_DEFINE_TYPE_WITH_CODE (GstVulkanImageBufferPool, gst_vulkan_image_buffer_pool, + GST_TYPE_BUFFER_POOL, G_ADD_PRIVATE (GstVulkanImageBufferPool) + GST_DEBUG_CATEGORY_INIT (GST_CAT_VULKAN_IMAGE_BUFFER_POOL, + "vulkanimagebufferpool", 0, "Vulkan Image Buffer Pool")); + +static const gchar ** +gst_vulkan_image_buffer_pool_get_options (GstBufferPool * pool) +{ + static const gchar *options[] = { GST_BUFFER_POOL_OPTION_VIDEO_META, + NULL + }; + + return options; +} + +static gboolean +gst_vulkan_image_buffer_pool_set_config (GstBufferPool * pool, + GstStructure * config) +{ + GstVulkanImageBufferPool *vk_pool = GST_VULKAN_IMAGE_BUFFER_POOL_CAST (pool); + GstVulkanImageBufferPoolPrivate *priv = vk_pool->priv; + guint min_buffers, max_buffers; + GstCaps *caps = NULL; + gboolean ret = TRUE; + guint i; + + if (!gst_buffer_pool_config_get_params (config, &caps, NULL, &min_buffers, + &max_buffers)) + goto wrong_config; + + if (caps == NULL) + goto no_caps; + + /* now parse the caps from the config */ + if (!gst_video_info_from_caps (&priv->v_info, caps)) + goto wrong_caps; + + GST_LOG_OBJECT (pool, "%dx%d, caps %" GST_PTR_FORMAT, priv->v_info.width, + priv->v_info.height, caps); + + gst_caps_replace (&priv->caps, caps); + + /* get the size of the buffer to allocate */ + priv->v_info.size = 0; + for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&priv->v_info); i++) { + GstVideoFormat v_format = GST_VIDEO_INFO_FORMAT (&priv->v_info); + GstVulkanImageMemory *img_mem; + guint width, height; + VkFormat vk_format; + + vk_format = gst_vulkan_format_from_video_format (v_format, i); + width = GST_VIDEO_INFO_COMP_WIDTH (&priv->v_info, i); + height = GST_VIDEO_INFO_COMP_HEIGHT (&priv->v_info, i); + + img_mem = (GstVulkanImageMemory *) + gst_vulkan_image_memory_alloc (vk_pool->device, vk_format, width, + height, VK_IMAGE_TILING_OPTIMAL, + VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, + VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); + + priv->v_info.offset[i] = priv->v_info.size; + priv->v_info.size += img_mem->requirements.size; + + gst_memory_unref (GST_MEMORY_CAST (img_mem)); + } + + priv->add_videometa = gst_buffer_pool_config_has_option (config, + GST_BUFFER_POOL_OPTION_VIDEO_META); + + gst_buffer_pool_config_set_params (config, caps, + priv->v_info.size, min_buffers, max_buffers); + + return GST_BUFFER_POOL_CLASS (parent_class)->set_config (pool, config) && ret; + + /* ERRORS */ +wrong_config: + { + GST_WARNING_OBJECT (pool, "invalid config"); + return FALSE; + } +no_caps: + { + GST_WARNING_OBJECT (pool, "no caps in config"); + return FALSE; + } +wrong_caps: + { + GST_WARNING_OBJECT (pool, + "failed getting geometry from caps %" GST_PTR_FORMAT, caps); + return FALSE; + } +} + +/* This function handles GstBuffer creation */ +static GstFlowReturn +gst_vulkan_image_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer, + GstBufferPoolAcquireParams * params) +{ + GstVulkanImageBufferPool *vk_pool = GST_VULKAN_IMAGE_BUFFER_POOL_CAST (pool); + GstVulkanImageBufferPoolPrivate *priv = vk_pool->priv; + GstBuffer *buf; + guint i; + + if (!(buf = gst_buffer_new ())) { + goto no_buffer; + } + + for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&priv->v_info); i++) { + GstVideoFormat v_format = GST_VIDEO_INFO_FORMAT (&priv->v_info); + VkFormat vk_format; + GstMemory *mem; + + vk_format = gst_vulkan_format_from_video_format (v_format, i); + + mem = gst_vulkan_image_memory_alloc (vk_pool->device, + vk_format, GST_VIDEO_INFO_COMP_WIDTH (&priv->v_info, i), + GST_VIDEO_INFO_COMP_HEIGHT (&priv->v_info, i), + VK_IMAGE_TILING_OPTIMAL /* FIXME: support linear */ , + /* FIXME: choose from outside */ + VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | + VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT, + /* FIXME: choose from outside */ + 0); + if (!mem) { + gst_buffer_unref (buf); + goto mem_create_failed; + } + + gst_buffer_append_memory (buf, mem); + } + + *buffer = buf; + + return GST_FLOW_OK; + + /* ERROR */ +no_buffer: + { + GST_WARNING_OBJECT (pool, "can't create image"); + return GST_FLOW_ERROR; + } +mem_create_failed: + { + GST_WARNING_OBJECT (pool, "Could not create Vulkan Memory"); + return GST_FLOW_ERROR; + } +} + +/** + * gst_vulkan_image_buffer_pool_new: + * @device: the #GstVulkanDevice to use + * + * Returns: (transfer full): a #GstBufferPool that allocates buffers with #GstGLMemory + * + * Since: 1.18 + */ +GstBufferPool * +gst_vulkan_image_buffer_pool_new (GstVulkanDevice * device) +{ + GstVulkanImageBufferPool *pool; + + pool = g_object_new (GST_TYPE_VULKAN_IMAGE_BUFFER_POOL, NULL); + g_object_ref_sink (pool); + pool->device = gst_object_ref (device); + + GST_LOG_OBJECT (pool, "new Vulkan buffer pool for device %" GST_PTR_FORMAT, + device); + + return GST_BUFFER_POOL_CAST (pool); +} + +static void +gst_vulkan_image_buffer_pool_class_init (GstVulkanImageBufferPoolClass * klass) +{ + GObjectClass *gobject_class = (GObjectClass *) klass; + GstBufferPoolClass *gstbufferpool_class = (GstBufferPoolClass *) klass; + + gobject_class->finalize = gst_vulkan_image_buffer_pool_finalize; + + gstbufferpool_class->get_options = gst_vulkan_image_buffer_pool_get_options; + gstbufferpool_class->set_config = gst_vulkan_image_buffer_pool_set_config; + gstbufferpool_class->alloc_buffer = gst_vulkan_image_buffer_pool_alloc; +} + +static void +gst_vulkan_image_buffer_pool_init (GstVulkanImageBufferPool * pool) +{ + pool->priv = gst_vulkan_image_buffer_pool_get_instance_private (pool); +} + +static void +gst_vulkan_image_buffer_pool_finalize (GObject * object) +{ + GstVulkanImageBufferPool *pool = GST_VULKAN_IMAGE_BUFFER_POOL_CAST (object); + GstVulkanImageBufferPoolPrivate *priv = pool->priv; + + GST_LOG_OBJECT (pool, "finalize Vulkan buffer pool %p", pool); + + if (priv->caps) + gst_caps_unref (priv->caps); + + G_OBJECT_CLASS (gst_vulkan_image_buffer_pool_parent_class)->finalize (object); + + /* only release the context once all our memory have been deleted */ + if (pool->device) { + gst_object_unref (pool->device); + pool->device = NULL; + } +} diff --git a/gst-libs/gst/vulkan/gstvkimagebufferpool.h b/gst-libs/gst/vulkan/gstvkimagebufferpool.h new file mode 100644 index 0000000000..c55a316ef6 --- /dev/null +++ b/gst-libs/gst/vulkan/gstvkimagebufferpool.h @@ -0,0 +1,68 @@ +/* + * GStreamer + * Copyright (C) 2016 Matthew Waters + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_VULKAN_IMAGE_BUFFER_POOL_H__ +#define __GST_VULKAN_IMAGE_BUFFER_POOL_H__ + +#include +#include +#include + +#include + +G_BEGIN_DECLS + +GST_VULKAN_API +GType gst_vulkan_image_buffer_pool_get_type (void); +#define GST_TYPE_VULKAN_IMAGE_BUFFER_POOL (gst_vulkan_image_buffer_pool_get_type()) +#define GST_IS_VULKAN_IMAGE_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VULKAN_IMAGE_BUFFER_POOL)) +#define GST_VULKAN_IMAGE_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VULKAN_IMAGE_BUFFER_POOL, GstVulkanImageBufferPool)) +#define GST_VULKAN_IMAGE_BUFFER_POOL_CAST(obj) ((GstVulkanImageBufferPool*)(obj)) + +/** + * GstVulkanImageBufferPool: + * + * Opaque GstVulkanImageBufferPool struct + */ +struct _GstVulkanImageBufferPool +{ + GstBufferPool bufferpool; + + GstVulkanDevice *device; + + GstVulkanImageBufferPoolPrivate *priv; +}; + +/** + * GstVulkanImageBufferPoolClass: + * + * The #GstVulkanImageBufferPoolClass structure contains only private data + */ +struct _GstVulkanImageBufferPoolClass +{ + GstBufferPoolClass parent_class; +}; + +GST_VULKAN_API +GstBufferPool *gst_vulkan_image_buffer_pool_new (GstVulkanDevice * device); + +G_END_DECLS + +#endif /* __GST_VULKAN_IMAGE_BUFFER_POOL_H__ */ diff --git a/gst-libs/gst/vulkan/meson.build b/gst-libs/gst/vulkan/meson.build index 8c96ec6941..4ab6a5c539 100644 --- a/gst-libs/gst/vulkan/meson.build +++ b/gst-libs/gst/vulkan/meson.build @@ -12,6 +12,7 @@ vulkan_sources = [ 'gstvkerror.c', 'gstvkfence.c', 'gstvkimagememory.c', + 'gstvkimagebufferpool.c', 'gstvkinstance.c', 'gstvkmemory.c', 'gstvkqueue.c', @@ -28,6 +29,7 @@ vulkan_headers = [ 'gstvkerror.h', 'gstvkfence.h', 'gstvkimagememory.h', + 'gstvkimagebufferpool.h', 'gstvkinstance.h', 'gstvkmemory.h', 'gstvkqueue.h', diff --git a/gst-libs/gst/vulkan/vulkan.h b/gst-libs/gst/vulkan/vulkan.h index 19eaf11a1d..6c67c9c3f5 100644 --- a/gst-libs/gst/vulkan/vulkan.h +++ b/gst-libs/gst/vulkan/vulkan.h @@ -37,6 +37,7 @@ #include #include #include +#include #include #include diff --git a/gst-libs/gst/vulkan/vulkan_fwd.h b/gst-libs/gst/vulkan/vulkan_fwd.h index b4fdac74b2..5c815a0f3d 100644 --- a/gst-libs/gst/vulkan/vulkan_fwd.h +++ b/gst-libs/gst/vulkan/vulkan_fwd.h @@ -62,6 +62,10 @@ typedef struct _GstVulkanBufferPool GstVulkanBufferPool; typedef struct _GstVulkanBufferPoolClass GstVulkanBufferPoolClass; typedef struct _GstVulkanBufferPoolPrivate GstVulkanBufferPoolPrivate; +typedef struct _GstVulkanImageBufferPool GstVulkanImageBufferPool; +typedef struct _GstVulkanImageBufferPoolClass GstVulkanImageBufferPoolClass; +typedef struct _GstVulkanImageBufferPoolPrivate GstVulkanImageBufferPoolPrivate; + G_END_DECLS #endif /* __GST_VULKAN_FWD_H__ */