From ce7256e0d38228d5d0ed1cf6a9b5bdefa7cb2e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Wed, 5 Apr 2023 10:09:39 +0200 Subject: [PATCH] vulkan: use gst_vulkan_format_get_aspect() In order to use it, without depending in a previous calling of _create_info_from_args(), VkFormat as input parameter to gst_vulkan_image_memory_init() was added. Part-of: --- .../gst-libs/gst/vulkan/gstvkimagememory.c | 13 +++++++------ .../gst-libs/gst/vulkan/gstvkimagememory.h | 1 + .../sys/applemedia/iosurfacevulkanmemory.c | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagememory.c b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagememory.c index 755fe3823d..de22939a13 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagememory.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagememory.c @@ -71,8 +71,8 @@ _create_info_from_args (VkImageCreateInfo * info, VkFormat format, gsize width, gboolean gst_vulkan_image_memory_init (GstVulkanImageMemory * mem, GstAllocator * allocator, GstMemory * parent, GstVulkanDevice * device, - VkImageUsageFlags usage, GstAllocationParams * params, gsize size, - gpointer user_data, GDestroyNotify notify) + VkFormat format, VkImageUsageFlags usage, GstAllocationParams * params, + gsize size, gpointer user_data, GDestroyNotify notify) { gsize align = gst_memory_alignment, offset = 0, maxsize = size; GstMemoryFlags flags = 0; @@ -94,7 +94,7 @@ gst_vulkan_image_memory_init (GstVulkanImageMemory * mem, mem->barrier.image_layout = VK_IMAGE_LAYOUT_UNDEFINED; /* *INDENT-OFF* */ mem->barrier.subresource_range = (VkImageSubresourceRange) { - .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, + .aspectMask = gst_vulkan_format_get_aspect (format), .baseMipLevel = 0, .levelCount = 1, .baseArrayLayer = 0, @@ -156,7 +156,8 @@ _vk_image_mem_new_alloc_with_image_info (GstAllocator * allocator, vkGetImageMemoryRequirements (device->device, image, &mem->requirements); gst_vulkan_image_memory_init (mem, allocator, parent, device, - image_info->usage, ¶ms, mem->requirements.size, user_data, notify); + image_info->format, image_info->usage, ¶ms, mem->requirements.size, + user_data, notify); mem->create_info = *image_info; /* XXX: to avoid handling pNext lifetime */ mem->create_info.pNext = NULL; @@ -245,8 +246,8 @@ _vk_image_mem_new_wrapped (GstAllocator * allocator, GstMemory * parent, /* XXX: assumes alignment is a power of 2 */ params.align = mem->requirements.alignment - 1; params.flags = GST_MEMORY_FLAG_NOT_MAPPABLE; - gst_vulkan_image_memory_init (mem, allocator, parent, device, usage, ¶ms, - mem->requirements.size, user_data, notify); + gst_vulkan_image_memory_init (mem, allocator, parent, device, format, usage, + ¶ms, mem->requirements.size, user_data, notify); mem->wrapped = TRUE; if (!_create_info_from_args (&mem->create_info, format, width, height, tiling, diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagememory.h b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagememory.h index b688531dc9..29bca01537 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagememory.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/gstvkimagememory.h @@ -170,6 +170,7 @@ gboolean gst_vulkan_image_memory_init (GstVulkanImageMemory * GstAllocator * allocator, GstMemory * parent, GstVulkanDevice * device, + VkFormat format, VkImageUsageFlags usage, GstAllocationParams * params, gsize size, diff --git a/subprojects/gst-plugins-bad/sys/applemedia/iosurfacevulkanmemory.c b/subprojects/gst-plugins-bad/sys/applemedia/iosurfacevulkanmemory.c index 2bf2e5da76..0f89085667 100644 --- a/subprojects/gst-plugins-bad/sys/applemedia/iosurfacevulkanmemory.c +++ b/subprojects/gst-plugins-bad/sys/applemedia/iosurfacevulkanmemory.c @@ -194,8 +194,8 @@ _io_surface_vulkan_memory_new (GstVulkanDevice * device, IOSurfaceRef surface, &mem->vulkan_mem.requirements); gst_vulkan_image_memory_init (&mem->vulkan_mem, - _io_surface_vulkan_memory_allocator, NULL, device, usage, ¶ms, - mem->vulkan_mem.requirements.size, user_data, notify); + _io_surface_vulkan_memory_allocator, NULL, device, vk_format, usage, + ¶ms, mem->vulkan_mem.requirements.size, user_data, notify); mem->vulkan_mem.create_info = image_info; mem->vulkan_mem.image = image; mem->vulkan_mem.barrier.image_layout = VK_IMAGE_LAYOUT_GENERAL;