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_DEVICE_H_ 22 #define _VK_DEVICE_H_ 23 24 #include <gst/gst.h> 25 #include "vk.h" 26 27 G_BEGIN_DECLS 28 29 #define GST_TYPE_VULKAN_DEVICE (gst_vulkan_device_get_type()) 30 #define GST_VULKAN_DEVICE(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_VULKAN_DEVICE, GstVulkanDevice)) 31 #define GST_VULKAN_DEVICE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GST_TYPE_VULKAN_DEVICE, GstVulkanDeviceClass)) 32 #define GST_IS_VULKAN_DEVICE(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_VULKAN_DEVICE)) 33 #define GST_IS_VULKAN_DEVICE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_VULKAN_DEVICE)) 34 #define GST_VULKAN_DEVICE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_VULKAN_DEVICE, GstVulkanDeviceClass)) 35 GType gst_vulkan_device_get_type (void); 36 37 #define GST_VULKAN_DEVICE_CONTEXT_TYPE_STR "gst.vulkan.device" 38 39 typedef gboolean (*GstVulkanDeviceForEachQueueFunc) (GstVulkanDevice * device, GstVulkanQueue * queue, gpointer user_data); 40 41 struct _GstVulkanDevice 42 { 43 GstObject parent; 44 45 GstVulkanInstance *instance; 46 47 guint device_index; 48 VkDevice device; /* hides a pointer */ 49 VkPhysicalDeviceProperties gpu_props; 50 VkPhysicalDeviceFeatures gpu_features; 51 VkPhysicalDeviceMemoryProperties memory_properties; 52 53 VkQueueFamilyProperties *queue_family_props; 54 guint32 n_queue_families; 55 56 guint32 queue_family_id; 57 guint32 n_queues; 58 59 VkCommandPool cmd_pool; 60 61 GstVulkanDevicePrivate *priv; 62 }; 63 64 struct _GstVulkanDeviceClass 65 { 66 GstObjectClass parent_class; 67 }; 68 69 GstVulkanDevice * gst_vulkan_device_new (GstVulkanInstance * instance); 70 GstVulkanInstance * gst_vulkan_device_get_instance (GstVulkanDevice * device); 71 gboolean gst_vulkan_device_open (GstVulkanDevice * device, 72 GError ** error); 73 74 gpointer gst_vulkan_device_get_proc_address (GstVulkanDevice * device, 75 const gchar * name); 76 void gst_vulkan_device_foreach_queue (GstVulkanDevice * device, 77 GstVulkanDeviceForEachQueueFunc func, 78 gpointer user_data); 79 GstVulkanQueue * gst_vulkan_device_get_queue (GstVulkanDevice * device, 80 guint32 queue_family, 81 guint32 queue_i); 82 VkPhysicalDevice gst_vulkan_device_get_physical_device (GstVulkanDevice * device); 83 gboolean gst_vulkan_device_create_cmd_buffer (GstVulkanDevice * device, 84 VkCommandBuffer * cmd, 85 GError ** error); 86 87 void gst_context_set_vulkan_device (GstContext * context, 88 GstVulkanDevice * device); 89 gboolean gst_context_get_vulkan_device (GstContext * context, 90 GstVulkanDevice ** device); 91 gboolean gst_vulkan_device_handle_context_query (GstElement * element, 92 GstQuery * query, 93 GstVulkanDevice ** device); 94 gboolean gst_vulkan_device_run_context_query (GstElement * element, 95 GstVulkanDevice ** device); 96 97 G_END_DECLS 98 99 #endif /* _VK_DEVICE_H_ */ 100