Module: Mesa Branch: main Commit: 142e452e9a38771de2f832991208866a3c4e73cc URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=142e452e9a38771de2f832991208866a3c4e73cc
Author: Chia-I Wu <[email protected]> Date: Thu May 6 09:41:35 2021 -0700 venus: add vn_image_memory_barrier_has_present_src And call it regardless of ANDROID or not. Signed-off-by: Chia-I Wu <[email protected]> Reviewed-by: Yiwei Zhang <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10709> --- src/virtio/vulkan/vn_command_buffer.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/virtio/vulkan/vn_command_buffer.c b/src/virtio/vulkan/vn_command_buffer.c index b782aebfce6..e2836a31232 100644 --- a/src/virtio/vulkan/vn_command_buffer.c +++ b/src/virtio/vulkan/vn_command_buffer.c @@ -17,6 +17,18 @@ #include "vn_image.h" #include "vn_render_pass.h" +static bool +vn_image_memory_barrier_has_present_src( + const VkImageMemoryBarrier *img_barriers, uint32_t count) +{ + for (uint32_t i = 0; i < count; i++) { + if (img_barriers[i].oldLayout == VK_IMAGE_LAYOUT_PRESENT_SRC_KHR || + img_barriers[i].newLayout == VK_IMAGE_LAYOUT_PRESENT_SRC_KHR) + return true; + } + return false; +} + static void vn_cmd_begin_render_pass(struct vn_command_buffer *cmd, const struct vn_render_pass *pass, @@ -1033,19 +1045,13 @@ vn_get_intercepted_barriers(struct vn_command_buffer *cmd, const VkImageMemoryBarrier *img_barriers, uint32_t count) { - /* XXX drop the #ifdef after fixing common wsi */ -#ifdef ANDROID - bool has_present_src = false; - for (uint32_t i = 0; i < count; i++) { - if (img_barriers[i].oldLayout == VK_IMAGE_LAYOUT_PRESENT_SRC_KHR || - img_barriers[i].newLayout == VK_IMAGE_LAYOUT_PRESENT_SRC_KHR) { - has_present_src = false; - break; - } - } + const bool has_present_src = + vn_image_memory_barrier_has_present_src(img_barriers, count); if (!has_present_src) return img_barriers; + /* 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; _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
