Merge master branch into multiple_swapchains_present_req
authorIason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Wed, 10 Nov 2021 14:31:19 +0000 (14:31 +0000)
committerIason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Wed, 10 Nov 2021 15:38:07 +0000 (15:38 +0000)
Change-Id: Ibc6c094d85795e532e59184252896ecd05b50019
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
1  2 
layer/swapchain_api.cpp
wsi/wayland/surface.cpp
wsi/wayland/surface.hpp
wsi/wayland/swapchain.cpp

@@@ -127,56 -128,8 +128,57 @@@ wsi_layer_vkAcquireNextImageKHR(VkDevic
     return sc->acquire_next_image(timeout, semaphore, fence, pImageIndex);
  }
  
- VKAPI_ATTR VkResult wsi_layer_vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo)
 +static VkResult submit_wait_request(VkQueue queue, const VkPresentInfoKHR &present_info,
 +                                    layer::device_private_data &device_data)
 +{
 +   util::vector<VkSemaphore> swapchain_semaphores{ util::allocator(device_data.get_allocator(),
 +                                                                   VK_SYSTEM_ALLOCATION_SCOPE_COMMAND) };
 +   if (!swapchain_semaphores.try_resize(present_info.swapchainCount))
 +   {
 +      return VK_ERROR_OUT_OF_HOST_MEMORY;
 +   }
 +
 +   for (uint32_t i = 0; i < present_info.swapchainCount; ++i)
 +   {
 +      auto swapchain = reinterpret_cast<wsi::swapchain_base *>(present_info.pSwapchains[i]);
 +      swapchain_semaphores[i] = swapchain->get_image_present_semaphore(present_info.pImageIndices[i]);
 +   }
 +
 +   util::vector<VkPipelineStageFlags> pipeline_stage_flags{ util::allocator(device_data.get_allocator(),
 +                                                                            VK_SYSTEM_ALLOCATION_SCOPE_COMMAND) };
 +   if (!pipeline_stage_flags.try_resize(present_info.waitSemaphoreCount))
 +   {
 +      return VK_ERROR_OUT_OF_HOST_MEMORY;
 +   }
 +
 +   for (uint32_t i = 0; i < present_info.waitSemaphoreCount; ++i)
 +   {
 +      pipeline_stage_flags[i] = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
 +   }
 +
 +   VkSubmitInfo submit_info = {
 +      VK_STRUCTURE_TYPE_SUBMIT_INFO,
 +      NULL,
 +      present_info.waitSemaphoreCount,
 +      present_info.pWaitSemaphores,
 +      pipeline_stage_flags.data(),
 +      0,
 +      NULL,
 +      static_cast<uint32_t>(swapchain_semaphores.size()),
 +      swapchain_semaphores.data(),
 +   };
 +
 +   VkResult result = device_data.disp.QueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE);
 +   if (result != VK_SUCCESS)
 +   {
 +      return result;
 +   }
 +
 +   return VK_SUCCESS;
 +}
 +
+ VWL_VKAPI_CALL(VkResult)
+ wsi_layer_vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) VWL_API_POST
  {
     assert(queue != VK_NULL_HANDLE);
     assert(pPresentInfo != nullptr);
Simple merge
Simple merge
Simple merge