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_FENCE_H__
22 #define __GST_VULKAN_FENCE_H__
23
24 #include <gst/vulkan/gstvkhandlepool.h>
25
26 G_BEGIN_DECLS
27
28 /**
29 * GST_TYPE_VULKAN_FENCE:
30 *
31 * Since: 1.18
32 */
33 #define GST_TYPE_VULKAN_FENCE (gst_vulkan_fence_get_type ())
34 GST_VULKAN_API
35 GType gst_vulkan_fence_get_type (void);
36
37 /**
38 * GST_VULKAN_FENCE_CAST:
39 *
40 * Since: 1.18
41 */
42 #define GST_VULKAN_FENCE_CAST(f) ((GstVulkanFence *) f)
43 /**
44 * GST_VULKAN_FENCE_FENCE:
45 *
46 * Since: 1.18
47 */
48 #define GST_VULKAN_FENCE_FENCE(f) (GST_VULKAN_FENCE_CAST(f)->fence)
49
50 /**
51 * GstVulkanFence:
52 * @parent: the parent #GstMiniObject
53 * @device: the #GstVulkanDevice this fence is allocated from
54 * @cache: the parent #GstVulkanFenceCache for fence reuse
55 * @fence: the vulkan fence handle
56 *
57 * Since: 1.18
58 */
59 struct _GstVulkanFence
60 {
61 GstMiniObject parent;
62
63 GstVulkanDevice *device;
64 GstVulkanFenceCache *cache;
65
66 VkFence fence;
67
68 /* <private> */
69 gpointer _reserved [GST_PADDING];
70 };
71
72 GST_VULKAN_API
73 GstVulkanFence * gst_vulkan_fence_new (GstVulkanDevice * device,
74 GError ** error);
75 GST_VULKAN_API
76 void gst_vulkan_fence_reset (GstVulkanFence * fence);
77
78 GST_VULKAN_API
79 GstVulkanFence * gst_vulkan_fence_new_always_signalled (GstVulkanDevice *device);
80
81 GST_VULKAN_API
82 gboolean gst_vulkan_fence_is_signaled (GstVulkanFence * fence);
83
84 static inline GstVulkanFence *
gst_vulkan_fence_ref(GstVulkanFence * fence)85 gst_vulkan_fence_ref (GstVulkanFence * fence)
86 {
87 return GST_VULKAN_FENCE_CAST (gst_mini_object_ref (GST_MINI_OBJECT_CAST (fence)));
88 }
89
90 static inline void
gst_vulkan_fence_unref(GstVulkanFence * fence)91 gst_vulkan_fence_unref (GstVulkanFence * fence)
92 {
93 gst_mini_object_unref (GST_MINI_OBJECT_CAST (fence));
94 }
95
96 GST_VULKAN_API
97 GType gst_vulkan_fence_cache_get_type (void);
98 #define GST_TYPE_VULKAN_FENCE_CACHE (gst_vulkan_fence_cache_get_type())
99 #define GST_VULKAN_FENCE_CACHE(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_VULKAN_FENCE_CACHE, GstVulkanFenceCache))
100 #define GST_VULKAN_FENCE_CACHE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GST_TYPE_VULKAN_FENCE_CACHE, GstVulkanFenceCacheClass))
101 #define GST_IS_VULKAN_FENCE_CACHE(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_VULKAN_FENCE_CACHE))
102 #define GST_IS_VULKAN_FENCE_CACHE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_VULKAN_FENCE_CACHE))
103 #define GST_VULKAN_FENCE_CACHE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_VULKAN_FENCE_CACHE, GstVulkanFenceCacheClass))
104
105 /**
106 * GstVulkanFenceCache:
107 * @parent: the parent #GstVulkanHandlePool
108 *
109 * Since: 1.18
110 */
111 struct _GstVulkanFenceCache
112 {
113 GstVulkanHandlePool parent;
114
115 /* <private> */
116 gpointer _reserved [GST_PADDING];
117 };
118
119 /**
120 * GstVulkanFenceCacheClass:
121 * @parent_class: the parent #GstVulkanHandlePoolClass
122 *
123 * Since: 1.18
124 */
125 struct _GstVulkanFenceCacheClass
126 {
127 GstVulkanHandlePoolClass parent_class;
128
129 /* <private> */
130 gpointer _reserved [GST_PADDING];
131 };
132
133 GstVulkanFenceCache * gst_vulkan_fence_cache_new (GstVulkanDevice * device);
134
135 /**
136 * gst_vulkan_fence_cache_acquire:
137 * @o: the #GstVulkanFenceCache
138 * @e: a #GError
139 *
140 * A helper define for internally calling @gst_vulkan_handle_pool_acquire()
141 *
142 * Since: 1.18
143 */
144 #define gst_vulkan_fence_cache_acquire(o,e) (GstVulkanFence *) gst_vulkan_handle_pool_acquire (GST_VULKAN_HANDLE_POOL (o),e);
145
146 G_END_DECLS
147
148 #endif /* __GST_VULKAN_FENCE_H__ */
149