vulkan: fix non-dispatchable handles on 32-bit platforms

non-dispatchable handles are 64-bit integers on 32-bit platforms
This commit is contained in:
Matthew Waters 2019-10-16 17:47:33 +11:00 committed by GStreamer Merge Bot
parent 7a1bb3001a
commit f738c1f138

View file

@ -89,11 +89,34 @@ gst_vulkan_trash_new (GstVulkanFence * fence, GstVulkanTrashNotify notify,
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 * \
@ -101,9 +124,11 @@ G_PASTE(gst_vulkan_trash_new_free_,type_name) (GstVulkanFence * fence, \
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; \
}
@ -125,7 +150,8 @@ struct G_PASTE(free_parent_info_,type_name) \
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); \
} \
@ -135,11 +161,11 @@ G_PASTE(gst_vulkan_trash_new_free_,type_name) (GstVulkanFence * fence, \
{ \
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; \