Debian Codegraph @

gst-libs/gst/vulkan/gstvkimagememory.h

raw symbols SCIP
1 /*
2 * GStreamer
3 * Copyright (C) 2015 Matthew Waters <[email protected]>
4 *
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.
9 *
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.
14 *
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.
19 */
20
21 #ifndef __GST_VULKAN_IMAGE_MEMORY_H__
22 #define __GST_VULKAN_IMAGE_MEMORY_H__
23
24 #include <gst/vulkan/gstvkbarrier.h>
25 #include <gst/vulkan/gstvkdevice.h>
26
27 #include <gst/video/video.h>
28
29 G_BEGIN_DECLS
30
31 #define GST_TYPE_VULKAN_IMAGE_MEMORY_ALLOCATOR (gst_vulkan_image_memory_allocator_get_type())
32 GST_VULKAN_API
33 GType gst_vulkan_image_memory_allocator_get_type(void);
34
35 #define GST_IS_VULKAN_IMAGE_MEMORY_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VULKAN_IMAGE_MEMORY_ALLOCATOR))
36 #define GST_IS_VULKAN_IMAGE_MEMORY_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_VULKAN_IMAGE_MEMORY_ALLOCATOR))
37 #define GST_VULKAN_IMAGE_MEMORY_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VULKAN_MEMORY_ALLOCATOR, GstVulkanImageMemoryAllocatorClass))
38 #define GST_VULKAN_IMAGE_MEMORY_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VULKAN_MEMORY_ALLOCATOR, GstVulkanImageMemoryAllocator))
39 #define GST_VULKAN_IMAGE_MEMORY_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_VULKAN_MEMORY_ALLOCATOR, GstVulkanImageMemoryAllocatorClass))
40 /**
41 * GST_VULKAN_IMAGE_MEMORY_ALLOCATOR_CAST:
42 *
43 * Since: 1.18
44 */
45 #define GST_VULKAN_IMAGE_MEMORY_ALLOCATOR_CAST(obj) ((GstVulkanImageMemoryAllocator *)(obj))
46
47 /**
48 * GST_VULKAN_IMAGE_MEMORY_ALLOCATOR_NAME:
49 *
50 * Since: 1.18
51 */
52 #define GST_VULKAN_IMAGE_MEMORY_ALLOCATOR_NAME "VulkanImage"
53 /**
54 * GST_CAPS_FEATURE_MEMORY_VULKAN_IMAGE:
55 *
56 * Since: 1.18
57 */
58 #define GST_CAPS_FEATURE_MEMORY_VULKAN_IMAGE "memory:VulkanImage"
59
60 /**
61 * GstVulkanBarrierImageInfo:
62 * @parent: parent #GstVulkanBarrierMemoryInfo
63 * @image_layout: the image layout of this barrier
64 * @subresource_range: what subresource the barrier applies to
65 *
66 * Since: 1.18
67 */
68 struct _GstVulkanBarrierImageInfo
69 {
70 GstVulkanBarrierMemoryInfo parent;
71
72 VkImageLayout image_layout;
73 /* FIXME: multiple layers or mipmap levels may require multiple barriers */
74 VkImageSubresourceRange subresource_range;
75 };
76
77 /**
78 * GstVulkanImageMemory:
79 * @parent: parent #GstMemory
80 * @device: the #GstVulkanDevice to allocate images from
81 * @image: the Vulkan image handle
82 * @vk_mem: the backing #GstVulkanMemory for @image
83 * @create_info: creation information for @image
84 * @requirements: memory requirements for @image
85 * @format_properties: format properties
86 * @usage: intended usage for @image
87 * @barrier: last set barrier for @image
88 *
89 * Since: 1.18
90 */
91 struct _GstVulkanImageMemory
92 {
93 GstMemory parent;
94
95 GstVulkanDevice * device;
96
97 VkImage image;
98 GstVulkanMemory *vk_mem;
99
100 VkImageCreateInfo create_info;
101 VkMemoryRequirements requirements;
102 VkImageFormatProperties format_properties;
103 VkImageUsageFlags usage;
104
105 GstVulkanBarrierImageInfo barrier;
106
107 /* <private> */
108 GMutex lock;
109 gboolean wrapped;
110 GDestroyNotify notify;
111 gpointer user_data;
112
113 GPtrArray *views;
114 GPtrArray *outstanding_views;
115
116 gpointer _padding[GST_PADDING];
117 };
118
119 /**
120 * GstVulkanImageMemoryFindViewFunc:
121 *
122 * Function definition used to find views. Return %TRUE if @view matches the
123 * criteria.
124 *
125 * Since: 1.18
126 */
127 typedef gboolean (*GstVulkanImageMemoryFindViewFunc) (GstVulkanImageView * view, gpointer user_data);
128
129 /**
130 * GstVulkanImageMemoryAllocator
131 * @parent: the parent #GstAllocator
132 *
133 * Opaque #GstVulkanImageMemoryAllocator struct
134 *
135 * Since: 1.18
136 */
137 struct _GstVulkanImageMemoryAllocator
138 {
139 GstAllocator parent;
140
141 /* <private> */
142 gpointer _reserved [GST_PADDING];
143 };
144
145 /**
146 * GstVulkanImageMemoryAllocatorClass:
147 * @parent_class: the parent #GstAllocatorClass
148 *
149 * The #GstVulkanImageMemoryAllocatorClass only contains private data
150 *
151 * Since: 1.18
152 */
153 struct _GstVulkanImageMemoryAllocatorClass
154 {
155 GstAllocatorClass parent_class;
156
157 /* <private> */
158 gpointer _reserved [GST_PADDING];
159 };
160
161 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVulkanImageMemoryAllocator, gst_object_unref);
162
163 GST_VULKAN_API
164 void gst_vulkan_image_memory_init_once (void);
165 GST_VULKAN_API
166 gboolean gst_is_vulkan_image_memory (GstMemory * mem);
167
168 GST_VULKAN_API
169 gboolean gst_vulkan_image_memory_init (GstVulkanImageMemory * mem,
170 GstAllocator * allocator,
171 GstMemory * parent,
172 GstVulkanDevice * device,
173 VkFormat format,
174 VkImageUsageFlags usage,
175 VkImageLayout initial_layout,
176 GstAllocationParams * params,
177 gsize size,
178 gpointer user_data,
179 GDestroyNotify notify);
180
181 GST_VULKAN_API
182 GstMemory * gst_vulkan_image_memory_alloc_with_image_info
183 (GstVulkanDevice * device,
184 VkImageCreateInfo * image_info,
185 VkMemoryPropertyFlags mem_prop_flags);
186
187 GST_VULKAN_API
188 GstMemory * gst_vulkan_image_memory_alloc (GstVulkanDevice * device,
189 VkFormat format,
190 gsize width,
191 gsize height,
192 VkImageTiling tiling,
193 VkImageUsageFlags usage,
194 VkMemoryPropertyFlags mem_prop_flags);
195
196 GST_VULKAN_API
197 GstMemory * gst_vulkan_image_memory_wrapped (GstVulkanDevice * device,
198 VkImage image,
199 VkFormat format,
200 gsize width,
201 gsize height,
202 VkImageTiling tiling,
203 VkImageUsageFlags usage,
204 gpointer user_data,
205 GDestroyNotify notify);
206
207 GST_VULKAN_API
208 guint32 gst_vulkan_image_memory_get_width (GstVulkanImageMemory * image);
209 GST_VULKAN_API
210 guint32 gst_vulkan_image_memory_get_height (GstVulkanImageMemory * image);
211
212 GST_VULKAN_API
213 GstVulkanImageView *gst_vulkan_image_memory_find_view (GstVulkanImageMemory * image,
214 GstVulkanImageMemoryFindViewFunc find_func,
215 gpointer user_data) G_GNUC_WARN_UNUSED_RESULT;
216 GST_VULKAN_API
217 void gst_vulkan_image_memory_add_view (GstVulkanImageMemory * image,
218 GstVulkanImageView * view);
219
220
221 G_END_DECLS
222
223 #endif /* __GST_VULKAN_IMAGE_MEMORY_H__ */