mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-26 17:18:15 +00:00
vulkan: remove the private struct from the public struct
Remove any references to CamelTypePrivate from the public CamelType struct. They can be accessed as needed using camel_type_get_instance_private().
This commit is contained in:
parent
32b3387ae6
commit
670d0a8e88
25 changed files with 347 additions and 321 deletions
|
@ -53,9 +53,7 @@ struct _GstVulkanWindowCocoa
|
|||
|
||||
PFN_vkCreateMacOSSurfaceMVK CreateMacOSSurface;
|
||||
|
||||
/*< private >*/
|
||||
GstVulkanWindowCocoaPrivate *priv;
|
||||
|
||||
/*< private >*/
|
||||
gpointer _reserved[GST_PADDING];
|
||||
};
|
||||
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
|
||||
#include "gstvkcocoa_utils.h"
|
||||
|
||||
#define GST_VULKAN_WINDOW_COCOA_GET_PRIVATE(o) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE((o), GST_TYPE_VULKAN_WINDOW_COCOA, GstVulkanWindowCocoaPrivate))
|
||||
#define GET_PRIV(o) gst_vulkan_window_cocoa_get_instance_private (o)
|
||||
|
||||
#define GST_CAT_DEFAULT gst_vulkan_window_cocoa_debug
|
||||
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
||||
|
@ -106,10 +105,10 @@ gst_vulkan_window_cocoa_class_init (GstVulkanWindowCocoaClass * klass)
|
|||
static void
|
||||
gst_vulkan_window_cocoa_init (GstVulkanWindowCocoa * window)
|
||||
{
|
||||
window->priv = gst_vulkan_window_cocoa_get_instance_private (window);
|
||||
GstVulkanWindowCocoaPrivate *priv = GET_PRIV (window);
|
||||
|
||||
window->priv->preferred_width = 320;
|
||||
window->priv->preferred_height = 240;
|
||||
priv->preferred_width = 320;
|
||||
priv->preferred_height = 240;
|
||||
}
|
||||
|
||||
/* Must be called in the gl thread */
|
||||
|
@ -138,7 +137,7 @@ static void
|
|||
_show_window (gpointer data)
|
||||
{
|
||||
GstVulkanWindowCocoa *window_cocoa = GST_VULKAN_WINDOW_COCOA (data);
|
||||
GstVulkanWindowCocoaPrivate *priv = window_cocoa->priv;
|
||||
GstVulkanWindowCocoaPrivate *priv = GET_PRIV (window_cocoa);
|
||||
GstVulkanNSWindow *internal_win_id = (__bridge GstVulkanNSWindow *)priv->internal_win_id;
|
||||
|
||||
GST_DEBUG_OBJECT (window_cocoa, "showing");
|
||||
|
@ -153,7 +152,7 @@ static void
|
|||
gst_vulkan_window_cocoa_show (GstVulkanWindow * window)
|
||||
{
|
||||
GstVulkanWindowCocoa *window_cocoa = GST_VULKAN_WINDOW_COCOA (window);
|
||||
GstVulkanWindowCocoaPrivate *priv = window_cocoa->priv;
|
||||
GstVulkanWindowCocoaPrivate *priv = GET_PRIV (window_cocoa);
|
||||
|
||||
if (!priv->visible)
|
||||
_invoke_on_main ((GstVulkanWindowFunc) _show_window, gst_object_ref (window),
|
||||
|
@ -171,7 +170,7 @@ gst_vulkan_window_cocoa_hide (GstVulkanWindow * window)
|
|||
static void
|
||||
_create_window (GstVulkanWindowCocoa * window_cocoa)
|
||||
{
|
||||
GstVulkanWindowCocoaPrivate *priv = window_cocoa->priv;
|
||||
GstVulkanWindowCocoaPrivate *priv = GET_PRIV (window_cocoa);
|
||||
NSRect mainRect = [[NSScreen mainScreen] visibleFrame];
|
||||
gint h = priv->preferred_height;
|
||||
gint y = mainRect.size.height > h ? (mainRect.size.height - h) * 0.5 : 0;
|
||||
|
@ -210,6 +209,7 @@ static VkSurfaceKHR
|
|||
gst_vulkan_window_cocoa_get_surface (GstVulkanWindow * window, GError ** error)
|
||||
{
|
||||
GstVulkanWindowCocoa *window_cocoa = GST_VULKAN_WINDOW_COCOA (window);
|
||||
GstVulkanWindowCocoaPrivate *priv = GET_PRIV (window_cocoa);
|
||||
VkMacOSSurfaceCreateInfoMVK info = { 0, };
|
||||
VkSurfaceKHR ret;
|
||||
VkResult err;
|
||||
|
@ -217,7 +217,7 @@ gst_vulkan_window_cocoa_get_surface (GstVulkanWindow * window, GError ** error)
|
|||
info.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
|
||||
info.pNext = NULL;
|
||||
info.flags = 0;
|
||||
info.pView = window_cocoa->priv->internal_view;
|
||||
info.pView = priv->internal_view;
|
||||
|
||||
if (!window_cocoa->CreateMacOSSurface)
|
||||
window_cocoa->CreateMacOSSurface =
|
||||
|
@ -261,16 +261,17 @@ _close_window (gpointer * data)
|
|||
{
|
||||
GstVulkanWindowCocoa *window_cocoa = GST_VULKAN_WINDOW_COCOA (data);
|
||||
GstVulkanWindow *window = GST_VULKAN_WINDOW (window_cocoa);
|
||||
GstVulkanWindowCocoaPrivate *priv = GET_PRIV (window_cocoa);
|
||||
GstVulkanNSWindow *internal_win_id =
|
||||
(__bridge GstVulkanNSWindow *) window_cocoa->priv->internal_win_id;
|
||||
(__bridge GstVulkanNSWindow *) priv->internal_win_id;
|
||||
|
||||
gst_vulkan_window_cocoa_hide (window);
|
||||
|
||||
[[internal_win_id contentView] removeFromSuperview];
|
||||
CFBridgingRelease (window_cocoa->priv->internal_win_id);
|
||||
window_cocoa->priv->internal_win_id = NULL;
|
||||
CFBridgingRelease (window_cocoa->priv->internal_view);
|
||||
window_cocoa->priv->internal_view = NULL;
|
||||
CFBridgingRelease (priv->internal_win_id);
|
||||
priv->internal_win_id = NULL;
|
||||
CFBridgingRelease (priv->internal_view);
|
||||
priv->internal_view = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -325,7 +326,7 @@ gst_vulkan_window_cocoa_close (GstVulkanWindow * window)
|
|||
|
||||
- (BOOL) windowShouldClose:(id)sender {
|
||||
|
||||
GstVulkanWindowCocoaPrivate *priv = window_cocoa->priv;
|
||||
GstVulkanWindowCocoaPrivate *priv = GET_PRIV (window_cocoa);
|
||||
GstVulkanNSWindow *internal_win_id = (__bridge GstVulkanNSWindow *)priv->internal_win_id;
|
||||
GST_DEBUG ("user clicked the close button\n");
|
||||
[internal_win_id setClosed];
|
||||
|
|
|
@ -52,6 +52,8 @@ static void gst_vulkan_buffer_pool_finalize (GObject * object);
|
|||
GST_DEBUG_CATEGORY_STATIC (GST_CAT_VULKAN_BUFFER_POOL);
|
||||
#define GST_CAT_DEFAULT GST_CAT_VULKAN_BUFFER_POOL
|
||||
|
||||
#define GET_PRIV(pool) gst_vulkan_buffer_pool_get_instance_private (pool)
|
||||
|
||||
#define gst_vulkan_buffer_pool_parent_class parent_class
|
||||
G_DEFINE_TYPE_WITH_CODE (GstVulkanBufferPool, gst_vulkan_buffer_pool,
|
||||
GST_TYPE_BUFFER_POOL, G_ADD_PRIVATE (GstVulkanBufferPool)
|
||||
|
@ -72,7 +74,7 @@ static gboolean
|
|||
gst_vulkan_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
|
||||
{
|
||||
GstVulkanBufferPool *vk_pool = GST_VULKAN_BUFFER_POOL_CAST (pool);
|
||||
GstVulkanBufferPoolPrivate *priv = vk_pool->priv;
|
||||
GstVulkanBufferPoolPrivate *priv = GET_PRIV (vk_pool);
|
||||
guint min_buffers, max_buffers;
|
||||
GstCaps *caps = NULL;
|
||||
gboolean ret = TRUE;
|
||||
|
@ -136,7 +138,7 @@ gst_vulkan_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
|
|||
GstBufferPoolAcquireParams * params)
|
||||
{
|
||||
GstVulkanBufferPool *vk_pool = GST_VULKAN_BUFFER_POOL_CAST (pool);
|
||||
GstVulkanBufferPoolPrivate *priv = vk_pool->priv;
|
||||
GstVulkanBufferPoolPrivate *priv = GET_PRIV (vk_pool);
|
||||
GstBuffer *buf;
|
||||
guint i;
|
||||
|
||||
|
@ -223,14 +225,13 @@ gst_vulkan_buffer_pool_class_init (GstVulkanBufferPoolClass * klass)
|
|||
static void
|
||||
gst_vulkan_buffer_pool_init (GstVulkanBufferPool * pool)
|
||||
{
|
||||
pool->priv = gst_vulkan_buffer_pool_get_instance_private (pool);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vulkan_buffer_pool_finalize (GObject * object)
|
||||
{
|
||||
GstVulkanBufferPool *pool = GST_VULKAN_BUFFER_POOL_CAST (object);
|
||||
GstVulkanBufferPoolPrivate *priv = pool->priv;
|
||||
GstVulkanBufferPoolPrivate *priv = GET_PRIV (pool);
|
||||
|
||||
GST_LOG_OBJECT (pool, "finalize Vulkan buffer pool %p", pool);
|
||||
|
||||
|
|
|
@ -46,8 +46,6 @@ struct _GstVulkanBufferPool
|
|||
GstBufferPool bufferpool;
|
||||
|
||||
GstVulkanDevice *device;
|
||||
|
||||
GstVulkanBufferPoolPrivate *priv;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -34,10 +34,7 @@
|
|||
|
||||
#define GST_VULKAN_COMMAND_POOL_LARGE_OUTSTANDING 1024
|
||||
|
||||
#define GET_PRIV(pool) G_TYPE_INSTANCE_GET_PRIVATE(pool, GST_TYPE_VULKAN_COMMAND_POOL, GstVulkanCommandPoolPrivate)
|
||||
|
||||
#define GST_VULKAN_COMMAND_POOL_LOCK(pool) (g_rec_mutex_lock(&GET_PRIV(pool)->rec_mutex))
|
||||
#define GST_VULKAN_COMMAND_POOL_UNLOCK(pool) (g_rec_mutex_unlock(&GET_PRIV(pool)->rec_mutex))
|
||||
#define GET_PRIV(pool) gst_vulkan_command_pool_get_instance_private (pool)
|
||||
|
||||
#define GST_CAT_DEFAULT gst_vulkan_command_pool_debug
|
||||
GST_DEBUG_CATEGORY (GST_CAT_DEFAULT);
|
||||
|
@ -88,10 +85,10 @@ gst_vulkan_command_pool_finalize (GObject * object)
|
|||
GstVulkanCommandPool *pool = GST_VULKAN_COMMAND_POOL (object);
|
||||
GstVulkanCommandPoolPrivate *priv = GET_PRIV (pool);
|
||||
|
||||
GST_VULKAN_COMMAND_POOL_LOCK (pool);
|
||||
gst_vulkan_command_pool_lock (pool);
|
||||
g_queue_free_full (priv->available, (GDestroyNotify) do_free_buffer);
|
||||
priv->available = NULL;
|
||||
GST_VULKAN_COMMAND_POOL_UNLOCK (pool);
|
||||
gst_vulkan_command_pool_unlock (pool);
|
||||
|
||||
if (priv->outstanding > 0)
|
||||
g_critical
|
||||
|
@ -138,9 +135,9 @@ command_alloc (GstVulkanCommandPool * pool, GError ** error)
|
|||
cmd_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
|
||||
cmd_info.commandBufferCount = 1;
|
||||
|
||||
GST_VULKAN_COMMAND_POOL_LOCK (pool);
|
||||
gst_vulkan_command_pool_lock (pool);
|
||||
err = vkAllocateCommandBuffers (pool->queue->device->device, &cmd_info, &cmd);
|
||||
GST_VULKAN_COMMAND_POOL_UNLOCK (pool);
|
||||
gst_vulkan_command_pool_unlock (pool);
|
||||
if (gst_vulkan_error_to_g_error (err, error, "vkCreateCommandBuffer") < 0)
|
||||
return NULL;
|
||||
|
||||
|
@ -182,9 +179,9 @@ gst_vulkan_command_pool_create (GstVulkanCommandPool * pool, GError ** error)
|
|||
priv = GET_PRIV (pool);
|
||||
|
||||
if (gst_vulkan_command_pool_can_reset (pool)) {
|
||||
GST_VULKAN_COMMAND_POOL_LOCK (pool);
|
||||
gst_vulkan_command_pool_lock (pool);
|
||||
cmd = g_queue_pop_head (priv->available);
|
||||
GST_VULKAN_COMMAND_POOL_UNLOCK (pool);
|
||||
gst_vulkan_command_pool_unlock (pool);
|
||||
}
|
||||
if (!cmd)
|
||||
cmd = command_alloc (pool, error);
|
||||
|
@ -193,13 +190,13 @@ gst_vulkan_command_pool_create (GstVulkanCommandPool * pool, GError ** error)
|
|||
|
||||
cmd->pool = gst_object_ref (pool);
|
||||
|
||||
GST_VULKAN_COMMAND_POOL_LOCK (pool);
|
||||
gst_vulkan_command_pool_lock (pool);
|
||||
priv->outstanding++;
|
||||
if (priv->outstanding > GST_VULKAN_COMMAND_POOL_LARGE_OUTSTANDING)
|
||||
g_critical ("%s: There are a large number of command buffers outstanding! "
|
||||
"This usually means there is a reference counting issue somewhere.",
|
||||
GST_OBJECT_NAME (pool));
|
||||
GST_VULKAN_COMMAND_POOL_UNLOCK (pool);
|
||||
gst_vulkan_command_pool_unlock (pool);
|
||||
return cmd;
|
||||
}
|
||||
|
||||
|
@ -217,7 +214,7 @@ gst_vulkan_command_pool_release_buffer (GstVulkanCommandPool * pool,
|
|||
priv = GET_PRIV (pool);
|
||||
can_reset = gst_vulkan_command_pool_can_reset (pool);
|
||||
|
||||
GST_VULKAN_COMMAND_POOL_LOCK (pool);
|
||||
gst_vulkan_command_pool_lock (pool);
|
||||
if (can_reset) {
|
||||
vkResetCommandBuffer (buffer->cmd, 0);
|
||||
g_queue_push_tail (priv->available, buffer);
|
||||
|
@ -226,7 +223,7 @@ gst_vulkan_command_pool_release_buffer (GstVulkanCommandPool * pool,
|
|||
/* TODO: if this is a secondary command buffer, all primary command buffers
|
||||
* that reference this command buffer will be invalid */
|
||||
priv->outstanding--;
|
||||
GST_VULKAN_COMMAND_POOL_UNLOCK (pool);
|
||||
gst_vulkan_command_pool_unlock (pool);
|
||||
|
||||
/* decrease the refcount that the buffer had to us */
|
||||
gst_clear_object (&buffer->pool);
|
||||
|
@ -249,8 +246,10 @@ gst_vulkan_command_pool_release_buffer (GstVulkanCommandPool * pool,
|
|||
void
|
||||
gst_vulkan_command_pool_lock (GstVulkanCommandPool * pool)
|
||||
{
|
||||
GstVulkanCommandPoolPrivate *priv;
|
||||
g_return_if_fail (GST_IS_VULKAN_COMMAND_POOL (pool));
|
||||
GST_VULKAN_COMMAND_POOL_LOCK (pool);
|
||||
priv = GET_PRIV (pool);
|
||||
g_rec_mutex_lock (&priv->rec_mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -263,6 +262,8 @@ gst_vulkan_command_pool_lock (GstVulkanCommandPool * pool)
|
|||
void
|
||||
gst_vulkan_command_pool_unlock (GstVulkanCommandPool * pool)
|
||||
{
|
||||
GstVulkanCommandPoolPrivate *priv;
|
||||
g_return_if_fail (GST_IS_VULKAN_COMMAND_POOL (pool));
|
||||
GST_VULKAN_COMMAND_POOL_UNLOCK (pool);
|
||||
priv = GET_PRIV (pool);
|
||||
g_rec_mutex_unlock (&priv->rec_mutex);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
* @see_also: #GstVulkanDevice
|
||||
*/
|
||||
|
||||
#define GET_PRIV(cache) G_TYPE_INSTANCE_GET_PRIVATE(cache, GST_TYPE_VULKAN_DESCRIPTOR_CACHE, GstVulkanDescriptorCachePrivate)
|
||||
#define GET_PRIV(cache) gst_vulkan_descriptor_cache_get_instance_private (cache)
|
||||
|
||||
#define GST_CAT_DEFAULT gst_vulkan_descriptor_cache_debug
|
||||
GST_DEBUG_CATEGORY (GST_CAT_DEFAULT);
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
* @see_also: #GstVulkanDevice
|
||||
*/
|
||||
|
||||
#define GET_PRIV(pool) G_TYPE_INSTANCE_GET_PRIVATE(pool, GST_TYPE_VULKAN_DESCRIPTOR_POOL, GstVulkanDescriptorPoolPrivate)
|
||||
#define GET_PRIV(pool) gst_vulkan_descriptor_pool_get_instance_private (pool)
|
||||
|
||||
#define GST_CAT_DEFAULT gst_vulkan_descriptor_pool_debug
|
||||
GST_DEBUG_CATEGORY (GST_CAT_DEFAULT);
|
||||
|
@ -68,9 +68,9 @@ static void
|
|||
gst_vulkan_descriptor_pool_finalize (GObject * object)
|
||||
{
|
||||
GstVulkanDescriptorPool *pool = GST_VULKAN_DESCRIPTOR_POOL (object);
|
||||
#if 0
|
||||
GstVulkanDescriptorPoolPrivate *priv = GET_PRIV (pool);
|
||||
|
||||
#if 0
|
||||
/* FIXME: track these correctly */
|
||||
if (priv->outstanding > 0)
|
||||
g_critical
|
||||
|
|
|
@ -89,23 +89,27 @@ struct _GstVulkanDisplayPrivate
|
|||
GCond thread_cond;
|
||||
};
|
||||
|
||||
#define GET_PRIV(display) gst_vulkan_display_get_instance_private (display)
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GstVulkanDisplay, gst_vulkan_display, GST_TYPE_OBJECT,
|
||||
G_ADD_PRIVATE (GstVulkanDisplay) _init_debug ());
|
||||
|
||||
static gpointer
|
||||
_event_thread_main (GstVulkanDisplay * display)
|
||||
{
|
||||
g_mutex_lock (&display->priv->thread_lock);
|
||||
GstVulkanDisplayPrivate *priv = GET_PRIV (display);
|
||||
|
||||
g_mutex_lock (&priv->thread_lock);
|
||||
|
||||
display->main_context = g_main_context_new ();
|
||||
display->main_loop = g_main_loop_new (display->main_context, FALSE);
|
||||
|
||||
g_cond_broadcast (&display->priv->thread_cond);
|
||||
g_mutex_unlock (&display->priv->thread_lock);
|
||||
g_cond_broadcast (&priv->thread_cond);
|
||||
g_mutex_unlock (&priv->thread_lock);
|
||||
|
||||
g_main_loop_run (display->main_loop);
|
||||
|
||||
g_mutex_lock (&display->priv->thread_lock);
|
||||
g_mutex_lock (&priv->thread_lock);
|
||||
|
||||
g_main_loop_unref (display->main_loop);
|
||||
g_main_context_unref (display->main_context);
|
||||
|
@ -113,8 +117,8 @@ _event_thread_main (GstVulkanDisplay * display)
|
|||
display->main_loop = NULL;
|
||||
display->main_context = NULL;
|
||||
|
||||
g_cond_broadcast (&display->priv->thread_cond);
|
||||
g_mutex_unlock (&display->priv->thread_lock);
|
||||
g_cond_broadcast (&priv->thread_cond);
|
||||
g_mutex_unlock (&priv->thread_lock);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -131,19 +135,20 @@ gst_vulkan_display_class_init (GstVulkanDisplayClass * klass)
|
|||
static void
|
||||
gst_vulkan_display_init (GstVulkanDisplay * display)
|
||||
{
|
||||
display->priv = gst_vulkan_display_get_instance_private (display);
|
||||
GstVulkanDisplayPrivate *priv = GET_PRIV (display);
|
||||
|
||||
display->type = GST_VULKAN_DISPLAY_TYPE_ANY;
|
||||
|
||||
g_mutex_init (&display->priv->thread_lock);
|
||||
g_cond_init (&display->priv->thread_cond);
|
||||
g_mutex_init (&priv->thread_lock);
|
||||
g_cond_init (&priv->thread_cond);
|
||||
|
||||
display->priv->event_thread = g_thread_new ("vkdisplay-event",
|
||||
priv->event_thread = g_thread_new ("vkdisplay-event",
|
||||
(GThreadFunc) _event_thread_main, display);
|
||||
|
||||
g_mutex_lock (&display->priv->thread_lock);
|
||||
g_mutex_lock (&priv->thread_lock);
|
||||
while (!display->main_loop)
|
||||
g_cond_wait (&display->priv->thread_cond, &display->priv->thread_lock);
|
||||
g_mutex_unlock (&display->priv->thread_lock);
|
||||
g_cond_wait (&priv->thread_cond, &priv->thread_lock);
|
||||
g_mutex_unlock (&priv->thread_lock);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -160,19 +165,20 @@ static void
|
|||
gst_vulkan_display_finalize (GObject * object)
|
||||
{
|
||||
GstVulkanDisplay *display = GST_VULKAN_DISPLAY (object);
|
||||
GstVulkanDisplayPrivate *priv = GET_PRIV (display);
|
||||
|
||||
g_mutex_lock (&display->priv->thread_lock);
|
||||
g_mutex_lock (&priv->thread_lock);
|
||||
|
||||
if (display->main_loop)
|
||||
g_main_loop_quit (display->main_loop);
|
||||
|
||||
while (display->main_loop)
|
||||
g_cond_wait (&display->priv->thread_cond, &display->priv->thread_lock);
|
||||
g_cond_wait (&priv->thread_cond, &priv->thread_lock);
|
||||
|
||||
if (display->priv->event_thread)
|
||||
g_thread_unref (display->priv->event_thread);
|
||||
display->priv->event_thread = NULL;
|
||||
g_mutex_unlock (&display->priv->thread_lock);
|
||||
if (priv->event_thread)
|
||||
g_thread_unref (priv->event_thread);
|
||||
priv->event_thread = NULL;
|
||||
g_mutex_unlock (&priv->thread_lock);
|
||||
|
||||
if (display->event_source) {
|
||||
g_source_destroy (display->event_source);
|
||||
|
|
|
@ -85,9 +85,6 @@ struct _GstVulkanDisplay
|
|||
GMainContext *main_context;
|
||||
GMainLoop *main_loop;
|
||||
GSource *event_source;
|
||||
|
||||
/* <private> */
|
||||
GstVulkanDisplayPrivate *priv;
|
||||
};
|
||||
|
||||
struct _GstVulkanDisplayClass
|
||||
|
|
|
@ -52,6 +52,8 @@ static void gst_vulkan_image_buffer_pool_finalize (GObject * object);
|
|||
GST_DEBUG_CATEGORY_STATIC (GST_CAT_VULKAN_IMAGE_BUFFER_POOL);
|
||||
#define GST_CAT_DEFAULT GST_CAT_VULKAN_IMAGE_BUFFER_POOL
|
||||
|
||||
#define GET_PRIV(pool) gst_vulkan_image_buffer_pool_get_instance_private (pool)
|
||||
|
||||
#define gst_vulkan_image_buffer_pool_parent_class parent_class
|
||||
G_DEFINE_TYPE_WITH_CODE (GstVulkanImageBufferPool, gst_vulkan_image_buffer_pool,
|
||||
GST_TYPE_BUFFER_POOL, G_ADD_PRIVATE (GstVulkanImageBufferPool)
|
||||
|
@ -73,7 +75,7 @@ gst_vulkan_image_buffer_pool_set_config (GstBufferPool * pool,
|
|||
GstStructure * config)
|
||||
{
|
||||
GstVulkanImageBufferPool *vk_pool = GST_VULKAN_IMAGE_BUFFER_POOL_CAST (pool);
|
||||
GstVulkanImageBufferPoolPrivate *priv = vk_pool->priv;
|
||||
GstVulkanImageBufferPoolPrivate *priv = GET_PRIV (vk_pool);
|
||||
guint min_buffers, max_buffers;
|
||||
GstCaps *caps = NULL;
|
||||
GstCapsFeatures *features;
|
||||
|
@ -161,7 +163,7 @@ gst_vulkan_image_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
|
|||
GstBufferPoolAcquireParams * params)
|
||||
{
|
||||
GstVulkanImageBufferPool *vk_pool = GST_VULKAN_IMAGE_BUFFER_POOL_CAST (pool);
|
||||
GstVulkanImageBufferPoolPrivate *priv = vk_pool->priv;
|
||||
GstVulkanImageBufferPoolPrivate *priv = GET_PRIV (vk_pool);
|
||||
GstBuffer *buf;
|
||||
guint i;
|
||||
|
||||
|
@ -251,14 +253,13 @@ gst_vulkan_image_buffer_pool_class_init (GstVulkanImageBufferPoolClass * klass)
|
|||
static void
|
||||
gst_vulkan_image_buffer_pool_init (GstVulkanImageBufferPool * pool)
|
||||
{
|
||||
pool->priv = gst_vulkan_image_buffer_pool_get_instance_private (pool);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vulkan_image_buffer_pool_finalize (GObject * object)
|
||||
{
|
||||
GstVulkanImageBufferPool *pool = GST_VULKAN_IMAGE_BUFFER_POOL_CAST (object);
|
||||
GstVulkanImageBufferPoolPrivate *priv = pool->priv;
|
||||
GstVulkanImageBufferPoolPrivate *priv = GET_PRIV (pool);
|
||||
|
||||
GST_LOG_OBJECT (pool, "finalize Vulkan buffer pool %p", pool);
|
||||
|
||||
|
|
|
@ -46,8 +46,6 @@ struct _GstVulkanImageBufferPool
|
|||
GstBufferPool bufferpool;
|
||||
|
||||
GstVulkanDevice *device;
|
||||
|
||||
GstVulkanImageBufferPoolPrivate *priv;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -74,6 +74,8 @@ _init_debug (void)
|
|||
}
|
||||
}
|
||||
|
||||
#define GET_PRIV(instance) gst_vulkan_instance_get_instance_private (instance)
|
||||
|
||||
#define gst_vulkan_instance_parent_class parent_class
|
||||
G_DEFINE_TYPE_WITH_CODE (GstVulkanInstance, gst_vulkan_instance,
|
||||
GST_TYPE_OBJECT, G_ADD_PRIVATE (GstVulkanInstance)
|
||||
|
@ -93,7 +95,6 @@ gst_vulkan_instance_new (void)
|
|||
static void
|
||||
gst_vulkan_instance_init (GstVulkanInstance * instance)
|
||||
{
|
||||
instance->priv = gst_vulkan_instance_get_instance_private (instance);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -125,15 +126,16 @@ static void
|
|||
gst_vulkan_instance_finalize (GObject * object)
|
||||
{
|
||||
GstVulkanInstance *instance = GST_VULKAN_INSTANCE (object);
|
||||
GstVulkanInstancePrivate *priv = GET_PRIV (instance);
|
||||
|
||||
if (instance->priv->opened) {
|
||||
if (priv->opened) {
|
||||
if (instance->dbgDestroyDebugReportCallback)
|
||||
instance->dbgDestroyDebugReportCallback (instance->instance,
|
||||
instance->msg_callback, NULL);
|
||||
|
||||
g_free (instance->physical_devices);
|
||||
}
|
||||
instance->priv->opened = FALSE;
|
||||
priv->opened = FALSE;
|
||||
|
||||
if (instance->instance)
|
||||
vkDestroyInstance (instance->instance, NULL);
|
||||
|
@ -191,6 +193,7 @@ _gst_vk_debug_callback (VkDebugReportFlagsEXT msgFlags,
|
|||
gboolean
|
||||
gst_vulkan_instance_open (GstVulkanInstance * instance, GError ** error)
|
||||
{
|
||||
GstVulkanInstancePrivate *priv;
|
||||
VkExtensionProperties *instance_extensions;
|
||||
char *extension_names[64]; /* FIXME: make dynamic */
|
||||
VkLayerProperties *instance_layers;
|
||||
|
@ -202,8 +205,10 @@ gst_vulkan_instance_open (GstVulkanInstance * instance, GError ** error)
|
|||
|
||||
g_return_val_if_fail (GST_IS_VULKAN_INSTANCE (instance), FALSE);
|
||||
|
||||
priv = GET_PRIV (instance);
|
||||
|
||||
GST_OBJECT_LOCK (instance);
|
||||
if (instance->priv->opened) {
|
||||
if (priv->opened) {
|
||||
GST_OBJECT_UNLOCK (instance);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -400,7 +405,7 @@ gst_vulkan_instance_open (GstVulkanInstance * instance, GError ** error)
|
|||
goto error;
|
||||
}
|
||||
|
||||
instance->priv->opened = TRUE;
|
||||
priv->opened = TRUE;
|
||||
GST_OBJECT_UNLOCK (instance);
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -48,8 +48,6 @@ struct _GstVulkanInstance
|
|||
PFN_vkCreateDebugReportCallbackEXT dbgCreateDebugReportCallback;
|
||||
PFN_vkDestroyDebugReportCallbackEXT dbgDestroyDebugReportCallback;
|
||||
PFN_vkDebugReportMessageEXT dbgReportMessage;
|
||||
|
||||
GstVulkanInstancePrivate *priv;
|
||||
};
|
||||
|
||||
struct _GstVulkanInstanceClass
|
||||
|
|
|
@ -67,6 +67,8 @@ _init_debug (void)
|
|||
}
|
||||
}
|
||||
|
||||
#define GET_PRIV(device) gst_vulkan_physical_device_get_instance_private (device)
|
||||
|
||||
#define gst_vulkan_physical_device_parent_class parent_class
|
||||
G_DEFINE_TYPE_WITH_CODE (GstVulkanPhysicalDevice, gst_vulkan_physical_device,
|
||||
GST_TYPE_OBJECT, G_ADD_PRIVATE (GstVulkanPhysicalDevice);
|
||||
|
|
|
@ -56,8 +56,6 @@ struct _GstVulkanPhysicalDevice
|
|||
|
||||
VkQueueFamilyProperties *queue_family_props;
|
||||
guint32 n_queue_families;
|
||||
|
||||
GstVulkanPhysicalDevicePrivate *priv;
|
||||
};
|
||||
|
||||
struct _GstVulkanPhysicalDeviceClass
|
||||
|
|
|
@ -29,10 +29,6 @@
|
|||
#define GST_CAT_DEFAULT gst_vulkan_swapper_debug
|
||||
GST_DEBUG_CATEGORY (GST_CAT_DEFAULT);
|
||||
|
||||
#define RENDER_GET_LOCK(o) &(GST_VULKAN_SWAPPER (o)->priv->render_lock)
|
||||
#define RENDER_LOCK(o) g_mutex_lock (RENDER_GET_LOCK(o));
|
||||
#define RENDER_UNLOCK(o) g_mutex_unlock (RENDER_GET_LOCK(o));
|
||||
|
||||
struct _GstVulkanSwapperPrivate
|
||||
{
|
||||
VkSurfaceKHR surface;
|
||||
|
@ -99,6 +95,8 @@ enum
|
|||
#define DEFAULT_PIXEL_ASPECT_RATIO_N 0
|
||||
#define DEFAULT_PIXEL_ASPECT_RATIO_D 1
|
||||
|
||||
#define GET_PRIV(swapper) gst_vulkan_swapper_get_instance_private (swapper)
|
||||
|
||||
#define gst_vulkan_swapper_parent_class parent_class
|
||||
G_DEFINE_TYPE_WITH_CODE (GstVulkanSwapper, gst_vulkan_swapper,
|
||||
GST_TYPE_OBJECT, G_ADD_PRIVATE (GstVulkanSwapper)
|
||||
|
@ -110,9 +108,20 @@ static void _on_window_draw (GstVulkanWindow * window,
|
|||
static void _on_window_resize (GstVulkanWindow * window,
|
||||
guint width, guint height, GstVulkanSwapper * swapper);
|
||||
|
||||
static inline GMutex *
|
||||
render_get_lock (gpointer swapper)
|
||||
{
|
||||
GstVulkanSwapperPrivate *priv = GET_PRIV (swapper);
|
||||
return &priv->render_lock;
|
||||
}
|
||||
|
||||
#define RENDER_LOCK(o) g_mutex_lock (render_get_lock(o));
|
||||
#define RENDER_UNLOCK(o) g_mutex_unlock (render_get_lock(o));
|
||||
|
||||
static gboolean
|
||||
_get_function_table (GstVulkanSwapper * swapper)
|
||||
{
|
||||
GstVulkanSwapperPrivate *priv = GET_PRIV (swapper);
|
||||
GstVulkanDevice *device = swapper->device;
|
||||
GstVulkanInstance *instance = gst_vulkan_device_get_instance (device);
|
||||
|
||||
|
@ -120,30 +129,26 @@ _get_function_table (GstVulkanSwapper * swapper)
|
|||
GST_ERROR_OBJECT (swapper, "Failed to get instance from the device");
|
||||
return FALSE;
|
||||
}
|
||||
#define GET_PROC_ADDRESS_REQUIRED(obj, type, name) \
|
||||
#define GET_PROC_ADDRESS_REQUIRED(type, name) \
|
||||
G_STMT_START { \
|
||||
obj->priv->G_PASTE (, name) = G_PASTE(G_PASTE(gst_vulkan_, type), _get_proc_address) (type, "vk" G_STRINGIFY(name)); \
|
||||
if (!obj->priv->G_PASTE(, name)) { \
|
||||
GST_ERROR_OBJECT (obj, "Failed to find required function vk" G_STRINGIFY(name)); \
|
||||
priv->G_PASTE (, name) = G_PASTE(G_PASTE(gst_vulkan_, type), _get_proc_address) (type, "vk" G_STRINGIFY(name)); \
|
||||
if (!priv->G_PASTE(, name)) { \
|
||||
GST_ERROR_OBJECT (swapper, "Failed to find required function vk" G_STRINGIFY(name)); \
|
||||
gst_object_unref (instance); \
|
||||
return FALSE; \
|
||||
} \
|
||||
} G_STMT_END
|
||||
|
||||
GET_PROC_ADDRESS_REQUIRED (swapper, instance,
|
||||
GetPhysicalDeviceSurfaceSupportKHR);
|
||||
GET_PROC_ADDRESS_REQUIRED (swapper, instance,
|
||||
GetPhysicalDeviceSurfaceCapabilitiesKHR);
|
||||
GET_PROC_ADDRESS_REQUIRED (swapper, instance,
|
||||
GetPhysicalDeviceSurfaceFormatsKHR);
|
||||
GET_PROC_ADDRESS_REQUIRED (swapper, instance,
|
||||
GetPhysicalDeviceSurfacePresentModesKHR);
|
||||
GET_PROC_ADDRESS_REQUIRED (swapper, instance, DestroySurfaceKHR);
|
||||
GET_PROC_ADDRESS_REQUIRED (swapper, device, CreateSwapchainKHR);
|
||||
GET_PROC_ADDRESS_REQUIRED (swapper, device, DestroySwapchainKHR);
|
||||
GET_PROC_ADDRESS_REQUIRED (swapper, device, GetSwapchainImagesKHR);
|
||||
GET_PROC_ADDRESS_REQUIRED (swapper, device, AcquireNextImageKHR);
|
||||
GET_PROC_ADDRESS_REQUIRED (swapper, device, QueuePresentKHR);
|
||||
GET_PROC_ADDRESS_REQUIRED (instance, GetPhysicalDeviceSurfaceSupportKHR);
|
||||
GET_PROC_ADDRESS_REQUIRED (instance, GetPhysicalDeviceSurfaceCapabilitiesKHR);
|
||||
GET_PROC_ADDRESS_REQUIRED (instance, GetPhysicalDeviceSurfaceFormatsKHR);
|
||||
GET_PROC_ADDRESS_REQUIRED (instance, GetPhysicalDeviceSurfacePresentModesKHR);
|
||||
GET_PROC_ADDRESS_REQUIRED (instance, DestroySurfaceKHR);
|
||||
GET_PROC_ADDRESS_REQUIRED (device, CreateSwapchainKHR);
|
||||
GET_PROC_ADDRESS_REQUIRED (device, DestroySwapchainKHR);
|
||||
GET_PROC_ADDRESS_REQUIRED (device, GetSwapchainImagesKHR);
|
||||
GET_PROC_ADDRESS_REQUIRED (device, AcquireNextImageKHR);
|
||||
GET_PROC_ADDRESS_REQUIRED (device, QueuePresentKHR);
|
||||
|
||||
gst_object_unref (instance);
|
||||
|
||||
|
@ -200,8 +205,10 @@ _add_vk_format_to_list (GValue * list, VkFormat format)
|
|||
static gboolean
|
||||
_vulkan_swapper_ensure_surface (GstVulkanSwapper * swapper, GError ** error)
|
||||
{
|
||||
if (!swapper->priv->surface) {
|
||||
if (!(swapper->priv->surface =
|
||||
GstVulkanSwapperPrivate *priv = GET_PRIV (swapper);
|
||||
|
||||
if (!priv->surface) {
|
||||
if (!(priv->surface =
|
||||
gst_vulkan_window_get_surface (swapper->window, error))) {
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -221,6 +228,7 @@ static gboolean
|
|||
_choose_queue (GstVulkanDevice * device, GstVulkanQueue * queue,
|
||||
struct choose_data *data)
|
||||
{
|
||||
GstVulkanSwapperPrivate *priv = GET_PRIV (data->swapper);
|
||||
guint flags =
|
||||
device->physical_device->queue_family_props[queue->family].queueFlags;
|
||||
VkPhysicalDevice gpu;
|
||||
|
@ -234,8 +242,8 @@ _choose_queue (GstVulkanDevice * device, GstVulkanQueue * queue,
|
|||
VkBool32 physical_device_supported;
|
||||
|
||||
err =
|
||||
data->swapper->priv->GetPhysicalDeviceSurfaceSupportKHR (gpu,
|
||||
queue->index, data->swapper->priv->surface, &physical_device_supported);
|
||||
priv->GetPhysicalDeviceSurfaceSupportKHR (gpu,
|
||||
queue->index, priv->surface, &physical_device_supported);
|
||||
if (gst_vulkan_error_to_g_error (err, &error,
|
||||
"GetPhysicalDeviceSurfaceSupport") < 0) {
|
||||
GST_DEBUG_OBJECT (data->swapper,
|
||||
|
@ -334,42 +342,46 @@ gst_vulkan_swapper_choose_queue (GstVulkanSwapper * swapper,
|
|||
static void
|
||||
dump_surface_properties (GstVulkanSwapper * swapper)
|
||||
{
|
||||
GstVulkanSwapperPrivate *priv = GET_PRIV (swapper);
|
||||
|
||||
GST_TRACE_OBJECT (swapper, "surface %p, n images [%" G_GUINT32_FORMAT ", %"
|
||||
G_GUINT32_FORMAT "], extent [%" GST_VULKAN_EXTENT2D_FORMAT ", %"
|
||||
GST_VULKAN_EXTENT2D_FORMAT "], max layers %" G_GUINT32_FORMAT
|
||||
" transforms supported 0x%x current transform 0x%x, alpha flags 0x%x, "
|
||||
"supported image usage flags 0x%x", swapper->priv->surface,
|
||||
swapper->priv->surf_props.minImageCount,
|
||||
swapper->priv->surf_props.maxImageCount,
|
||||
GST_VULKAN_EXTENT2D_ARGS (swapper->priv->surf_props.minImageExtent),
|
||||
GST_VULKAN_EXTENT2D_ARGS (swapper->priv->surf_props.maxImageExtent),
|
||||
swapper->priv->surf_props.maxImageArrayLayers,
|
||||
swapper->priv->surf_props.supportedTransforms,
|
||||
swapper->priv->surf_props.currentTransform,
|
||||
swapper->priv->surf_props.supportedCompositeAlpha,
|
||||
swapper->priv->surf_props.supportedUsageFlags);
|
||||
"supported image usage flags 0x%x", priv->surface,
|
||||
priv->surf_props.minImageCount,
|
||||
priv->surf_props.maxImageCount,
|
||||
GST_VULKAN_EXTENT2D_ARGS (priv->surf_props.minImageExtent),
|
||||
GST_VULKAN_EXTENT2D_ARGS (priv->surf_props.maxImageExtent),
|
||||
priv->surf_props.maxImageArrayLayers,
|
||||
priv->surf_props.supportedTransforms,
|
||||
priv->surf_props.currentTransform,
|
||||
priv->surf_props.supportedCompositeAlpha,
|
||||
priv->surf_props.supportedUsageFlags);
|
||||
}
|
||||
|
||||
static void
|
||||
dump_surface_formats (GstVulkanSwapper * swapper)
|
||||
{
|
||||
GstVulkanSwapperPrivate *priv = GET_PRIV (swapper);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < swapper->priv->n_surf_formats; i++) {
|
||||
for (i = 0; i < priv->n_surf_formats; i++) {
|
||||
GST_DEBUG_OBJECT (swapper, "surface %p format 0x%x colorspace 0x%x",
|
||||
swapper->priv->surface, swapper->priv->surf_formats[i].format,
|
||||
swapper->priv->surf_formats[i].colorSpace);
|
||||
priv->surface, priv->surf_formats[i].format,
|
||||
priv->surf_formats[i].colorSpace);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
dump_surface_present_modes (GstVulkanSwapper * swapper)
|
||||
{
|
||||
GstVulkanSwapperPrivate *priv = GET_PRIV (swapper);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < swapper->priv->n_surf_present_modes; i++) {
|
||||
for (i = 0; i < priv->n_surf_present_modes; i++) {
|
||||
GST_DEBUG_OBJECT (swapper, "surface %p present modes 0x%x",
|
||||
swapper->priv->surface, swapper->priv->surf_present_modes[i]);
|
||||
priv->surface, priv->surf_present_modes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -377,10 +389,11 @@ static gboolean
|
|||
_vulkan_swapper_retrieve_surface_properties (GstVulkanSwapper * swapper,
|
||||
GError ** error)
|
||||
{
|
||||
GstVulkanSwapperPrivate *priv = GET_PRIV (swapper);
|
||||
VkPhysicalDevice gpu;
|
||||
VkResult err;
|
||||
|
||||
if (swapper->priv->surf_formats)
|
||||
if (priv->surf_formats)
|
||||
return TRUE;
|
||||
|
||||
gpu = gst_vulkan_device_get_physical_device (swapper->device);
|
||||
|
@ -393,8 +406,8 @@ _vulkan_swapper_retrieve_surface_properties (GstVulkanSwapper * swapper,
|
|||
return FALSE;
|
||||
|
||||
err =
|
||||
swapper->priv->GetPhysicalDeviceSurfaceCapabilitiesKHR (gpu,
|
||||
swapper->priv->surface, &swapper->priv->surf_props);
|
||||
priv->GetPhysicalDeviceSurfaceCapabilitiesKHR (gpu,
|
||||
priv->surface, &priv->surf_props);
|
||||
if (gst_vulkan_error_to_g_error (err, error,
|
||||
"GetPhysicalDeviceSurfaceCapabilitiesKHR") < 0)
|
||||
return FALSE;
|
||||
|
@ -402,18 +415,16 @@ _vulkan_swapper_retrieve_surface_properties (GstVulkanSwapper * swapper,
|
|||
dump_surface_properties (swapper);
|
||||
|
||||
err =
|
||||
swapper->priv->GetPhysicalDeviceSurfaceFormatsKHR (gpu,
|
||||
swapper->priv->surface, &swapper->priv->n_surf_formats, NULL);
|
||||
priv->GetPhysicalDeviceSurfaceFormatsKHR (gpu,
|
||||
priv->surface, &priv->n_surf_formats, NULL);
|
||||
if (gst_vulkan_error_to_g_error (err, error,
|
||||
"GetPhysicalDeviceSurfaceFormatsKHR") < 0)
|
||||
return FALSE;
|
||||
|
||||
swapper->priv->surf_formats =
|
||||
g_new0 (VkSurfaceFormatKHR, swapper->priv->n_surf_formats);
|
||||
priv->surf_formats = g_new0 (VkSurfaceFormatKHR, priv->n_surf_formats);
|
||||
err =
|
||||
swapper->priv->GetPhysicalDeviceSurfaceFormatsKHR (gpu,
|
||||
swapper->priv->surface, &swapper->priv->n_surf_formats,
|
||||
swapper->priv->surf_formats);
|
||||
priv->GetPhysicalDeviceSurfaceFormatsKHR (gpu,
|
||||
priv->surface, &priv->n_surf_formats, priv->surf_formats);
|
||||
if (gst_vulkan_error_to_g_error (err, error,
|
||||
"GetPhysicalDeviceSurfaceFormatsKHR") < 0)
|
||||
return FALSE;
|
||||
|
@ -421,18 +432,17 @@ _vulkan_swapper_retrieve_surface_properties (GstVulkanSwapper * swapper,
|
|||
dump_surface_formats (swapper);
|
||||
|
||||
err =
|
||||
swapper->priv->GetPhysicalDeviceSurfacePresentModesKHR (gpu,
|
||||
swapper->priv->surface, &swapper->priv->n_surf_present_modes, NULL);
|
||||
priv->GetPhysicalDeviceSurfacePresentModesKHR (gpu,
|
||||
priv->surface, &priv->n_surf_present_modes, NULL);
|
||||
if (gst_vulkan_error_to_g_error (err, error,
|
||||
"GetPhysicalDeviceSurfacePresentModesKHR") < 0)
|
||||
return FALSE;
|
||||
|
||||
swapper->priv->surf_present_modes =
|
||||
g_new0 (VkPresentModeKHR, swapper->priv->n_surf_present_modes);
|
||||
priv->surf_present_modes =
|
||||
g_new0 (VkPresentModeKHR, priv->n_surf_present_modes);
|
||||
err =
|
||||
swapper->priv->GetPhysicalDeviceSurfacePresentModesKHR (gpu,
|
||||
swapper->priv->surface, &swapper->priv->n_surf_present_modes,
|
||||
swapper->priv->surf_present_modes);
|
||||
priv->GetPhysicalDeviceSurfacePresentModesKHR (gpu,
|
||||
priv->surface, &priv->n_surf_present_modes, priv->surf_present_modes);
|
||||
if (gst_vulkan_error_to_g_error (err, error,
|
||||
"GetPhysicalDeviceSurfacePresentModesKHR") < 0)
|
||||
return FALSE;
|
||||
|
@ -445,7 +455,9 @@ _vulkan_swapper_retrieve_surface_properties (GstVulkanSwapper * swapper,
|
|||
static gboolean
|
||||
_on_window_close (GstVulkanWindow * window, GstVulkanSwapper * swapper)
|
||||
{
|
||||
g_atomic_int_set (&swapper->priv->to_quit, 1);
|
||||
GstVulkanSwapperPrivate *priv = GET_PRIV (swapper);
|
||||
|
||||
g_atomic_int_set (&priv->to_quit, 1);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -455,14 +467,15 @@ gst_vulkan_swapper_set_property (GObject * object, guint prop_id,
|
|||
const GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GstVulkanSwapper *swapper = GST_VULKAN_SWAPPER (object);
|
||||
GstVulkanSwapperPrivate *priv = GET_PRIV (swapper);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_FORCE_ASPECT_RATIO:
|
||||
swapper->priv->force_aspect_ratio = g_value_get_boolean (value);
|
||||
priv->force_aspect_ratio = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_PIXEL_ASPECT_RATIO:
|
||||
swapper->priv->par_n = gst_value_get_fraction_numerator (value);
|
||||
swapper->priv->par_d = gst_value_get_fraction_denominator (value);
|
||||
priv->par_n = gst_value_get_fraction_numerator (value);
|
||||
priv->par_d = gst_value_get_fraction_denominator (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
@ -475,14 +488,14 @@ gst_vulkan_swapper_get_property (GObject * object, guint prop_id,
|
|||
GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GstVulkanSwapper *swapper = GST_VULKAN_SWAPPER (object);
|
||||
GstVulkanSwapperPrivate *priv = GET_PRIV (swapper);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_FORCE_ASPECT_RATIO:
|
||||
g_value_set_boolean (value, swapper->priv->force_aspect_ratio);
|
||||
g_value_set_boolean (value, priv->force_aspect_ratio);
|
||||
break;
|
||||
case PROP_PIXEL_ASPECT_RATIO:
|
||||
gst_value_set_fraction (value, swapper->priv->par_n,
|
||||
swapper->priv->par_d);
|
||||
gst_value_set_fraction (value, priv->par_n, priv->par_d);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
@ -494,55 +507,54 @@ static void
|
|||
gst_vulkan_swapper_finalize (GObject * object)
|
||||
{
|
||||
GstVulkanSwapper *swapper = GST_VULKAN_SWAPPER (object);
|
||||
GstVulkanSwapperPrivate *priv = GET_PRIV (swapper);
|
||||
GstVulkanInstance *instance =
|
||||
gst_vulkan_device_get_instance (swapper->device);
|
||||
int i;
|
||||
|
||||
g_signal_handler_disconnect (swapper->window, swapper->priv->draw_id);
|
||||
swapper->priv->draw_id = 0;
|
||||
g_signal_handler_disconnect (swapper->window, priv->draw_id);
|
||||
priv->draw_id = 0;
|
||||
|
||||
g_signal_handler_disconnect (swapper->window, swapper->priv->close_id);
|
||||
swapper->priv->close_id = 0;
|
||||
g_signal_handler_disconnect (swapper->window, priv->close_id);
|
||||
priv->close_id = 0;
|
||||
|
||||
g_signal_handler_disconnect (swapper->window, swapper->priv->resize_id);
|
||||
swapper->priv->resize_id = 0;
|
||||
g_signal_handler_disconnect (swapper->window, priv->resize_id);
|
||||
priv->resize_id = 0;
|
||||
|
||||
if (!gst_vulkan_trash_list_wait (swapper->priv->trash_list, -1))
|
||||
if (!gst_vulkan_trash_list_wait (priv->trash_list, -1))
|
||||
GST_WARNING_OBJECT (swapper, "Failed to wait for all fences to complete "
|
||||
"before shutting down");
|
||||
gst_object_unref (swapper->priv->trash_list);
|
||||
swapper->priv->trash_list = NULL;
|
||||
gst_object_unref (priv->trash_list);
|
||||
priv->trash_list = NULL;
|
||||
|
||||
if (swapper->priv->swap_chain_images) {
|
||||
for (i = 0; i < swapper->priv->n_swap_chain_images; i++) {
|
||||
gst_memory_unref ((GstMemory *) swapper->priv->swap_chain_images[i]);
|
||||
swapper->priv->swap_chain_images[i] = NULL;
|
||||
if (priv->swap_chain_images) {
|
||||
for (i = 0; i < priv->n_swap_chain_images; i++) {
|
||||
gst_memory_unref ((GstMemory *) priv->swap_chain_images[i]);
|
||||
priv->swap_chain_images[i] = NULL;
|
||||
}
|
||||
g_free (swapper->priv->swap_chain_images);
|
||||
g_free (priv->swap_chain_images);
|
||||
}
|
||||
swapper->priv->swap_chain_images = NULL;
|
||||
priv->swap_chain_images = NULL;
|
||||
|
||||
if (swapper->priv->swap_chain)
|
||||
swapper->priv->DestroySwapchainKHR (swapper->device->device,
|
||||
swapper->priv->swap_chain, NULL);
|
||||
swapper->priv->swap_chain = VK_NULL_HANDLE;
|
||||
if (priv->swap_chain)
|
||||
priv->DestroySwapchainKHR (swapper->device->device, priv->swap_chain, NULL);
|
||||
priv->swap_chain = VK_NULL_HANDLE;
|
||||
|
||||
if (swapper->priv->surface) {
|
||||
swapper->priv->DestroySurfaceKHR (instance->instance,
|
||||
swapper->priv->surface, NULL);
|
||||
if (priv->surface) {
|
||||
priv->DestroySurfaceKHR (instance->instance, priv->surface, NULL);
|
||||
}
|
||||
swapper->priv->surface = VK_NULL_HANDLE;
|
||||
priv->surface = VK_NULL_HANDLE;
|
||||
|
||||
g_free (swapper->priv->surf_present_modes);
|
||||
swapper->priv->surf_present_modes = NULL;
|
||||
g_free (priv->surf_present_modes);
|
||||
priv->surf_present_modes = NULL;
|
||||
|
||||
g_free (swapper->priv->surf_formats);
|
||||
swapper->priv->surf_formats = NULL;
|
||||
g_free (priv->surf_formats);
|
||||
priv->surf_formats = NULL;
|
||||
|
||||
gst_buffer_replace (&swapper->priv->current_buffer, NULL);
|
||||
gst_caps_replace (&swapper->priv->caps, NULL);
|
||||
gst_buffer_replace (&priv->current_buffer, NULL);
|
||||
gst_caps_replace (&priv->caps, NULL);
|
||||
|
||||
g_mutex_clear (&swapper->priv->render_lock);
|
||||
g_mutex_clear (&priv->render_lock);
|
||||
|
||||
if (swapper->cmd_pool)
|
||||
gst_object_unref (swapper->cmd_pool);
|
||||
|
@ -568,15 +580,15 @@ gst_vulkan_swapper_finalize (GObject * object)
|
|||
static void
|
||||
gst_vulkan_swapper_init (GstVulkanSwapper * swapper)
|
||||
{
|
||||
swapper->priv = gst_vulkan_swapper_get_instance_private (swapper);
|
||||
GstVulkanSwapperPrivate *priv = GET_PRIV (swapper);
|
||||
|
||||
g_mutex_init (&swapper->priv->render_lock);
|
||||
g_mutex_init (&priv->render_lock);
|
||||
|
||||
swapper->priv->force_aspect_ratio = DEFAULT_FORCE_ASPECT_RATIO;
|
||||
swapper->priv->par_n = DEFAULT_PIXEL_ASPECT_RATIO_N;
|
||||
swapper->priv->par_d = DEFAULT_PIXEL_ASPECT_RATIO_D;
|
||||
priv->force_aspect_ratio = DEFAULT_FORCE_ASPECT_RATIO;
|
||||
priv->par_n = DEFAULT_PIXEL_ASPECT_RATIO_N;
|
||||
priv->par_d = DEFAULT_PIXEL_ASPECT_RATIO_D;
|
||||
|
||||
swapper->priv->trash_list = gst_vulkan_trash_fence_list_new ();
|
||||
priv->trash_list = gst_vulkan_trash_fence_list_new ();
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -604,6 +616,7 @@ GstVulkanSwapper *
|
|||
gst_vulkan_swapper_new (GstVulkanDevice * device, GstVulkanWindow * window)
|
||||
{
|
||||
GstVulkanSwapper *swapper;
|
||||
GstVulkanSwapperPrivate *priv;
|
||||
|
||||
swapper = g_object_new (GST_TYPE_VULKAN_SWAPPER, NULL);
|
||||
gst_object_ref_sink (swapper);
|
||||
|
@ -614,12 +627,13 @@ gst_vulkan_swapper_new (GstVulkanDevice * device, GstVulkanWindow * window)
|
|||
gst_object_unref (swapper);
|
||||
return NULL;
|
||||
}
|
||||
priv = GET_PRIV (swapper);
|
||||
|
||||
swapper->priv->close_id = g_signal_connect (swapper->window, "close",
|
||||
priv->close_id = g_signal_connect (swapper->window, "close",
|
||||
(GCallback) _on_window_close, swapper);
|
||||
swapper->priv->draw_id = g_signal_connect (swapper->window, "draw",
|
||||
priv->draw_id = g_signal_connect (swapper->window, "draw",
|
||||
(GCallback) _on_window_draw, swapper);
|
||||
swapper->priv->resize_id = g_signal_connect (swapper->window, "resize",
|
||||
priv->resize_id = g_signal_connect (swapper->window, "resize",
|
||||
(GCallback) _on_window_resize, swapper);
|
||||
|
||||
return swapper;
|
||||
|
@ -629,6 +643,7 @@ GstCaps *
|
|||
gst_vulkan_swapper_get_supported_caps (GstVulkanSwapper * swapper,
|
||||
GError ** error)
|
||||
{
|
||||
GstVulkanSwapperPrivate *priv = GET_PRIV (swapper);
|
||||
GstStructure *s;
|
||||
GstCaps *caps;
|
||||
|
||||
|
@ -648,12 +663,12 @@ gst_vulkan_swapper_get_supported_caps (GstVulkanSwapper * swapper,
|
|||
|
||||
g_value_init (&list, GST_TYPE_LIST);
|
||||
|
||||
if (swapper->priv->n_surf_formats
|
||||
&& swapper->priv->surf_formats[0].format == VK_FORMAT_UNDEFINED) {
|
||||
if (priv->n_surf_formats
|
||||
&& priv->surf_formats[0].format == VK_FORMAT_UNDEFINED) {
|
||||
_add_vk_format_to_list (&list, VK_FORMAT_B8G8R8A8_UNORM);
|
||||
} else {
|
||||
for (i = 0; i < swapper->priv->n_surf_formats; i++) {
|
||||
_add_vk_format_to_list (&list, swapper->priv->surf_formats[i].format);
|
||||
for (i = 0; i < priv->n_surf_formats; i++) {
|
||||
_add_vk_format_to_list (&list, priv->surf_formats[i].format);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -680,6 +695,7 @@ static gboolean
|
|||
_allocate_swapchain (GstVulkanSwapper * swapper, GstCaps * caps,
|
||||
GError ** error)
|
||||
{
|
||||
GstVulkanSwapperPrivate *priv = GET_PRIV (swapper);
|
||||
VkSurfaceTransformFlagsKHR preTransform;
|
||||
VkCompositeAlphaFlagsKHR alpha_flags;
|
||||
VkPresentModeKHR present_mode;
|
||||
|
@ -698,25 +714,25 @@ _allocate_swapchain (GstVulkanSwapper * swapper, GstCaps * caps,
|
|||
|
||||
gpu = gst_vulkan_device_get_physical_device (swapper->device);
|
||||
err =
|
||||
swapper->priv->GetPhysicalDeviceSurfaceCapabilitiesKHR (gpu,
|
||||
swapper->priv->surface, &swapper->priv->surf_props);
|
||||
priv->GetPhysicalDeviceSurfaceCapabilitiesKHR (gpu,
|
||||
priv->surface, &priv->surf_props);
|
||||
if (gst_vulkan_error_to_g_error (err, error,
|
||||
"GetPhysicalDeviceSurfaceCapabilitiesKHR") < 0)
|
||||
return FALSE;
|
||||
|
||||
/* width and height are either both -1, or both not -1. */
|
||||
if (swapper->priv->surf_props.currentExtent.width == -1) {
|
||||
if (priv->surf_props.currentExtent.width == -1) {
|
||||
/* If the surface size is undefined, the size is set to
|
||||
* the size of the images requested. */
|
||||
guint width, height;
|
||||
gst_vulkan_window_get_surface_dimensions (swapper->window, &width, &height);
|
||||
swapchain_dims.width = width;
|
||||
swapchain_dims.height = height;
|
||||
swapper->priv->any_current_extent = TRUE;
|
||||
priv->any_current_extent = TRUE;
|
||||
} else {
|
||||
/* If the surface size is defined, the swap chain size must match */
|
||||
swapchain_dims = swapper->priv->surf_props.currentExtent;
|
||||
swapper->priv->any_current_extent = FALSE;
|
||||
swapchain_dims = priv->surf_props.currentExtent;
|
||||
priv->any_current_extent = FALSE;
|
||||
}
|
||||
|
||||
/* If mailbox mode is available, use it, as is the lowest-latency non-
|
||||
|
@ -724,14 +740,13 @@ _allocate_swapchain (GstVulkanSwapper * swapper, GstCaps * caps,
|
|||
* and is fastest (though it tears). If not, fall back to FIFO which is
|
||||
* always available. */
|
||||
present_mode = VK_PRESENT_MODE_FIFO_KHR;
|
||||
for (i = 0; i < swapper->priv->n_surf_present_modes; i++) {
|
||||
if (swapper->priv->surf_present_modes[i] == VK_PRESENT_MODE_MAILBOX_KHR) {
|
||||
for (i = 0; i < priv->n_surf_present_modes; i++) {
|
||||
if (priv->surf_present_modes[i] == VK_PRESENT_MODE_MAILBOX_KHR) {
|
||||
present_mode = VK_PRESENT_MODE_MAILBOX_KHR;
|
||||
break;
|
||||
}
|
||||
if ((present_mode != VK_PRESENT_MODE_MAILBOX_KHR) &&
|
||||
(swapper->priv->surf_present_modes[i] ==
|
||||
VK_PRESENT_MODE_IMMEDIATE_KHR)) {
|
||||
(priv->surf_present_modes[i] == VK_PRESENT_MODE_IMMEDIATE_KHR)) {
|
||||
present_mode = VK_PRESENT_MODE_IMMEDIATE_KHR;
|
||||
}
|
||||
}
|
||||
|
@ -739,27 +754,27 @@ _allocate_swapchain (GstVulkanSwapper * swapper, GstCaps * caps,
|
|||
/* Determine the number of VkImage's to use in the swap chain (we desire to
|
||||
* own only 1 image at a time, besides the images being displayed and
|
||||
* queued for display): */
|
||||
n_images_wanted = swapper->priv->surf_props.minImageCount + 1;
|
||||
if ((swapper->priv->surf_props.maxImageCount > 0) &&
|
||||
(n_images_wanted > swapper->priv->surf_props.maxImageCount)) {
|
||||
n_images_wanted = priv->surf_props.minImageCount + 1;
|
||||
if ((priv->surf_props.maxImageCount > 0) &&
|
||||
(n_images_wanted > priv->surf_props.maxImageCount)) {
|
||||
/* Application must settle for fewer images than desired: */
|
||||
n_images_wanted = swapper->priv->surf_props.maxImageCount;
|
||||
n_images_wanted = priv->surf_props.maxImageCount;
|
||||
}
|
||||
|
||||
if (swapper->priv->surf_props.
|
||||
if (priv->surf_props.
|
||||
supportedTransforms & VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR) {
|
||||
preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
|
||||
} else {
|
||||
preTransform = swapper->priv->surf_props.currentTransform;
|
||||
preTransform = priv->surf_props.currentTransform;
|
||||
}
|
||||
|
||||
format = gst_vulkan_format_from_video_info (&swapper->priv->v_info, 0);
|
||||
color_space = _vk_color_space_from_video_info (&swapper->priv->v_info);
|
||||
format = gst_vulkan_format_from_video_info (&priv->v_info, 0);
|
||||
color_space = _vk_color_space_from_video_info (&priv->v_info);
|
||||
|
||||
if ((swapper->priv->surf_props.supportedCompositeAlpha &
|
||||
if ((priv->surf_props.supportedCompositeAlpha &
|
||||
VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR) != 0) {
|
||||
alpha_flags = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
|
||||
} else if ((swapper->priv->surf_props.supportedCompositeAlpha &
|
||||
} else if ((priv->surf_props.supportedCompositeAlpha &
|
||||
VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR) != 0) {
|
||||
alpha_flags = VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR;
|
||||
} else {
|
||||
|
@ -769,7 +784,7 @@ _allocate_swapchain (GstVulkanSwapper * swapper, GstCaps * caps,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if ((swapper->priv->surf_props.supportedUsageFlags &
|
||||
if ((priv->surf_props.supportedUsageFlags &
|
||||
VK_IMAGE_USAGE_TRANSFER_DST_BIT) != 0) {
|
||||
usage |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
||||
} else {
|
||||
|
@ -778,7 +793,7 @@ _allocate_swapchain (GstVulkanSwapper * swapper, GstCaps * caps,
|
|||
"Incorrect usage flags available for the swap images");
|
||||
return FALSE;
|
||||
}
|
||||
if ((swapper->priv->
|
||||
if ((priv->
|
||||
surf_props.supportedUsageFlags & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT)
|
||||
!= 0) {
|
||||
usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
|
@ -793,13 +808,13 @@ _allocate_swapchain (GstVulkanSwapper * swapper, GstCaps * caps,
|
|||
VkSwapchainCreateInfoKHR swap_chain_info = { 0, };
|
||||
VkSwapchainKHR old_swap_chain;
|
||||
|
||||
old_swap_chain = swapper->priv->swap_chain;
|
||||
old_swap_chain = priv->swap_chain;
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
swap_chain_info = (VkSwapchainCreateInfoKHR) {
|
||||
.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,
|
||||
.pNext = NULL,
|
||||
.surface = swapper->priv->surface,
|
||||
.surface = priv->surface,
|
||||
.minImageCount = n_images_wanted,
|
||||
.imageFormat = format,
|
||||
.imageColorSpace = color_space,
|
||||
|
@ -818,46 +833,44 @@ _allocate_swapchain (GstVulkanSwapper * swapper, GstCaps * caps,
|
|||
/* *INDENT-ON* */
|
||||
|
||||
err =
|
||||
swapper->priv->CreateSwapchainKHR (swapper->device->device,
|
||||
&swap_chain_info, NULL, &swapper->priv->swap_chain);
|
||||
priv->CreateSwapchainKHR (swapper->device->device,
|
||||
&swap_chain_info, NULL, &priv->swap_chain);
|
||||
if (gst_vulkan_error_to_g_error (err, error, "vkCreateSwapchainKHR") < 0)
|
||||
return FALSE;
|
||||
|
||||
if (old_swap_chain != VK_NULL_HANDLE) {
|
||||
swapper->priv->DestroySwapchainKHR (swapper->device->device,
|
||||
old_swap_chain, NULL);
|
||||
priv->DestroySwapchainKHR (swapper->device->device, old_swap_chain, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
err =
|
||||
swapper->priv->GetSwapchainImagesKHR (swapper->device->device,
|
||||
swapper->priv->swap_chain, &swapper->priv->n_swap_chain_images, NULL);
|
||||
priv->GetSwapchainImagesKHR (swapper->device->device,
|
||||
priv->swap_chain, &priv->n_swap_chain_images, NULL);
|
||||
if (gst_vulkan_error_to_g_error (err, error, "vkGetSwapchainImagesKHR") < 0)
|
||||
return FALSE;
|
||||
|
||||
swap_chain_images = g_new0 (VkImage, swapper->priv->n_swap_chain_images);
|
||||
swap_chain_images = g_new0 (VkImage, priv->n_swap_chain_images);
|
||||
err =
|
||||
swapper->priv->GetSwapchainImagesKHR (swapper->device->device,
|
||||
swapper->priv->swap_chain, &swapper->priv->n_swap_chain_images,
|
||||
swap_chain_images);
|
||||
priv->GetSwapchainImagesKHR (swapper->device->device,
|
||||
priv->swap_chain, &priv->n_swap_chain_images, swap_chain_images);
|
||||
if (gst_vulkan_error_to_g_error (err, error, "vkGetSwapchainImagesKHR") < 0) {
|
||||
g_free (swap_chain_images);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
swapper->priv->swap_chain_images =
|
||||
g_new0 (GstVulkanImageMemory *, swapper->priv->n_swap_chain_images);
|
||||
for (i = 0; i < swapper->priv->n_swap_chain_images; i++) {
|
||||
swapper->priv->swap_chain_images[i] = (GstVulkanImageMemory *)
|
||||
priv->swap_chain_images =
|
||||
g_new0 (GstVulkanImageMemory *, priv->n_swap_chain_images);
|
||||
for (i = 0; i < priv->n_swap_chain_images; i++) {
|
||||
priv->swap_chain_images[i] = (GstVulkanImageMemory *)
|
||||
gst_vulkan_image_memory_wrapped (swapper->device, swap_chain_images[i],
|
||||
format, swapchain_dims.width, swapchain_dims.height,
|
||||
VK_IMAGE_TILING_OPTIMAL, usage, NULL, NULL);
|
||||
|
||||
swapper->priv->swap_chain_images[i]->barrier.parent.pipeline_stages =
|
||||
priv->swap_chain_images[i]->barrier.parent.pipeline_stages =
|
||||
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
|
||||
swapper->priv->swap_chain_images[i]->barrier.parent.access_flags =
|
||||
priv->swap_chain_images[i]->barrier.parent.access_flags =
|
||||
VK_ACCESS_MEMORY_READ_BIT;
|
||||
swapper->priv->swap_chain_images[i]->barrier.image_layout =
|
||||
priv->swap_chain_images[i]->barrier.image_layout =
|
||||
VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
}
|
||||
|
||||
|
@ -868,6 +881,7 @@ _allocate_swapchain (GstVulkanSwapper * swapper, GstCaps * caps,
|
|||
static gboolean
|
||||
_swapchain_resize (GstVulkanSwapper * swapper, GError ** error)
|
||||
{
|
||||
GstVulkanSwapperPrivate *priv = GET_PRIV (swapper);
|
||||
int i;
|
||||
|
||||
if (!swapper->queue) {
|
||||
|
@ -876,22 +890,23 @@ _swapchain_resize (GstVulkanSwapper * swapper, GError ** error)
|
|||
}
|
||||
}
|
||||
|
||||
if (swapper->priv->swap_chain_images) {
|
||||
for (i = 0; i < swapper->priv->n_swap_chain_images; i++) {
|
||||
if (swapper->priv->swap_chain_images[i])
|
||||
gst_memory_unref ((GstMemory *) swapper->priv->swap_chain_images[i]);
|
||||
if (priv->swap_chain_images) {
|
||||
for (i = 0; i < priv->n_swap_chain_images; i++) {
|
||||
if (priv->swap_chain_images[i])
|
||||
gst_memory_unref ((GstMemory *) priv->swap_chain_images[i]);
|
||||
}
|
||||
g_free (swapper->priv->swap_chain_images);
|
||||
swapper->priv->swap_chain_images = NULL;
|
||||
g_free (priv->swap_chain_images);
|
||||
priv->swap_chain_images = NULL;
|
||||
}
|
||||
|
||||
return _allocate_swapchain (swapper, swapper->priv->caps, error);
|
||||
return _allocate_swapchain (swapper, priv->caps, error);
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
configure_display_from_info (GstVulkanSwapper * swapper, GstVideoInfo * vinfo)
|
||||
{
|
||||
GstVulkanSwapperPrivate *priv = GET_PRIV (swapper);
|
||||
gint width;
|
||||
gint height;
|
||||
gboolean ok;
|
||||
|
@ -909,9 +924,9 @@ configure_display_from_info (GstVulkanSwapper * swapper, GstVideoInfo * vinfo)
|
|||
par_n = 1;
|
||||
|
||||
/* get display's PAR */
|
||||
if (swapper->priv->par_n != 0 && swapper->priv->par_d != 0) {
|
||||
display_par_n = swapper->priv->par_n;
|
||||
display_par_d = swapper->priv->par_d;
|
||||
if (priv->par_n != 0 && priv->par_d != 0) {
|
||||
display_par_n = priv->par_n;
|
||||
display_par_d = priv->par_d;
|
||||
} else {
|
||||
display_par_n = 1;
|
||||
display_par_d = 1;
|
||||
|
@ -929,24 +944,24 @@ configure_display_from_info (GstVulkanSwapper * swapper, GstVideoInfo * vinfo)
|
|||
|
||||
if (height % display_ratio_den == 0) {
|
||||
GST_DEBUG_OBJECT (swapper, "keeping video height");
|
||||
swapper->priv->dar_width = (guint)
|
||||
priv->dar_width = (guint)
|
||||
gst_util_uint64_scale_int (height, display_ratio_num,
|
||||
display_ratio_den);
|
||||
swapper->priv->dar_height = height;
|
||||
priv->dar_height = height;
|
||||
} else if (width % display_ratio_num == 0) {
|
||||
GST_DEBUG_OBJECT (swapper, "keeping video width");
|
||||
swapper->priv->dar_width = width;
|
||||
swapper->priv->dar_height = (guint)
|
||||
priv->dar_width = width;
|
||||
priv->dar_height = (guint)
|
||||
gst_util_uint64_scale_int (width, display_ratio_den, display_ratio_num);
|
||||
} else {
|
||||
GST_DEBUG_OBJECT (swapper, "approximating while keeping video height");
|
||||
swapper->priv->dar_width = (guint)
|
||||
priv->dar_width = (guint)
|
||||
gst_util_uint64_scale_int (height, display_ratio_num,
|
||||
display_ratio_den);
|
||||
swapper->priv->dar_height = height;
|
||||
priv->dar_height = height;
|
||||
}
|
||||
GST_DEBUG_OBJECT (swapper, "scaling to %dx%d", swapper->priv->dar_width,
|
||||
swapper->priv->dar_height);
|
||||
GST_DEBUG_OBJECT (swapper, "scaling to %dx%d", priv->dar_width,
|
||||
priv->dar_height);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -955,19 +970,21 @@ gboolean
|
|||
gst_vulkan_swapper_set_caps (GstVulkanSwapper * swapper, GstCaps * caps,
|
||||
GError ** error)
|
||||
{
|
||||
if (!gst_video_info_from_caps (&swapper->priv->v_info, caps)) {
|
||||
GstVulkanSwapperPrivate *priv = GET_PRIV (swapper);
|
||||
|
||||
if (!gst_video_info_from_caps (&priv->v_info, caps)) {
|
||||
g_set_error (error, GST_VULKAN_ERROR,
|
||||
VK_ERROR_INITIALIZATION_FAILED, "Failed to get GstVideoInfo from caps");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!configure_display_from_info (swapper, &swapper->priv->v_info)) {
|
||||
if (!configure_display_from_info (swapper, &priv->v_info)) {
|
||||
g_set_error (error, GST_VULKAN_ERROR,
|
||||
VK_ERROR_INITIALIZATION_FAILED, "Failed to configure display sizes");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gst_caps_replace (&swapper->priv->caps, caps);
|
||||
gst_caps_replace (&priv->caps, caps);
|
||||
|
||||
return _swapchain_resize (swapper, error);
|
||||
}
|
||||
|
@ -976,14 +993,15 @@ static gboolean
|
|||
_build_render_buffer_cmd (GstVulkanSwapper * swapper, guint32 swap_idx,
|
||||
GstBuffer * buffer, GstVulkanCommandBuffer ** cmd_ret, GError ** error)
|
||||
{
|
||||
GstVulkanSwapperPrivate *priv = GET_PRIV (swapper);
|
||||
GstMemory *in_mem;
|
||||
GstVulkanImageMemory *swap_img;
|
||||
GstVulkanCommandBuffer *cmd_buf;
|
||||
GstVideoRectangle src, dst, rslt;
|
||||
VkResult err;
|
||||
|
||||
g_return_val_if_fail (swap_idx < swapper->priv->n_swap_chain_images, FALSE);
|
||||
swap_img = swapper->priv->swap_chain_images[swap_idx];
|
||||
g_return_val_if_fail (swap_idx < priv->n_swap_chain_images, FALSE);
|
||||
swap_img = priv->swap_chain_images[swap_idx];
|
||||
|
||||
if (!(cmd_buf = gst_vulkan_command_pool_create (swapper->cmd_pool, error)))
|
||||
return FALSE;
|
||||
|
@ -1032,15 +1050,14 @@ _build_render_buffer_cmd (GstVulkanSwapper * swapper, guint32 swap_idx,
|
|||
}
|
||||
|
||||
src.x = src.y = 0;
|
||||
src.w = swapper->priv->dar_width;
|
||||
src.h = swapper->priv->dar_height;
|
||||
src.w = priv->dar_width;
|
||||
src.h = priv->dar_height;
|
||||
|
||||
dst.x = dst.y = 0;
|
||||
dst.w = gst_vulkan_image_memory_get_width (swap_img);
|
||||
dst.h = gst_vulkan_image_memory_get_height (swap_img);
|
||||
|
||||
gst_video_sink_center_rect (src, dst, &rslt,
|
||||
swapper->priv->force_aspect_ratio);
|
||||
gst_video_sink_center_rect (src, dst, &rslt, priv->force_aspect_ratio);
|
||||
|
||||
GST_TRACE_OBJECT (swapper, "rendering into result rectangle %ux%u+%u,%u "
|
||||
"src %ux%u dst %ux%u", rslt.w, rslt.h, rslt.x, rslt.y, src.w, src.h,
|
||||
|
@ -1059,7 +1076,7 @@ _build_render_buffer_cmd (GstVulkanSwapper * swapper, guint32 swap_idx,
|
|||
},
|
||||
.srcOffsets = {
|
||||
{0, 0, 0},
|
||||
{GST_VIDEO_INFO_WIDTH (&swapper->priv->v_info), GST_VIDEO_INFO_HEIGHT (&swapper->priv->v_info), 1},
|
||||
{GST_VIDEO_INFO_WIDTH (&priv->v_info), GST_VIDEO_INFO_HEIGHT (&priv->v_info), 1},
|
||||
},
|
||||
.dstSubresource = {
|
||||
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
|
@ -1154,6 +1171,7 @@ static gboolean
|
|||
_render_buffer_unlocked (GstVulkanSwapper * swapper,
|
||||
GstBuffer * buffer, GError ** error)
|
||||
{
|
||||
GstVulkanSwapperPrivate *priv = GET_PRIV (swapper);
|
||||
VkSemaphore acquire_semaphore = { 0, };
|
||||
VkSemaphore present_semaphore = { 0, };
|
||||
VkSemaphoreCreateInfo semaphore_info = { 0, };
|
||||
|
@ -1163,7 +1181,7 @@ _render_buffer_unlocked (GstVulkanSwapper * swapper,
|
|||
guint32 swap_idx;
|
||||
VkResult err, present_err = VK_SUCCESS;
|
||||
|
||||
gst_vulkan_trash_list_gc (swapper->priv->trash_list);
|
||||
gst_vulkan_trash_list_gc (priv->trash_list);
|
||||
|
||||
if (!buffer) {
|
||||
g_set_error (error, GST_VULKAN_ERROR,
|
||||
|
@ -1171,13 +1189,13 @@ _render_buffer_unlocked (GstVulkanSwapper * swapper,
|
|||
goto error;
|
||||
}
|
||||
|
||||
if (g_atomic_int_get (&swapper->priv->to_quit)) {
|
||||
if (g_atomic_int_get (&priv->to_quit)) {
|
||||
g_set_error (error, GST_VULKAN_ERROR, VK_ERROR_SURFACE_LOST_KHR,
|
||||
"Output window was closed");
|
||||
goto error;
|
||||
}
|
||||
|
||||
gst_buffer_replace (&swapper->priv->current_buffer, buffer);
|
||||
gst_buffer_replace (&priv->current_buffer, buffer);
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
semaphore_info = (VkSemaphoreCreateInfo) {
|
||||
|
@ -1194,9 +1212,8 @@ reacquire:
|
|||
goto error;
|
||||
|
||||
err =
|
||||
swapper->priv->AcquireNextImageKHR (swapper->device->device,
|
||||
swapper->priv->swap_chain, -1, acquire_semaphore, VK_NULL_HANDLE,
|
||||
&swap_idx);
|
||||
priv->AcquireNextImageKHR (swapper->device->device,
|
||||
priv->swap_chain, -1, acquire_semaphore, VK_NULL_HANDLE, &swap_idx);
|
||||
/* TODO: Deal with the VK_SUBOPTIMAL_KHR and VK_ERROR_OUT_OF_DATE_KHR */
|
||||
if (err == VK_ERROR_OUT_OF_DATE_KHR) {
|
||||
GST_DEBUG_OBJECT (swapper, "out of date frame acquired");
|
||||
|
@ -1247,10 +1264,10 @@ reacquire:
|
|||
if (gst_vulkan_error_to_g_error (err, error, "vkQueueSubmit") < 0)
|
||||
goto error;
|
||||
|
||||
gst_vulkan_trash_list_add (swapper->priv->trash_list,
|
||||
gst_vulkan_trash_list_add (priv->trash_list,
|
||||
gst_vulkan_trash_new_mini_object_unref (gst_vulkan_fence_ref (fence),
|
||||
GST_MINI_OBJECT_CAST (cmd_buf)));
|
||||
gst_vulkan_trash_list_add (swapper->priv->trash_list,
|
||||
gst_vulkan_trash_list_add (priv->trash_list,
|
||||
gst_vulkan_trash_new_free_semaphore (fence, acquire_semaphore));
|
||||
acquire_semaphore = VK_NULL_HANDLE;
|
||||
|
||||
|
@ -1266,13 +1283,13 @@ reacquire:
|
|||
.waitSemaphoreCount = 1,
|
||||
.pWaitSemaphores = &present_semaphore,
|
||||
.swapchainCount = 1,
|
||||
.pSwapchains = &swapper->priv->swap_chain,
|
||||
.pSwapchains = &priv->swap_chain,
|
||||
.pImageIndices = &swap_idx,
|
||||
.pResults = &present_err,
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
err = swapper->priv->QueuePresentKHR (swapper->queue->queue, &present);
|
||||
err = priv->QueuePresentKHR (swapper->queue->queue, &present);
|
||||
|
||||
if (present_err == VK_ERROR_OUT_OF_DATE_KHR) {
|
||||
GST_DEBUG_OBJECT (swapper, "out of date frame submitted");
|
||||
|
@ -1304,7 +1321,7 @@ reacquire:
|
|||
if (gst_vulkan_error_to_g_error (err, error, "vkQueueSubmit") < 0)
|
||||
goto error;
|
||||
|
||||
gst_vulkan_trash_list_add (swapper->priv->trash_list,
|
||||
gst_vulkan_trash_list_add (priv->trash_list,
|
||||
gst_vulkan_trash_new_free_semaphore (fence, present_semaphore));
|
||||
fence = NULL;
|
||||
}
|
||||
|
@ -1354,19 +1371,20 @@ gst_vulkan_swapper_render_buffer (GstVulkanSwapper * swapper,
|
|||
static void
|
||||
_on_window_draw (GstVulkanWindow * window, GstVulkanSwapper * swapper)
|
||||
{
|
||||
GstVulkanSwapperPrivate *priv = GET_PRIV (swapper);
|
||||
GError *error = NULL;
|
||||
|
||||
RENDER_LOCK (swapper);
|
||||
if (!swapper->priv->current_buffer) {
|
||||
if (!priv->current_buffer) {
|
||||
GST_DEBUG_OBJECT (swapper, "No buffer to render");
|
||||
RENDER_UNLOCK (swapper);
|
||||
return;
|
||||
}
|
||||
|
||||
/* TODO: perform some rate limiting of the number of redraw events */
|
||||
if (!_render_buffer_unlocked (swapper, swapper->priv->current_buffer, &error))
|
||||
if (!_render_buffer_unlocked (swapper, priv->current_buffer, &error))
|
||||
GST_ERROR_OBJECT (swapper, "Failed to redraw buffer %p %s",
|
||||
swapper->priv->current_buffer, error->message);
|
||||
priv->current_buffer, error->message);
|
||||
g_clear_error (&error);
|
||||
RENDER_UNLOCK (swapper);
|
||||
}
|
||||
|
@ -1375,10 +1393,11 @@ static void
|
|||
_on_window_resize (GstVulkanWindow * window, guint width, guint height,
|
||||
GstVulkanSwapper * swapper)
|
||||
{
|
||||
GstVulkanSwapperPrivate *priv = GET_PRIV (swapper);
|
||||
GError *error = NULL;
|
||||
|
||||
RENDER_LOCK (swapper);
|
||||
if (swapper->priv->any_current_extent) {
|
||||
if (priv->any_current_extent) {
|
||||
if (!_swapchain_resize (swapper, &error))
|
||||
GST_ERROR_OBJECT (swapper, "Failed to resize swapchain: %s",
|
||||
error->message);
|
||||
|
|
|
@ -50,8 +50,6 @@ struct _GstVulkanSwapper
|
|||
GstVulkanWindow *window;
|
||||
GstVulkanQueue *queue;
|
||||
GstVulkanCommandPool *cmd_pool;
|
||||
|
||||
GstVulkanSwapperPrivate *priv;
|
||||
};
|
||||
|
||||
struct _GstVulkanSwapperClass
|
||||
|
|
|
@ -62,6 +62,8 @@ struct _GstVulkanWindowPrivate
|
|||
guint surface_height;
|
||||
};
|
||||
|
||||
#define GET_PRIV(window) gst_vulkan_window_get_instance_private (window)
|
||||
|
||||
#define gst_vulkan_window_parent_class parent_class
|
||||
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GstVulkanWindow, gst_vulkan_window,
|
||||
GST_TYPE_OBJECT);
|
||||
|
@ -175,7 +177,6 @@ gst_vulkan_window_get_property (GObject * object, guint prop_id,
|
|||
static void
|
||||
gst_vulkan_window_init (GstVulkanWindow * window)
|
||||
{
|
||||
window->priv = gst_vulkan_window_get_instance_private (window);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -395,10 +396,14 @@ gst_vulkan_window_close (GstVulkanWindow * window)
|
|||
void
|
||||
gst_vulkan_window_resize (GstVulkanWindow * window, gint width, gint height)
|
||||
{
|
||||
GstVulkanWindowPrivate *priv;
|
||||
|
||||
g_return_if_fail (GST_IS_VULKAN_WINDOW (window));
|
||||
|
||||
window->priv->surface_width = width;
|
||||
window->priv->surface_height = height;
|
||||
priv = GET_PRIV (window);
|
||||
|
||||
priv->surface_width = width;
|
||||
priv->surface_height = height;
|
||||
|
||||
g_signal_emit (window, gst_vulkan_window_signals[SIGNAL_RESIZE], 0, width,
|
||||
height);
|
||||
|
@ -442,18 +447,20 @@ void
|
|||
gst_vulkan_window_get_surface_dimensions (GstVulkanWindow * window,
|
||||
guint * width, guint * height)
|
||||
{
|
||||
GstVulkanWindowPrivate *priv;
|
||||
GstVulkanWindowClass *klass;
|
||||
|
||||
g_return_if_fail (GST_IS_VULKAN_WINDOW (window));
|
||||
klass = GST_VULKAN_WINDOW_GET_CLASS (window);
|
||||
priv = GET_PRIV (window);
|
||||
|
||||
if (klass->get_surface_dimensions) {
|
||||
klass->get_surface_dimensions (window, width, height);
|
||||
} else {
|
||||
GST_DEBUG_OBJECT (window, "Returning size %ix%i",
|
||||
window->priv->surface_width, window->priv->surface_height);
|
||||
*width = window->priv->surface_width;
|
||||
*height = window->priv->surface_height;
|
||||
priv->surface_width, priv->surface_height);
|
||||
*width = priv->surface_width;
|
||||
*height = priv->surface_height;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -65,8 +65,6 @@ struct _GstVulkanWindow {
|
|||
|
||||
GMutex lock;
|
||||
|
||||
GstVulkanWindowPrivate *priv;
|
||||
|
||||
gpointer _reserved[GST_PADDING];
|
||||
};
|
||||
|
||||
|
|
|
@ -54,8 +54,6 @@ struct _GstVulkanWindowIos
|
|||
PFN_vkCreateIOSSurfaceMVK CreateIOSSurface;
|
||||
|
||||
/*< private >*/
|
||||
GstVulkanWindowIosPrivate *priv;
|
||||
|
||||
gpointer _reserved[GST_PADDING];
|
||||
};
|
||||
|
||||
|
|
|
@ -87,9 +87,10 @@ static void
|
|||
gst_vulkan_window_ios_finalize (GObject * object)
|
||||
{
|
||||
GstVulkanWindowIos *window_ios = GST_VULKAN_WINDOW_IOS (object);
|
||||
GstVulkanWindowIosPrivate *priv = GET_PRIV (window_ios);
|
||||
|
||||
g_mutex_clear (&window_ios->priv->lock);
|
||||
g_cond_clear (&window_ios->priv->cond);
|
||||
g_mutex_clear (&priv->lock);
|
||||
g_cond_clear (&priv->cond);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -114,13 +115,13 @@ gst_vulkan_window_ios_class_init (GstVulkanWindowIosClass * klass)
|
|||
static void
|
||||
gst_vulkan_window_ios_init (GstVulkanWindowIos * window)
|
||||
{
|
||||
window->priv = gst_vulkan_window_ios_get_instance_private (window);
|
||||
GstVulkanWindowIosPrivate *priv = GET_PRIV (window_ios);
|
||||
|
||||
window->priv->preferred_width = 320;
|
||||
window->priv->preferred_height = 240;
|
||||
priv->preferred_width = 320;
|
||||
priv->preferred_height = 240;
|
||||
|
||||
g_mutex_init (&window->priv->lock);
|
||||
g_cond_init (&window->priv->cond);
|
||||
g_mutex_init (&priv->lock);
|
||||
g_cond_init (&priv->cond);
|
||||
}
|
||||
|
||||
/* Must be called in the gl thread */
|
||||
|
@ -148,7 +149,7 @@ gst_vulkan_window_ios_new (GstVulkanDisplay * display)
|
|||
static void
|
||||
_create_window (GstVulkanWindowIos * window_ios)
|
||||
{
|
||||
GstVulkanWindowIosPrivate *priv = window_ios->priv;
|
||||
GstVulkanWindowIosPrivate *priv = GET_PRIV (window_ios);
|
||||
UIView *external_view = (__bridge UIView *) priv->external_view;
|
||||
CGRect rect = CGRectMake (0, 0, external_view.frame.size.width, external_view.frame.size.height);
|
||||
GstVulkanUIView *view;
|
||||
|
@ -171,7 +172,7 @@ _create_window (GstVulkanWindowIos * window_ios)
|
|||
gboolean
|
||||
gst_vulkan_window_ios_create_window (GstVulkanWindowIos * window_ios)
|
||||
{
|
||||
GstVulkanWindowIosPrivate *priv = window_ios->priv;
|
||||
GstVulkanWindowIosPrivate *priv = GET_PRIV (window_ios);
|
||||
|
||||
if (!priv->external_view) {
|
||||
GST_WARNING_OBJECT(window_ios, "No external UIView provided");
|
||||
|
@ -194,11 +195,12 @@ static VkSurfaceKHR
|
|||
gst_vulkan_window_ios_get_surface (GstVulkanWindow * window, GError ** error)
|
||||
{
|
||||
GstVulkanWindowIos *window_ios = GST_VULKAN_WINDOW_IOS (window);
|
||||
GstVulkanWindowIosPrivate *priv = GET_PRIV (window_ios);
|
||||
VkIOSSurfaceCreateInfoMVK info = { 0, };
|
||||
VkSurfaceKHR ret;
|
||||
VkResult err;
|
||||
|
||||
if (!window_ios->priv->internal_layer) {
|
||||
if (!priv->internal_layer) {
|
||||
g_set_error_literal (error, GST_VULKAN_ERROR,
|
||||
VK_ERROR_INITIALIZATION_FAILED,
|
||||
"No layer to retrieve surface for. Has create_window() been called?");
|
||||
|
@ -208,7 +210,7 @@ gst_vulkan_window_ios_get_surface (GstVulkanWindow * window, GError ** error)
|
|||
info.sType = VK_STRUCTURE_TYPE_IOS_SURFACE_CREATE_INFO_MVK;
|
||||
info.pNext = NULL;
|
||||
info.flags = 0;
|
||||
info.pView = window_ios->priv->internal_layer;
|
||||
info.pView = priv->internal_layer;
|
||||
|
||||
if (!window_ios->CreateIOSSurface)
|
||||
window_ios->CreateIOSSurface =
|
||||
|
@ -251,13 +253,14 @@ static void
|
|||
gst_vulkan_window_ios_close (GstVulkanWindow * window)
|
||||
{
|
||||
GstVulkanWindowIos *window_ios = GST_VULKAN_WINDOW_IOS (window);
|
||||
GstVulkanUIView *view = (__bridge GstVulkanUIView *) window_ios->priv->internal_view;
|
||||
GstVulkanWindowIosPrivate *priv = GET_PRIV (window_ios);
|
||||
GstVulkanUIView *view = (__bridge GstVulkanUIView *) priv->internal_view;
|
||||
|
||||
[view setGstWindow:NULL];
|
||||
CFBridgingRelease (window_ios->priv->internal_view);
|
||||
window_ios->priv->internal_view = NULL;
|
||||
CFBridgingRelease (window_ios->priv->internal_layer);
|
||||
window_ios->priv->internal_layer = NULL;
|
||||
CFBridgingRelease (priv->internal_view);
|
||||
priv->internal_view = NULL;
|
||||
CFBridgingRelease (priv->internal_layer);
|
||||
priv->internal_layer = NULL;
|
||||
|
||||
GST_VULKAN_WINDOW_CLASS (parent_class)->close (window);
|
||||
}
|
||||
|
@ -271,12 +274,12 @@ gst_vulkan_window_ios_set_window_handle (GstVulkanWindow * window,
|
|||
|
||||
g_return_if_fail (view != NULL);
|
||||
|
||||
if (window_ios->priv->external_view && window_ios->priv->external_view != view) {
|
||||
if (priv->external_view && priv->external_view != view) {
|
||||
GST_FIXME_OBJECT (window_ios, "View changes are not implemented");
|
||||
return;
|
||||
}
|
||||
|
||||
window_ios->priv->external_view = view;
|
||||
priv->external_view = view;
|
||||
}
|
||||
|
||||
@implementation GstVulkanUIView {
|
||||
|
|
|
@ -53,6 +53,8 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
|||
G_DEFINE_TYPE_WITH_CODE (GstVulkanWindowWin32, gst_vulkan_window_win32,
|
||||
GST_TYPE_VULKAN_WINDOW, G_ADD_PRIVATE (GstVulkanWindowWin32) DEBUG_INIT);
|
||||
|
||||
#define GET_PRIV(window) gst_vulkan_window_win32_get_instance_private (window)
|
||||
|
||||
static void gst_vulkan_window_win32_set_window_handle (GstVulkanWindow * window,
|
||||
guintptr handle);
|
||||
static VkSurfaceKHR
|
||||
|
@ -84,10 +86,10 @@ gst_vulkan_window_win32_class_init (GstVulkanWindowWin32Class * klass)
|
|||
static void
|
||||
gst_vulkan_window_win32_init (GstVulkanWindowWin32 * window)
|
||||
{
|
||||
window->priv = gst_vulkan_window_win32_get_instance_private (window);
|
||||
GstVulkanWindowWin32Private *priv = GET_PRIV (window);
|
||||
|
||||
window->priv->preferred_width = 320;
|
||||
window->priv->preferred_height = 240;
|
||||
priv->preferred_width = 320;
|
||||
priv->preferred_height = 240;
|
||||
}
|
||||
|
||||
GstVulkanWindowWin32 *
|
||||
|
@ -148,6 +150,7 @@ static gboolean
|
|||
gst_vulkan_window_win32_open (GstVulkanWindow * window, GError ** error)
|
||||
{
|
||||
GstVulkanWindowWin32 *window_win32 = GST_VULKAN_WINDOW_WIN32 (window);
|
||||
GstVulkanWindowWin32Private *priv = GET_PRIV (window_win32);
|
||||
GstVulkanDisplay *display;
|
||||
GMainContext *context;
|
||||
CreateWindowData data = { 0, };
|
||||
|
@ -159,9 +162,8 @@ gst_vulkan_window_win32_open (GstVulkanWindow * window, GError ** error)
|
|||
context = g_main_context_ref (display->main_context);
|
||||
gst_object_unref (display);
|
||||
|
||||
window_win32->priv->msg_io_channel = g_io_channel_win32_new_messages (0);
|
||||
window_win32->msg_source =
|
||||
g_io_create_watch (window_win32->priv->msg_io_channel, G_IO_IN);
|
||||
priv->msg_io_channel = g_io_channel_win32_new_messages (0);
|
||||
msg_source = g_io_create_watch (priv->msg_io_channel, G_IO_IN);
|
||||
g_source_set_callback (window_win32->msg_source, (GSourceFunc) msg_cb, NULL,
|
||||
NULL);
|
||||
g_source_attach (window_win32->msg_source, context);
|
||||
|
@ -193,6 +195,7 @@ static void
|
|||
gst_vulkan_window_win32_close (GstVulkanWindow * window)
|
||||
{
|
||||
GstVulkanWindowWin32 *window_win32 = GST_VULKAN_WINDOW_WIN32 (window);
|
||||
GstVulkanWindowWin32Private *priv = GET_PRIV (window_win32);
|
||||
|
||||
release_parent_win_id (window_win32);
|
||||
|
||||
|
@ -209,8 +212,8 @@ gst_vulkan_window_win32_close (GstVulkanWindow * window)
|
|||
g_source_destroy (window_win32->msg_source);
|
||||
g_source_unref (window_win32->msg_source);
|
||||
window_win32->msg_source = NULL;
|
||||
g_io_channel_unref (window_win32->priv->msg_io_channel);
|
||||
window_win32->priv->msg_io_channel = NULL;
|
||||
g_io_channel_unref (priv->msg_io_channel);
|
||||
priv->msg_io_channel = NULL;
|
||||
|
||||
GST_VULKAN_WINDOW_CLASS (parent_class)->close (window);
|
||||
}
|
||||
|
@ -455,8 +458,9 @@ gst_vulkan_window_win32_set_window_handle (GstVulkanWindow * window,
|
|||
static void
|
||||
gst_vulkan_window_win32_show (GstVulkanWindowWin32 * window)
|
||||
{
|
||||
gint width = window->priv->preferred_width;
|
||||
gint height = window->priv->preferred_height;
|
||||
GstVulkanWindowWin32Private *priv = GET_PRIV (window);
|
||||
gint width = priv->preferred_width;
|
||||
gint height = priv->preferred_height;
|
||||
|
||||
if (!window->visible) {
|
||||
HWND parent_id = window->parent_win_id;
|
||||
|
|
|
@ -58,8 +58,6 @@ struct _GstVulkanWindowWin32 {
|
|||
GSource *msg_source;
|
||||
|
||||
/*< private >*/
|
||||
GstVulkanWindowWin32Private *priv;
|
||||
|
||||
gpointer _reserved[GST_PADDING];
|
||||
};
|
||||
|
||||
|
|
|
@ -28,8 +28,7 @@
|
|||
#include "gstvkwindow_xcb.h"
|
||||
#include "gstvkdisplay_xcb.h"
|
||||
|
||||
#define GST_VULKAN_WINDOW_XCB_GET_PRIVATE(o) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE((o), GST_TYPE_VULKAN_WINDOW_XCB, GstVulkanWindowXCBPrivate))
|
||||
#define GET_PRIV(o) gst_vulkan_window_xcb_get_instance_private (o)
|
||||
|
||||
#define GST_CAT_DEFAULT gst_vulkan_window_xcb_debug
|
||||
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
||||
|
@ -100,7 +99,6 @@ gst_vulkan_window_xcb_class_init (GstVulkanWindowXCBClass * klass)
|
|||
static void
|
||||
gst_vulkan_window_xcb_init (GstVulkanWindowXCB * window)
|
||||
{
|
||||
window->priv = gst_vulkan_window_xcb_get_instance_private (window);
|
||||
}
|
||||
|
||||
/* Must be called in the gl thread */
|
||||
|
@ -303,6 +301,7 @@ static void
|
|||
gst_vulkan_window_xcb_close (GstVulkanWindow * window)
|
||||
{
|
||||
GstVulkanWindowXCB *window_xcb = GST_VULKAN_WINDOW_XCB (window);
|
||||
GstVulkanWindowXCBPrivate *priv = GET_PRIV (window_xcb);
|
||||
GstVulkanDisplayXCB *display_xcb = (GstVulkanDisplayXCB *) window->display;
|
||||
xcb_connection_t *connection =
|
||||
GST_VULKAN_DISPLAY_XCB_CONNECTION (display_xcb);
|
||||
|
@ -310,8 +309,8 @@ gst_vulkan_window_xcb_close (GstVulkanWindow * window)
|
|||
if (connection) {
|
||||
gst_vulkan_window_xcb_hide (window);
|
||||
|
||||
g_free (window_xcb->priv->atom_wm_delete_window);
|
||||
window_xcb->priv->atom_wm_delete_window = NULL;
|
||||
g_free (priv->atom_wm_delete_window);
|
||||
priv->atom_wm_delete_window = NULL;
|
||||
GST_DEBUG ("display receiver closed");
|
||||
}
|
||||
|
||||
|
|
|
@ -59,8 +59,6 @@ struct _GstVulkanWindowXCB
|
|||
PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR GetPhysicalDeviceXcbPresentationSupport;
|
||||
|
||||
/*< private >*/
|
||||
GstVulkanWindowXCBPrivate *priv;
|
||||
|
||||
gpointer _reserved[GST_PADDING];
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue