new vulkan based video sink
[platform/upstream/gstreamer.git] / ext / vulkan / vkswapper.h
1 /*
2  * GStreamer
3  * Copyright (C) 2015 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 _VK_SWAPPER_H_
22 #define _VK_SWAPPER_H_
23
24 #include <gst/video/video.h>
25
26 #include <vk.h>
27 #include <vulkan/vk_ext_khr_swapchain.h>
28 #include <vulkan/vk_ext_khr_device_swapchain.h>
29
30 G_BEGIN_DECLS
31
32 #define GST_TYPE_VULKAN_SWAPPER         (gst_vulkan_swapper_get_type())
33 #define GST_VULKAN_SWAPPER(o)           (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_VULKAN_SWAPPER, GstVulkanSwapper))
34 #define GST_VULKAN_SWAPPER_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), GST_TYPE_VULKAN_SWAPPER, GstVulkanSwapperClass))
35 #define GST_IS_VULKAN_SWAPPER(o)        (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_VULKAN_SWAPPER))
36 #define GST_IS_VULKAN_SWAPPER_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_VULKAN_SWAPPER))
37 #define GST_VULKAN_SWAPPER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_VULKAN_SWAPPER, GstVulkanSwapperClass))
38 GType gst_vulkan_swapper_get_type       (void);
39
40 struct _GstVulkanSwapper
41 {
42   GstObject parent;
43
44   GstVulkanDevice *device;
45   GstVulkanWindow *window;
46   GstVulkanQueue *queue;
47
48   VkSurfacePropertiesKHR surf_props;
49   VkSurfaceFormatKHR *surf_formats;
50   guint32 n_surf_formats;
51   VkPresentModeKHR *surf_present_modes;
52   guint32 n_surf_present_modes;
53
54   VkSwapchainKHR swap_chain;
55   GstVulkanImageMemory **swap_chain_images;
56   guint32 n_swap_chain_images;
57
58   GstCaps *caps;
59   GstVideoInfo v_info;
60
61   PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR;
62   PFN_vkGetSurfacePropertiesKHR GetSurfacePropertiesKHR;
63   PFN_vkGetSurfaceFormatsKHR GetSurfaceFormatsKHR;
64   PFN_vkGetSurfacePresentModesKHR GetSurfacePresentModesKHR;
65   PFN_vkCreateSwapchainKHR CreateSwapchainKHR;
66   PFN_vkDestroySwapchainKHR DestroySwapchainKHR;
67   PFN_vkGetSwapchainImagesKHR GetSwapchainImagesKHR;
68   PFN_vkAcquireNextImageKHR AcquireNextImageKHR;
69   PFN_vkQueuePresentKHR QueuePresentKHR;
70 };
71
72 struct _GstVulkanSwapperClass
73 {
74   GstObjectClass parent_class;
75 };
76
77 GstVulkanSwapper *  gst_vulkan_swapper_new                      (GstVulkanDevice * device,
78                                                                  GstVulkanWindow * window);
79
80 GstCaps *           gst_vulkan_swapper_get_supported_caps       (GstVulkanSwapper * swapper,
81                                                                  GError ** error);
82 gboolean            gst_vulkan_swapper_set_caps                 (GstVulkanSwapper * swapper,
83                                                                  GstCaps * caps,
84                                                                  GError ** error);
85 gboolean            gst_vulkan_swapper_render_buffer            (GstVulkanSwapper * swapper,
86                                                                  GstBuffer * buffer,
87                                                                  GError ** error);
88
89 G_END_DECLS
90
91 #endif /* _VK_INSTANCE_H_ */