From 2ad81d6b971ef0f2fc0c8c36289900f5f7bd7968 Mon Sep 17 00:00:00 2001 From: Normunds Rieksts Date: Tue, 10 Jan 2023 15:45:09 +0000 Subject: Fix a bug in queue submission Fixes a bug in queue submission where the wrong amount of VkPipelineStageFlags were passed to vkQueueSubmit when the number of semaphores to wait on were more than 1. Change-Id: Ic66e0c6a5e4f60659a0fb31c64c565820d4708a8 Signed-off-by: Normunds Rieksts --- wsi/synchronization.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/wsi/synchronization.cpp b/wsi/synchronization.cpp index 198ed35..99692bc 100644 --- a/wsi/synchronization.cpp +++ b/wsi/synchronization.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Arm Limited. + * Copyright (c) 2021-2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -31,6 +31,8 @@ #include "synchronization.hpp" #include "layer/private_data.hpp" +#include + namespace wsi { @@ -103,10 +105,25 @@ VkResult fence_sync::set_payload(VkQueue queue, const VkSemaphore *sem_payload, * want to block any future Vulkan queue work on it. So, we pass in BOTTOM_OF_PIPE bit as the * wait flag. */ - VkPipelineStageFlags pipeline_stage_flags = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; + VkPipelineStageFlags pipeline_stage_flag = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; + VkPipelineStageFlags *pipeline_stage_flag_data = &pipeline_stage_flag; + + util::vector pipeline_stage_flags_vector{ util::allocator( + dev->get_allocator(), VK_SYSTEM_ALLOCATION_SCOPE_COMMAND) }; + /* Try to avoid memory allocation for single semaphore */ + if (sem_count > 1) + { + if (!pipeline_stage_flags_vector.try_resize(sem_count)) + { + return VK_ERROR_OUT_OF_HOST_MEMORY; + } + std::fill(pipeline_stage_flags_vector.begin(), pipeline_stage_flags_vector.end(), + VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT); + pipeline_stage_flag_data = pipeline_stage_flags_vector.data(); + } VkSubmitInfo submit_info = { - VK_STRUCTURE_TYPE_SUBMIT_INFO, nullptr, sem_count, sem_payload, &pipeline_stage_flags, 0, nullptr, 0, nullptr + VK_STRUCTURE_TYPE_SUBMIT_INFO, nullptr, sem_count, sem_payload, pipeline_stage_flag_data, 0, nullptr, 0, nullptr }; result = dev->disp.QueueSubmit(queue, 1, &submit_info, fence); -- cgit v1.2.3