return ret;
}
+#if GLIB_SIZEOF_VOID_P == 8
+# define VK_NON_DISPATCHABLE_HANDLE_FORMAT "p"
+# define GstVulkanHandleType void *
+# define PUSH_NON_DISPATCHABLE_HANDLE_TO_GPOINTER(pointer, handle) pointer = (gpointer) handle
+# define TAKE_NON_DISPATCHABLE_HANDLE_FROM_GPOINTER(handle, type, pointer) handle = (type) pointer
+#else
+# define VK_NON_DISPATCHABLE_HANDLE_FORMAT G_GUINT64_FORMAT
+# define GstVulkanHandleType guint64
+# define PUSH_NON_DISPATCHABLE_HANDLE_TO_GPOINTER(pointer, handle) \
+ G_STMT_START { \
+ pointer = g_new0(guint64, 1); \
+ *((GstVulkanHandleType *) pointer) = (GstVulkanHandleType) handle; \
+ } G_STMT_END
+# define TAKE_NON_DISPATCHABLE_HANDLE_FROM_GPOINTER(handle, type, pointer) \
+ G_STMT_START { \
+ handle = *((type *) pointer); \
+ g_free (pointer); \
+ } G_STMT_END
+#endif
+
#define FREE_DESTROY_FUNC(func, type, type_name) \
static void \
-G_PASTE(_free_,type_name) (GstVulkanDevice * device, type resource) \
+G_PASTE(_free_,type_name) (GstVulkanDevice * device, gpointer resource_handle) \
{ \
- GST_TRACE_OBJECT (device, "Freeing vulkan " G_STRINGIFY (type) " %p", resource); \
+ type resource; \
+ TAKE_NON_DISPATCHABLE_HANDLE_FROM_GPOINTER(resource, type, resource_handle); \
+ GST_TRACE_OBJECT (device, "Freeing vulkan " G_STRINGIFY (type) \
+ " %" VK_NON_DISPATCHABLE_HANDLE_FORMAT, resource); \
func (device->device, resource, NULL); \
} \
GstVulkanTrash * \
type type_name) \
{ \
GstVulkanTrash *trash; \
- g_return_val_if_fail (type_name != VK_NULL_HANDLE, NULL); \
+ gpointer handle_data; \
+ PUSH_NON_DISPATCHABLE_HANDLE_TO_GPOINTER(handle_data, type_name); \
+ g_return_val_if_fail (type_name != VK_NULL_HANDLE, VK_NULL_HANDLE); \
trash = gst_vulkan_trash_new (fence, \
- (GstVulkanTrashNotify) G_PASTE(_free_,type_name), type_name); \
+ (GstVulkanTrashNotify) G_PASTE(_free_,type_name), handle_data); \
return trash; \
}
static void \
G_PASTE(_free_,type_name) (GstVulkanDevice * device, struct G_PASTE(free_parent_info_,type_name) *info) \
{ \
- GST_TRACE_OBJECT (device, "Freeing vulkan " G_STRINGIFY (type) " %p", info->resource); \
+ GST_TRACE_OBJECT (device, "Freeing vulkan " G_STRINGIFY (type) \
+ " %" VK_NON_DISPATCHABLE_HANDLE_FORMAT, info->resource); \
func (device->device, info->parent, 1, &info->resource); \
g_free (info); \
} \
{ \
struct G_PASTE(free_parent_info_,type_name) *info; \
GstVulkanTrash *trash; \
- g_return_val_if_fail (type_name != VK_NULL_HANDLE, NULL); \
+ g_return_val_if_fail (type_name != VK_NULL_HANDLE, VK_NULL_HANDLE); \
info = g_new0 (struct G_PASTE(free_parent_info_,type_name), 1); \
/* FIXME: keep parent alive ? */\
info->parent = parent; \
- info->resource = (gpointer) type_name; \
+ info->resource = (GstVulkanHandleType) type_name; \
trash = gst_vulkan_trash_new (fence, \
(GstVulkanTrashNotify) G_PASTE(_free_,type_name), info); \
return trash; \