vkbuffer: remove buffer view from the memory
authorMatthew Waters <matthew@centricular.com>
Tue, 24 Sep 2019 03:53:22 +0000 (13:53 +1000)
committerMatthew Waters <matthew@centricular.com>
Wed, 25 Sep 2019 11:11:02 +0000 (11:11 +0000)
It's only really useful for texture buffers which we currently do not
use.

ext/vulkan/vkcolorconvert.c
ext/vulkan/vkfullscreenrender.c
ext/vulkan/vkviewconvert.c
gst-libs/gst/vulkan/gstvkbuffermemory.c
gst-libs/gst/vulkan/gstvkbuffermemory.h
gst-libs/gst/vulkan/gstvkbufferpool.c
tests/check/libs/vkmemory.c

index c910b1022da9f44babc0137ab80effb31e0b42be..b03fc698c7e9936b52838e9ebf08e2552cf2fd1e 100644 (file)
@@ -1479,7 +1479,7 @@ _create_uniform_buffer (GstVulkanColorConvert * conv)
 
   if (conv->current_shader->uniform_size) {
     conv->uniform =
-        gst_vulkan_buffer_memory_alloc (render->device, VK_FORMAT_R8_UNORM,
+        gst_vulkan_buffer_memory_alloc (render->device,
         conv->current_shader->uniform_size,
         VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
         VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
index 49897900214ccad1189e768840b20674ec7777ea..b627e943b15e8ea794e59e71f236061ca74e367f 100644 (file)
@@ -689,8 +689,7 @@ _create_vertex_buffers (GstVulkanFullScreenRender * render)
   GstMapInfo map_info;
 
   render->vertices =
-      gst_vulkan_buffer_memory_alloc (render->device, VK_FORMAT_R8_UNORM,
-      sizeof (vertices),
+      gst_vulkan_buffer_memory_alloc (render->device, sizeof (vertices),
       VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
       VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
       VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
@@ -704,8 +703,7 @@ _create_vertex_buffers (GstVulkanFullScreenRender * render)
   gst_memory_unmap (render->vertices, &map_info);
 
   render->indices =
-      gst_vulkan_buffer_memory_alloc (render->device, VK_FORMAT_R8_UNORM,
-      sizeof (indices),
+      gst_vulkan_buffer_memory_alloc (render->device, sizeof (indices),
       VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT,
       VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
       VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
index ed5fc0393ae70ac91018d3c36648615b5ef21cd0..8711e3f297dfd0ab03d75f3dcf9c0b3f3456cda6 100644 (file)
@@ -2088,7 +2088,7 @@ _create_uniform_buffer (GstVulkanViewConvert * conv)
   GstVulkanFullScreenRender *render = GST_VULKAN_FULL_SCREEN_RENDER (conv);
 
   conv->uniform =
-      gst_vulkan_buffer_memory_alloc (render->device, VK_FORMAT_R8_UNORM,
+      gst_vulkan_buffer_memory_alloc (render->device,
       sizeof (struct ViewUpdate),
       VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
       VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
index 4dc15e82c7316e1d5336bb797d02fae6319f07ac..494a5f425b9fb955d78592fc9a9c74b82b7bb60f 100644 (file)
@@ -60,28 +60,6 @@ _create_info_from_args (VkBufferCreateInfo * info, gsize size,
   return TRUE;
 }
 
-static gboolean
-_create_view_from_args (VkBufferViewCreateInfo * info, VkBuffer buffer,
-    VkFormat format, gsize offset, gsize range)
-{
-  /* FIXME: validate these */
-  g_assert (format != VK_FORMAT_UNDEFINED);
-
-  /* *INDENT-OFF* */
-  *info = (VkBufferViewCreateInfo) {
-      .sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO,
-      .pNext = NULL,
-      .flags = 0,
-      .buffer = buffer,
-      .format = format,
-      .offset = offset,
-      .range = range,
-  };
-  /* *INDENT-ON* */
-
-  return TRUE;
-}
-
 static void
 _vk_buffer_mem_init (GstVulkanBufferMemory * mem, GstAllocator * allocator,
     GstMemory * parent, GstVulkanDevice * device, VkBufferUsageFlags usage,
@@ -119,9 +97,9 @@ _vk_buffer_mem_init (GstVulkanBufferMemory * mem, GstAllocator * allocator,
 
 static GstVulkanBufferMemory *
 _vk_buffer_mem_new_alloc (GstAllocator * allocator, GstMemory * parent,
-    GstVulkanDevice * device, VkFormat format, gsize size,
-    VkBufferUsageFlags usage, VkMemoryPropertyFlags mem_prop_flags,
-    gpointer user_data, GDestroyNotify notify)
+    GstVulkanDevice * device, gsize size, VkBufferUsageFlags usage,
+    VkMemoryPropertyFlags mem_prop_flags, gpointer user_data,
+    GDestroyNotify notify)
 {
   GstVulkanBufferMemory *mem = NULL;
   GstAllocationParams params = { 0, };
@@ -167,17 +145,6 @@ _vk_buffer_mem_new_alloc (GstAllocator * allocator, GstMemory * parent,
   if (gst_vulkan_error_to_g_error (err, &error, "vkBindBufferMemory") < 0)
     goto vk_error;
 
-  if (usage & (VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT |
-          VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT)) {
-    VkBufferViewCreateInfo view_info;
-
-    _create_view_from_args (&view_info, mem->buffer, format, 0,
-        mem->requirements.size);
-    err = vkCreateBufferView (device->device, &view_info, NULL, &mem->view);
-    if (gst_vulkan_error_to_g_error (err, &error, "vkCreateBufferView") < 0)
-      goto vk_error;
-  }
-
   return mem;
 
 vk_error:
@@ -198,13 +165,11 @@ error:
 
 static GstVulkanBufferMemory *
 _vk_buffer_mem_new_wrapped (GstAllocator * allocator, GstMemory * parent,
-    GstVulkanDevice * device, VkBuffer buffer, VkFormat format,
-    VkBufferUsageFlags usage, gpointer user_data, GDestroyNotify notify)
+    GstVulkanDevice * device, VkBuffer buffer, VkBufferUsageFlags usage,
+    gpointer user_data, GDestroyNotify notify)
 {
   GstVulkanBufferMemory *mem = g_new0 (GstVulkanBufferMemory, 1);
   GstAllocationParams params = { 0, };
-  GError *error = NULL;
-  VkResult err;
 
   mem->buffer = buffer;
 
@@ -217,34 +182,7 @@ _vk_buffer_mem_new_wrapped (GstAllocator * allocator, GstMemory * parent,
       mem->requirements.size, user_data, notify);
   mem->wrapped = TRUE;
 
-  /* XXX: we don't actually if the buffer has a vkDeviceMemory bound so
-   * this may fail */
-  if (usage & (VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT |
-          VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT)) {
-    VkBufferViewCreateInfo view_info;
-
-    _create_view_from_args (&view_info, mem->buffer, format, 0,
-        mem->requirements.size);
-    err = vkCreateBufferView (device->device, &view_info, NULL, &mem->view);
-    if (gst_vulkan_error_to_g_error (err, &error, "vkCreateBufferView") < 0)
-      goto vk_error;
-  }
-
   return mem;
-
-vk_error:
-  {
-    GST_CAT_ERROR (GST_CAT_VULKAN_BUFFER_MEMORY,
-        "Failed to allocate buffer memory %s", error->message);
-    g_clear_error (&error);
-    goto error;
-  }
-
-error:
-  {
-    gst_memory_unref ((GstMemory *) mem);
-    return NULL;
-  }
 }
 
 static gpointer
@@ -322,9 +260,6 @@ _vk_buffer_mem_free (GstAllocator * allocator, GstMemory * memory)
   if (mem->buffer && !mem->wrapped)
     vkDestroyBuffer (mem->device->device, mem->buffer, NULL);
 
-  if (mem->view)
-    vkDestroyBufferView (mem->device->device, mem->view, NULL);
-
   if (mem->vk_mem)
     gst_memory_unref ((GstMemory *) mem->vk_mem);
 
@@ -339,7 +274,6 @@ _vk_buffer_mem_free (GstAllocator * allocator, GstMemory * memory)
 /**
  * gst_vulkan_buffer_memory_alloc:
  * @device: a #GstVulkanDevice
- * @format: the format for the buffer
  * @size: size of the new buffer
  * @usage: buffer usage flags
  * @mem_prop_flags: memory properties flags for the backing memory
@@ -352,13 +286,13 @@ _vk_buffer_mem_free (GstAllocator * allocator, GstMemory * memory)
  * Since: 1.18
  */
 GstMemory *
-gst_vulkan_buffer_memory_alloc (GstVulkanDevice * device, VkFormat format,
-    gsize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags mem_prop_flags)
+gst_vulkan_buffer_memory_alloc (GstVulkanDevice * device, gsize size,
+    VkBufferUsageFlags usage, VkMemoryPropertyFlags mem_prop_flags)
 {
   GstVulkanBufferMemory *mem;
 
   mem = _vk_buffer_mem_new_alloc (_vulkan_buffer_memory_allocator, NULL, device,
-      format, size, usage, mem_prop_flags, NULL, NULL);
+      size, usage, mem_prop_flags, NULL, NULL);
 
   return (GstMemory *) mem;
 }
@@ -367,7 +301,6 @@ gst_vulkan_buffer_memory_alloc (GstVulkanDevice * device, VkFormat format,
  * gst_vulkan_buffer_memory_wrapped:
  * @device: a #GstVulkanDevice
  * @buffer: a #VkBuffer
- * @format: the #VkFormat of @buffer
  * @usage: usage flags of @buffer
  * @user_data: (allow-none): user data to call @notify with
  * @notify: (allow-none): a #GDestroyNotify called when @buffer is no longer in use
@@ -380,14 +313,13 @@ gst_vulkan_buffer_memory_alloc (GstVulkanDevice * device, VkFormat format,
  */
 GstMemory *
 gst_vulkan_buffer_memory_wrapped (GstVulkanDevice * device, VkBuffer buffer,
-    VkFormat format, VkBufferUsageFlags usage, gpointer user_data,
-    GDestroyNotify notify)
+    VkBufferUsageFlags usage, gpointer user_data, GDestroyNotify notify)
 {
   GstVulkanBufferMemory *mem;
 
   mem =
       _vk_buffer_mem_new_wrapped (_vulkan_buffer_memory_allocator, NULL, device,
-      buffer, format, usage, user_data, notify);
+      buffer, usage, user_data, notify);
 
   return (GstMemory *) mem;
 }
index dc372407c60f216af8af642aa39dd5fe2ac99ad8..61347d00bc8ba3dab9c6323ceeeefecb68fd551a 100644 (file)
@@ -60,7 +60,6 @@ struct _GstVulkanBufferMemory
   GstVulkanDevice * device;
 
   VkBuffer buffer;
-  VkBufferView view;
   GstVulkanMemory *vk_mem;
 
   VkMemoryRequirements requirements;
@@ -101,7 +100,6 @@ gboolean        gst_is_vulkan_buffer_memory              (GstMemory * mem);
 
 GST_VULKAN_API
 GstMemory *     gst_vulkan_buffer_memory_alloc           (GstVulkanDevice * device,
-                                                         VkFormat format,
                                                          gsize size,
                                                          VkBufferUsageFlags usage,
                                                          VkMemoryPropertyFlags mem_prop_flags);
@@ -109,7 +107,6 @@ GstMemory *     gst_vulkan_buffer_memory_alloc           (GstVulkanDevice * devi
 GST_VULKAN_API
 GstMemory *     gst_vulkan_buffer_memory_wrapped         (GstVulkanDevice * device,
                                                          VkBuffer buffer,
-                                                         VkFormat format,
                                                          VkBufferUsageFlags usage,
                                                          gpointer user_data,
                                                          GDestroyNotify notify);
index b7e1308357a13de02bd4139b8d92ed2bc2affdf9..78add7bdd017f544f19a3c6335830c11abfcd95d 100644 (file)
@@ -145,14 +145,9 @@ gst_vulkan_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
   }
 
   for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&priv->v_info); i++) {
-    GstVideoFormat v_format = GST_VIDEO_INFO_FORMAT (&priv->v_info);
-    VkFormat vk_format;
     GstMemory *mem;
 
-    vk_format = gst_vulkan_format_from_video_format (v_format, i);
-
-    mem = gst_vulkan_buffer_memory_alloc (vk_pool->device,
-        vk_format, priv->alloc_sizes[i],
+    mem = gst_vulkan_buffer_memory_alloc (vk_pool->device, priv->alloc_sizes[i],
         /* FIXME: choose from outside */
         VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
         /* FIXME: choose from outside */
index 4d9f24b63e01e3decdd9225b45df4e3605299570..3379d121c2b4d7e9d9321beec87ba42afe2a5b56 100644 (file)
@@ -64,7 +64,7 @@ GST_START_TEST (test_buffer_mem_allocate)
 
   usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT;
   mem =
-      gst_vulkan_buffer_memory_alloc (device, VK_FORMAT_R8_UNORM, orig_size,
+      gst_vulkan_buffer_memory_alloc (device, orig_size,
       usage, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
   fail_unless (gst_is_vulkan_buffer_memory (mem));
   vk_mem = (GstVulkanBufferMemory *) mem;