mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 09:55:36 +00:00
vkbuffer: remove buffer view from the memory
It's only really useful for texture buffers which we currently do not use.
This commit is contained in:
parent
5165f2509b
commit
452bb72292
7 changed files with 16 additions and 94 deletions
|
@ -1479,7 +1479,7 @@ _create_uniform_buffer (GstVulkanColorConvert * conv)
|
||||||
|
|
||||||
if (conv->current_shader->uniform_size) {
|
if (conv->current_shader->uniform_size) {
|
||||||
conv->uniform =
|
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,
|
conv->current_shader->uniform_size,
|
||||||
VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
|
VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
|
||||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
|
||||||
|
|
|
@ -689,8 +689,7 @@ _create_vertex_buffers (GstVulkanFullScreenRender * render)
|
||||||
GstMapInfo map_info;
|
GstMapInfo map_info;
|
||||||
|
|
||||||
render->vertices =
|
render->vertices =
|
||||||
gst_vulkan_buffer_memory_alloc (render->device, VK_FORMAT_R8_UNORM,
|
gst_vulkan_buffer_memory_alloc (render->device, sizeof (vertices),
|
||||||
sizeof (vertices),
|
|
||||||
VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
|
VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
|
||||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
|
||||||
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
|
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
|
||||||
|
@ -704,8 +703,7 @@ _create_vertex_buffers (GstVulkanFullScreenRender * render)
|
||||||
gst_memory_unmap (render->vertices, &map_info);
|
gst_memory_unmap (render->vertices, &map_info);
|
||||||
|
|
||||||
render->indices =
|
render->indices =
|
||||||
gst_vulkan_buffer_memory_alloc (render->device, VK_FORMAT_R8_UNORM,
|
gst_vulkan_buffer_memory_alloc (render->device, sizeof (indices),
|
||||||
sizeof (indices),
|
|
||||||
VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT,
|
VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT,
|
||||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
|
||||||
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
|
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
|
||||||
|
|
|
@ -2088,7 +2088,7 @@ _create_uniform_buffer (GstVulkanViewConvert * conv)
|
||||||
GstVulkanFullScreenRender *render = GST_VULKAN_FULL_SCREEN_RENDER (conv);
|
GstVulkanFullScreenRender *render = GST_VULKAN_FULL_SCREEN_RENDER (conv);
|
||||||
|
|
||||||
conv->uniform =
|
conv->uniform =
|
||||||
gst_vulkan_buffer_memory_alloc (render->device, VK_FORMAT_R8_UNORM,
|
gst_vulkan_buffer_memory_alloc (render->device,
|
||||||
sizeof (struct ViewUpdate),
|
sizeof (struct ViewUpdate),
|
||||||
VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
|
VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
|
||||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
|
||||||
|
|
|
@ -60,28 +60,6 @@ _create_info_from_args (VkBufferCreateInfo * info, gsize size,
|
||||||
return TRUE;
|
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
|
static void
|
||||||
_vk_buffer_mem_init (GstVulkanBufferMemory * mem, GstAllocator * allocator,
|
_vk_buffer_mem_init (GstVulkanBufferMemory * mem, GstAllocator * allocator,
|
||||||
GstMemory * parent, GstVulkanDevice * device, VkBufferUsageFlags usage,
|
GstMemory * parent, GstVulkanDevice * device, VkBufferUsageFlags usage,
|
||||||
|
@ -119,9 +97,9 @@ _vk_buffer_mem_init (GstVulkanBufferMemory * mem, GstAllocator * allocator,
|
||||||
|
|
||||||
static GstVulkanBufferMemory *
|
static GstVulkanBufferMemory *
|
||||||
_vk_buffer_mem_new_alloc (GstAllocator * allocator, GstMemory * parent,
|
_vk_buffer_mem_new_alloc (GstAllocator * allocator, GstMemory * parent,
|
||||||
GstVulkanDevice * device, VkFormat format, gsize size,
|
GstVulkanDevice * device, gsize size, VkBufferUsageFlags usage,
|
||||||
VkBufferUsageFlags usage, VkMemoryPropertyFlags mem_prop_flags,
|
VkMemoryPropertyFlags mem_prop_flags, gpointer user_data,
|
||||||
gpointer user_data, GDestroyNotify notify)
|
GDestroyNotify notify)
|
||||||
{
|
{
|
||||||
GstVulkanBufferMemory *mem = NULL;
|
GstVulkanBufferMemory *mem = NULL;
|
||||||
GstAllocationParams params = { 0, };
|
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)
|
if (gst_vulkan_error_to_g_error (err, &error, "vkBindBufferMemory") < 0)
|
||||||
goto vk_error;
|
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;
|
return mem;
|
||||||
|
|
||||||
vk_error:
|
vk_error:
|
||||||
|
@ -198,13 +165,11 @@ error:
|
||||||
|
|
||||||
static GstVulkanBufferMemory *
|
static GstVulkanBufferMemory *
|
||||||
_vk_buffer_mem_new_wrapped (GstAllocator * allocator, GstMemory * parent,
|
_vk_buffer_mem_new_wrapped (GstAllocator * allocator, GstMemory * parent,
|
||||||
GstVulkanDevice * device, VkBuffer buffer, VkFormat format,
|
GstVulkanDevice * device, VkBuffer buffer, VkBufferUsageFlags usage,
|
||||||
VkBufferUsageFlags usage, gpointer user_data, GDestroyNotify notify)
|
gpointer user_data, GDestroyNotify notify)
|
||||||
{
|
{
|
||||||
GstVulkanBufferMemory *mem = g_new0 (GstVulkanBufferMemory, 1);
|
GstVulkanBufferMemory *mem = g_new0 (GstVulkanBufferMemory, 1);
|
||||||
GstAllocationParams params = { 0, };
|
GstAllocationParams params = { 0, };
|
||||||
GError *error = NULL;
|
|
||||||
VkResult err;
|
|
||||||
|
|
||||||
mem->buffer = buffer;
|
mem->buffer = buffer;
|
||||||
|
|
||||||
|
@ -217,34 +182,7 @@ _vk_buffer_mem_new_wrapped (GstAllocator * allocator, GstMemory * parent,
|
||||||
mem->requirements.size, user_data, notify);
|
mem->requirements.size, user_data, notify);
|
||||||
mem->wrapped = TRUE;
|
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;
|
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
|
static gpointer
|
||||||
|
@ -322,9 +260,6 @@ _vk_buffer_mem_free (GstAllocator * allocator, GstMemory * memory)
|
||||||
if (mem->buffer && !mem->wrapped)
|
if (mem->buffer && !mem->wrapped)
|
||||||
vkDestroyBuffer (mem->device->device, mem->buffer, NULL);
|
vkDestroyBuffer (mem->device->device, mem->buffer, NULL);
|
||||||
|
|
||||||
if (mem->view)
|
|
||||||
vkDestroyBufferView (mem->device->device, mem->view, NULL);
|
|
||||||
|
|
||||||
if (mem->vk_mem)
|
if (mem->vk_mem)
|
||||||
gst_memory_unref ((GstMemory *) 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:
|
* gst_vulkan_buffer_memory_alloc:
|
||||||
* @device: a #GstVulkanDevice
|
* @device: a #GstVulkanDevice
|
||||||
* @format: the format for the buffer
|
|
||||||
* @size: size of the new buffer
|
* @size: size of the new buffer
|
||||||
* @usage: buffer usage flags
|
* @usage: buffer usage flags
|
||||||
* @mem_prop_flags: memory properties flags for the backing memory
|
* @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
|
* Since: 1.18
|
||||||
*/
|
*/
|
||||||
GstMemory *
|
GstMemory *
|
||||||
gst_vulkan_buffer_memory_alloc (GstVulkanDevice * device, VkFormat format,
|
gst_vulkan_buffer_memory_alloc (GstVulkanDevice * device, gsize size,
|
||||||
gsize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags mem_prop_flags)
|
VkBufferUsageFlags usage, VkMemoryPropertyFlags mem_prop_flags)
|
||||||
{
|
{
|
||||||
GstVulkanBufferMemory *mem;
|
GstVulkanBufferMemory *mem;
|
||||||
|
|
||||||
mem = _vk_buffer_mem_new_alloc (_vulkan_buffer_memory_allocator, NULL, device,
|
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;
|
return (GstMemory *) mem;
|
||||||
}
|
}
|
||||||
|
@ -367,7 +301,6 @@ gst_vulkan_buffer_memory_alloc (GstVulkanDevice * device, VkFormat format,
|
||||||
* gst_vulkan_buffer_memory_wrapped:
|
* gst_vulkan_buffer_memory_wrapped:
|
||||||
* @device: a #GstVulkanDevice
|
* @device: a #GstVulkanDevice
|
||||||
* @buffer: a #VkBuffer
|
* @buffer: a #VkBuffer
|
||||||
* @format: the #VkFormat of @buffer
|
|
||||||
* @usage: usage flags of @buffer
|
* @usage: usage flags of @buffer
|
||||||
* @user_data: (allow-none): user data to call @notify with
|
* @user_data: (allow-none): user data to call @notify with
|
||||||
* @notify: (allow-none): a #GDestroyNotify called when @buffer is no longer in use
|
* @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 *
|
GstMemory *
|
||||||
gst_vulkan_buffer_memory_wrapped (GstVulkanDevice * device, VkBuffer buffer,
|
gst_vulkan_buffer_memory_wrapped (GstVulkanDevice * device, VkBuffer buffer,
|
||||||
VkFormat format, VkBufferUsageFlags usage, gpointer user_data,
|
VkBufferUsageFlags usage, gpointer user_data, GDestroyNotify notify)
|
||||||
GDestroyNotify notify)
|
|
||||||
{
|
{
|
||||||
GstVulkanBufferMemory *mem;
|
GstVulkanBufferMemory *mem;
|
||||||
|
|
||||||
mem =
|
mem =
|
||||||
_vk_buffer_mem_new_wrapped (_vulkan_buffer_memory_allocator, NULL, device,
|
_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;
|
return (GstMemory *) mem;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,6 @@ struct _GstVulkanBufferMemory
|
||||||
GstVulkanDevice * device;
|
GstVulkanDevice * device;
|
||||||
|
|
||||||
VkBuffer buffer;
|
VkBuffer buffer;
|
||||||
VkBufferView view;
|
|
||||||
GstVulkanMemory *vk_mem;
|
GstVulkanMemory *vk_mem;
|
||||||
|
|
||||||
VkMemoryRequirements requirements;
|
VkMemoryRequirements requirements;
|
||||||
|
@ -101,7 +100,6 @@ gboolean gst_is_vulkan_buffer_memory (GstMemory * mem);
|
||||||
|
|
||||||
GST_VULKAN_API
|
GST_VULKAN_API
|
||||||
GstMemory * gst_vulkan_buffer_memory_alloc (GstVulkanDevice * device,
|
GstMemory * gst_vulkan_buffer_memory_alloc (GstVulkanDevice * device,
|
||||||
VkFormat format,
|
|
||||||
gsize size,
|
gsize size,
|
||||||
VkBufferUsageFlags usage,
|
VkBufferUsageFlags usage,
|
||||||
VkMemoryPropertyFlags mem_prop_flags);
|
VkMemoryPropertyFlags mem_prop_flags);
|
||||||
|
@ -109,7 +107,6 @@ GstMemory * gst_vulkan_buffer_memory_alloc (GstVulkanDevice * devi
|
||||||
GST_VULKAN_API
|
GST_VULKAN_API
|
||||||
GstMemory * gst_vulkan_buffer_memory_wrapped (GstVulkanDevice * device,
|
GstMemory * gst_vulkan_buffer_memory_wrapped (GstVulkanDevice * device,
|
||||||
VkBuffer buffer,
|
VkBuffer buffer,
|
||||||
VkFormat format,
|
|
||||||
VkBufferUsageFlags usage,
|
VkBufferUsageFlags usage,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
GDestroyNotify notify);
|
GDestroyNotify notify);
|
||||||
|
|
|
@ -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++) {
|
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;
|
GstMemory *mem;
|
||||||
|
|
||||||
vk_format = gst_vulkan_format_from_video_format (v_format, i);
|
mem = gst_vulkan_buffer_memory_alloc (vk_pool->device, priv->alloc_sizes[i],
|
||||||
|
|
||||||
mem = gst_vulkan_buffer_memory_alloc (vk_pool->device,
|
|
||||||
vk_format, priv->alloc_sizes[i],
|
|
||||||
/* FIXME: choose from outside */
|
/* FIXME: choose from outside */
|
||||||
VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
|
VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
|
||||||
/* FIXME: choose from outside */
|
/* FIXME: choose from outside */
|
||||||
|
|
|
@ -64,7 +64,7 @@ GST_START_TEST (test_buffer_mem_allocate)
|
||||||
|
|
||||||
usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT;
|
usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT;
|
||||||
mem =
|
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);
|
usage, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
|
||||||
fail_unless (gst_is_vulkan_buffer_memory (mem));
|
fail_unless (gst_is_vulkan_buffer_memory (mem));
|
||||||
vk_mem = (GstVulkanBufferMemory *) mem;
|
vk_mem = (GstVulkanBufferMemory *) mem;
|
||||||
|
|
Loading…
Reference in a new issue