3 * Copyright (C) 2019 Matthew Waters <matthew@centricular.com>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
22 * SECTION:vulkancommandbuffer
23 * @title: GstVulkanCommandBuffer
24 * @short_description: Vulkan command buffer
25 * @see_also: #GstVulkanCommandPool
27 * vulkancommandbuffer holds information about a command buffer.
34 #include "gstvkcommandbuffer.h"
35 #include "gstvkcommandpool.h"
36 #include "gstvkcommandpool-private.h"
38 #define GST_CAT_DEFAULT gst_debug_vulkan_command_buffer
39 GST_DEBUG_CATEGORY (GST_CAT_DEFAULT);
44 static gsize _init = 0;
46 if (g_once_init_enter (&_init)) {
47 GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "vulkancommandbuffer", 0,
48 "Vulkan command buffer");
49 g_once_init_leave (&_init, 1);
54 gst_vulkan_command_buffer_dispose (GstVulkanCommandBuffer * cmd)
56 GstVulkanCommandPool *pool;
58 /* no pool, do free */
59 if ((pool = cmd->pool) == NULL)
62 /* keep the buffer alive */
63 gst_vulkan_command_buffer_ref (cmd);
64 /* return the buffer to the pool */
65 gst_vulkan_command_pool_release_buffer (pool, cmd);
71 gst_vulkan_command_buffer_free (GstVulkanCommandBuffer * cmd)
73 g_assert (cmd->pool == NULL);
75 GST_TRACE ("Freeing %p", cmd);
81 gst_vulkan_command_buffer_init (GstVulkanCommandBuffer * cmd,
82 VkCommandBuffer cmd_buf, VkCommandBufferLevel level)
89 GST_TRACE ("new %p", cmd);
91 gst_mini_object_init (&cmd->parent, 0, GST_TYPE_VULKAN_COMMAND_BUFFER,
92 NULL, (GstMiniObjectDisposeFunction) gst_vulkan_command_buffer_dispose,
93 (GstMiniObjectFreeFunction) gst_vulkan_command_buffer_free);
97 * gst_vulkan_command_buffer_new_wrapped:
98 * @cmd: a VkCommandBuffer
99 * @level: the VkCommandBufferLevel for @cmd
101 * Returns: (transfer full): a new #GstVulkanCommandBuffer
105 GstVulkanCommandBuffer *
106 gst_vulkan_command_buffer_new_wrapped (VkCommandBuffer cmd,
107 VkCommandBufferLevel level)
109 GstVulkanCommandBuffer *ret;
111 ret = g_new0 (GstVulkanCommandBuffer, 1);
112 gst_vulkan_command_buffer_init (ret, cmd, level);
117 GST_DEFINE_MINI_OBJECT_TYPE (GstVulkanCommandBuffer, gst_vulkan_command_buffer);