• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * GStreamer
3  * Copyright (C) 2016 Matthew Waters <matthew@centricular.com>
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_TRASH_H__
22 #define __GST_VULKAN_TRASH_H__
23 
24 #include <gst/vulkan/vulkan.h>
25 
26 G_BEGIN_DECLS
27 
28 /**
29  * GstVulkanTrashNotify:
30  * @device: the #GstVulkanDevice
31  * @user_data: user data
32  *
33  * Since: 1.18
34  */
35 typedef void (*GstVulkanTrashNotify) (GstVulkanDevice * device, gpointer user_data);
36 
37 /**
38  * GstVulkanTrash:
39  *
40  * Since: 1.18
41  */
42 struct _GstVulkanTrash
43 {
44   GstMiniObject         parent;
45 
46   GstVulkanTrashList   *cache;
47 
48   GstVulkanFence       *fence;
49 
50   GstVulkanTrashNotify  notify;
51   gpointer              user_data;
52 
53   /* <private> */
54   gpointer              _padding[GST_PADDING];
55 };
56 
57 /**
58  * GST_TYPE_VULKAN_TRASH:
59  *
60  * Since: 1.18
61  */
62 #define GST_TYPE_VULKAN_TRASH gst_vulkan_trash_get_type()
63 GST_VULKAN_API
64 GType               gst_vulkan_trash_get_type (void);
65 
66 /**
67  * gst_vulkan_trash_ref: (skip)
68  * @trash: a #GstVulkanTrash.
69  *
70  * Increases the refcount of the given trash object by one.
71  *
72  * Returns: (transfer full): @trash
73  *
74  * Since: 1.18
75  */
76 static inline GstVulkanTrash* gst_vulkan_trash_ref(GstVulkanTrash* trash);
77 static inline GstVulkanTrash *
gst_vulkan_trash_ref(GstVulkanTrash * trash)78 gst_vulkan_trash_ref (GstVulkanTrash * trash)
79 {
80   return (GstVulkanTrash *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (trash));
81 }
82 
83 /**
84  * gst_vulkan_trash_unref: (skip)
85  * @trash: (transfer full): a #GstVulkanTrash.
86  *
87  * Decreases the refcount of the trash object. If the refcount reaches 0, the
88  * trash will be freed.
89  *
90  * Since: 1.18
91  */
92 static inline void gst_vulkan_trash_unref(GstVulkanTrash* trash);
93 static inline void
gst_vulkan_trash_unref(GstVulkanTrash * trash)94 gst_vulkan_trash_unref (GstVulkanTrash * trash)
95 {
96   gst_mini_object_unref (GST_MINI_OBJECT_CAST (trash));
97 }
98 
99 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVulkanTrash, gst_vulkan_trash_unref)
100 
101 GST_VULKAN_API
102 GstVulkanTrash *    gst_vulkan_trash_new                            (GstVulkanFence * fence,
103                                                                      GstVulkanTrashNotify notify,
104                                                                      gpointer user_data);
105 GST_VULKAN_API
106 void                gst_vulkan_trash_mini_object_unref              (GstVulkanDevice * device,
107                                                                      gpointer user_data);
108 GST_VULKAN_API
109 void                gst_vulkan_trash_object_unref                   (GstVulkanDevice * device,
110                                                                      gpointer user_data);
111 GST_VULKAN_API
112 GstVulkanTrash *    gst_vulkan_trash_new_free_semaphore             (GstVulkanFence * fence,
113                                                                      VkSemaphore semaphore);
114 
115 /**
116  * gst_vulkan_trash_new_object_unref:
117  * @fence: the #GstVulkanFence
118  * @object: a #GstObject to unref
119  *
120  * Returns: (transfer full): a new #GstVulkanTrash object that will the unref
121  *     @object when @fence is signalled
122  *
123  * Since: 1.18
124  */
125 static inline GstVulkanTrash *
gst_vulkan_trash_new_object_unref(GstVulkanFence * fence,GstObject * object)126 gst_vulkan_trash_new_object_unref (GstVulkanFence * fence, GstObject * object)
127 {
128   g_return_val_if_fail (GST_IS_OBJECT (object), NULL);
129   return gst_vulkan_trash_new (fence,
130       (GstVulkanTrashNotify) gst_vulkan_trash_object_unref, (gpointer) object);
131 }
132 
133 /**
134  * gst_vulkan_trash_new_mini_object_unref:
135  * @fence: the #GstVulkanFence
136  * @object: a #GstMiniObject to unref
137  *
138  * Returns: (transfer full): a new #GstVulkanTrash object that will the unref
139  *     @object when @fence is signalled
140  *
141  * Since: 1.18
142  */
143 static inline GstVulkanTrash *
gst_vulkan_trash_new_mini_object_unref(GstVulkanFence * fence,GstMiniObject * object)144 gst_vulkan_trash_new_mini_object_unref (GstVulkanFence * fence, GstMiniObject * object)
145 {
146   return gst_vulkan_trash_new (fence,
147       (GstVulkanTrashNotify) gst_vulkan_trash_mini_object_unref, (gpointer) object);
148 }
149 
150 GST_VULKAN_API
151 GType gst_vulkan_trash_list_get_type (void);
152 /**
153  * GST_TYPE_VULKAN_TRASH_LIST:
154  *
155  * Since: 1.18
156  */
157 #define GST_TYPE_VULKAN_TRASH_LIST gst_vulkan_trash_list_get_type()
158 #define GST_VULKAN_TRASH_LIST(obj)              (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VULKAN_TRASH_LIST,GstVulkanTrashList))
159 #define GST_VULKAN_TRASH_LIST_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VULKAN_TRASH_LIST,GstVulkanTrashListClass))
160 #define GST_VULKAN_TRASH_LIST_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_VULKAN_TRASH_LIST,GstVulkanTrashListClass))
161 #define GST_IS_VULKAN_TRASH_LIST(obj)           (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VULKAN_TRASH_LIST))
162 #define GST_IS_VULKAN_TRASH_LIST_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VULKAN_TRASH_LIST))
163 
164 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVulkanTrashList, gst_object_unref)
165 
166 /**
167  * GstVulkanTrashList:
168  * @parent: the parent #GstVulkanHandle
169  *
170  * Since: 1.18
171  */
172 struct _GstVulkanTrashList
173 {
174   GstVulkanHandlePool parent;
175 
176   /* <private> */
177   gpointer _reserved        [GST_PADDING];
178 };
179 
180 /**
181  * GstVulkanTrashListGC:
182  * @trash_list: the #GstVulkanTrashList instance
183  *
184  * Remove any memory allocated by any signalled objects.
185  *
186  * Since: 1.18
187  */
188 typedef void        (*GstVulkanTrashListGC)     (GstVulkanTrashList * trash_list);
189 
190 /**
191  * GstVulkanTrashListAdd:
192  * @trash_list: the #GstVulkanTrashList instance
193  * @trash: the #GstVulkanTrash to add to @trash_list
194  *
195  * Add @trash to @trash_list for tracking
196  *
197  * Returns: whether @trash could be added to @trash_list
198  *
199  * Since: 1.18
200  */
201 typedef gboolean    (*GstVulkanTrashListAdd)    (GstVulkanTrashList * trash_list, GstVulkanTrash * trash);
202 
203 /**
204  * GstVulkanTrashListWait:
205  * @trash_list: the #GstVulkanTrashList instance
206  * @timeout: the timeout in ns to wait
207  *
208  * Wait for a most @timeout to pass for all #GstVulkanTrash objects to be
209  * signalled and freed.
210  *
211  * Returns: whether all objects were signalled and freed within the @timeout
212  *
213  * Since: 1.18
214  */
215 typedef gboolean    (*GstVulkanTrashListWait)   (GstVulkanTrashList * trash_list, guint64 timeout);
216 
217 /**
218  * GstVulkanTrashListClass:
219  * @parent_class: the #GstVulkanHandlePoolClass
220  * @add_func: the #GstVulkanTrashListAdd functions
221  * @gc_func: the #GstVulkanTrashListGC function
222  * @wait_func: the #GstVulkanTrashListWait function
223  *
224  * Since: 1.18
225  */
226 struct _GstVulkanTrashListClass
227 {
228   GstVulkanHandlePoolClass  parent_class;
229 
230   GstVulkanTrashListAdd     add_func;
231   GstVulkanTrashListGC      gc_func;
232   GstVulkanTrashListWait    wait_func;
233 
234   /* <private> */
235   gpointer _reserved        [GST_PADDING];
236 };
237 
238 GST_VULKAN_API
239 void                gst_vulkan_trash_list_gc                        (GstVulkanTrashList * trash_list);
240 GST_VULKAN_API
241 gboolean            gst_vulkan_trash_list_wait                      (GstVulkanTrashList * trash_list,
242                                                                      guint64 timeout);
243 GST_VULKAN_API
244 gboolean            gst_vulkan_trash_list_add                       (GstVulkanTrashList * trash_list,
245                                                                      GstVulkanTrash * trash);
246 GST_VULKAN_API
247 GstVulkanTrash *    gst_vulkan_trash_list_acquire                   (GstVulkanTrashList * trash_list,
248                                                                      GstVulkanFence * fence,
249                                                                      GstVulkanTrashNotify notify,
250                                                                      gpointer user_data);
251 /**
252  * GstVulkanTrashFenceList:
253  *
254  * Since: 1.18
255  */
256 /**
257  * GstVulkanTrashFenceListClass:
258  *
259  * Since: 1.18
260  */
261 GST_VULKAN_API
262 G_DECLARE_FINAL_TYPE (GstVulkanTrashFenceList, gst_vulkan_trash_fence_list, GST, VULKAN_TRASH_FENCE_LIST, GstVulkanTrashList);
263 GST_VULKAN_API
264 GstVulkanTrashList * gst_vulkan_trash_fence_list_new                (void);
265 
266 G_END_DECLS
267 
268 #endif /* __GST_VULKAN_TRASH_H__ */
269