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 __GST_VULKAN_BUFFER_MEMORY_H__ 22 #define __GST_VULKAN_BUFFER_MEMORY_H__ 23 24 #include <gst/gst.h> 25 #include <gst/gstallocator.h> 26 #include <gst/gstmemory.h> 27 28 #include <gst/vulkan/gstvkbarrier.h> 29 #include <gst/vulkan/vulkan.h> 30 31 G_BEGIN_DECLS 32 33 #define GST_TYPE_VULKAN_BUFFER_MEMORY_ALLOCATOR (gst_vulkan_buffer_memory_allocator_get_type()) 34 GST_VULKAN_API 35 GType gst_vulkan_buffer_memory_allocator_get_type(void); 36 37 #define GST_IS_VULKAN_BUFFER_MEMORY_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VULKAN_BUFFER_MEMORY_ALLOCATOR)) 38 #define GST_IS_VULKAN_BUFFER_MEMORY_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_VULKAN_BUFFER_MEMORY_ALLOCATOR)) 39 #define GST_VULKAN_BUFFER_MEMORY_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VULKAN_MEMORY_ALLOCATOR, GstVulkanBufferMemoryAllocatorClass)) 40 #define GST_VULKAN_BUFFER_MEMORY_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VULKAN_MEMORY_ALLOCATOR, GstVulkanBufferMemoryAllocator)) 41 #define GST_VULKAN_BUFFER_MEMORY_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_VULKAN_MEMORY_ALLOCATOR, GstVulkanBufferMemoryAllocatorClass)) 42 /** 43 * GST_VULKAN_BUFFER_MEMORY_ALLOCATOR_CAST: 44 * 45 * Since: 1.18 46 */ 47 #define GST_VULKAN_BUFFER_MEMORY_ALLOCATOR_CAST(obj) ((GstVulkanBufferMemoryAllocator *)(obj)) 48 49 /** 50 * GST_VULKAN_BUFFER_MEMORY_ALLOCATOR_NAME: 51 * 52 * Since: 1.18 53 */ 54 #define GST_VULKAN_BUFFER_MEMORY_ALLOCATOR_NAME "VulkanBuffer" 55 /** 56 * GST_CAPS_FEATURE_MEMORY_VULKAN_BUFFER: 57 * 58 * Since: 1.18 59 */ 60 #define GST_CAPS_FEATURE_MEMORY_VULKAN_BUFFER "memory:VulkanBuffer" 61 62 /** 63 * GstVulkanBarrierBufferInfo: 64 * @parent: parent #GstVulkanBarrierMemoryInfo 65 * @offset: offset into the vulkan buffer to execute the barrier with 66 * @size: size of memory to execute barrier over 67 * 68 * Since: 1.18 69 */ 70 struct _GstVulkanBarrierBufferInfo 71 { 72 GstVulkanBarrierMemoryInfo parent; 73 74 VkDeviceSize offset; 75 VkDeviceSize size; 76 }; 77 /** 78 * GstVulkanBufferMemory: 79 * @parent: parent #GstMemory 80 * @device: the #GstVulkanDevice this vulkan buffer is allocated from 81 * @buffer: Vulkan buffer object 82 * @vk_mem: backing #GstVulkanMemory for @buffer 83 * @requirements: allocation requirements for @buffer 84 * @usage: intended usage for @buffer 85 * @barrier: the last set barrier information 86 * 87 * Since: 1.18 88 */ 89 struct _GstVulkanBufferMemory 90 { 91 GstMemory parent; 92 93 GstVulkanDevice * device; 94 95 VkBuffer buffer; 96 GstVulkanMemory *vk_mem; 97 98 VkMemoryRequirements requirements; 99 VkBufferUsageFlags usage; 100 101 GstVulkanBarrierBufferInfo barrier; 102 103 /* <private> */ 104 GMutex lock; 105 gboolean wrapped; 106 GDestroyNotify notify; 107 gpointer user_data; 108 }; 109 110 /** 111 * GstVulkanBufferMemoryAllocator 112 * @parent: the parent #GstAllocator 113 * 114 * Opaque #GstVulkanBufferMemoryAllocator struct 115 * 116 * Since: 1.18 117 */ 118 struct _GstVulkanBufferMemoryAllocator 119 { 120 GstAllocator parent; 121 122 /* <private> */ 123 gpointer _reserved [GST_PADDING]; 124 }; 125 126 /** 127 * GstVulkanBufferMemoryAllocatorClass: 128 * @parent_class: the parent #GstAllocatorClass 129 * 130 * The #GstVulkanBufferMemoryAllocatorClass only contains private data 131 * 132 * Since: 1.18 133 */ 134 struct _GstVulkanBufferMemoryAllocatorClass 135 { 136 GstAllocatorClass parent_class; 137 138 /* <private> */ 139 gpointer _reserved [GST_PADDING]; 140 }; 141 142 GST_VULKAN_API 143 void gst_vulkan_buffer_memory_init_once (void); 144 GST_VULKAN_API 145 gboolean gst_is_vulkan_buffer_memory (GstMemory * mem); 146 147 GST_VULKAN_API 148 GstMemory * gst_vulkan_buffer_memory_alloc (GstVulkanDevice * device, 149 gsize size, 150 VkBufferUsageFlags usage, 151 VkMemoryPropertyFlags mem_prop_flags); 152 153 GST_VULKAN_API 154 GstMemory * gst_vulkan_buffer_memory_wrapped (GstVulkanDevice * device, 155 VkBuffer buffer, 156 VkBufferUsageFlags usage, 157 gpointer user_data, 158 GDestroyNotify notify); 159 160 G_END_DECLS 161 162 #endif /* __GST_VULKAN_BUFFER_MEMORY_H__ */ 163