Mesa (main): venus: add vn_cmd_get_image_memory_barriers
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jun 3 06:13:17 UTC 2021
Module: Mesa
Branch: main
Commit: 7ec6cb61ad79b3751a93ca1c63767d6b8b178801
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7ec6cb61ad79b3751a93ca1c63767d6b8b178801
Author: Chia-I Wu <olvaffe at gmail.com>
Date: Thu May 6 09:41:58 2021 -0700
venus: add vn_cmd_get_image_memory_barriers
And call it regardless of ANDROID or not.
Signed-off-by: Chia-I Wu <olvaffe at gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10709>
---
src/virtio/vulkan/vn_command_buffer.c | 48 ++++++++++++++++++++++-------------
1 file changed, 30 insertions(+), 18 deletions(-)
diff --git a/src/virtio/vulkan/vn_command_buffer.c b/src/virtio/vulkan/vn_command_buffer.c
index e2836a31232..53faae7f1c6 100644
--- a/src/virtio/vulkan/vn_command_buffer.c
+++ b/src/virtio/vulkan/vn_command_buffer.c
@@ -29,6 +29,27 @@ vn_image_memory_barrier_has_present_src(
return false;
}
+static VkImageMemoryBarrier *
+vn_cmd_get_image_memory_barriers(struct vn_command_buffer *cmd,
+ uint32_t count)
+{
+ /* avoid shrinking in case of non efficient reallocation implementation */
+ if (count > cmd->builder.image_barrier_count) {
+ size_t size = sizeof(VkImageMemoryBarrier) * count;
+ VkImageMemoryBarrier *img_barriers =
+ vk_realloc(&cmd->allocator, cmd->builder.image_barriers, size,
+ VN_DEFAULT_ALIGN, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
+ if (!img_barriers)
+ return NULL;
+
+ /* update upon successful reallocation */
+ cmd->builder.image_barrier_count = count;
+ cmd->builder.image_barriers = img_barriers;
+ }
+
+ return cmd->builder.image_barriers;
+}
+
static void
vn_cmd_begin_render_pass(struct vn_command_buffer *cmd,
const struct vn_render_pass *pass,
@@ -1050,33 +1071,24 @@ vn_get_intercepted_barriers(struct vn_command_buffer *cmd,
if (!has_present_src)
return img_barriers;
+ VkImageMemoryBarrier *barriers =
+ vn_cmd_get_image_memory_barriers(cmd, count);
+ if (!barriers)
+ return img_barriers;
+
+ memcpy(barriers, img_barriers, sizeof(*img_barriers) * count);
+
/* XXX drop the #ifdef after fixing common wsi */
#ifdef ANDROID
- size_t size = sizeof(VkImageMemoryBarrier) * count;
- /* avoid shrinking in case of non efficient reallocation implementation */
- VkImageMemoryBarrier *barriers = cmd->builder.image_barriers;
- if (count > cmd->builder.image_barrier_count) {
- barriers =
- vk_realloc(&cmd->allocator, cmd->builder.image_barriers, size,
- VN_DEFAULT_ALIGN, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
- if (!barriers)
- return img_barriers;
-
- /* update upon successful reallocation */
- cmd->builder.image_barrier_count = count;
- cmd->builder.image_barriers = barriers;
- }
- memcpy(barriers, img_barriers, size);
for (uint32_t i = 0; i < count; i++) {
if (barriers[i].oldLayout == VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)
barriers[i].oldLayout = VK_IMAGE_LAYOUT_GENERAL;
if (barriers[i].newLayout == VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)
barriers[i].newLayout = VK_IMAGE_LAYOUT_GENERAL;
}
- return barriers;
-#else
- return img_barriers;
#endif
+
+ return barriers;
}
void
More information about the mesa-commit
mailing list