[Mesa-dev] [PATCH v2 20/32] vulkan/wsi: Set a proper pWaitDstStageMask on the dummy submit

Chad Versace chadversary at chromium.org
Sat Dec 2 15:06:58 UTC 2017


On Fri 01 Dec 2017, Chad Versace wrote:
> On Tue 28 Nov 2017, Jason Ekstrand wrote:
> > Neither mesa driver really cares, but we should set it none the less for
> > the sake of correctness.
> > ---
> >  src/vulkan/wsi/wsi_common.c | 17 +++++++++++++++++
> >  1 file changed, 17 insertions(+)
> > 
> > diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c
> > index 4f6648f..e5a9a28 100644
> > --- a/src/vulkan/wsi/wsi_common.c
> > +++ b/src/vulkan/wsi/wsi_common.c
> > @@ -542,14 +542,31 @@ wsi_common_queue_present(const struct wsi_device *wsi,
> >           .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
> >           .pNext = NULL,
> >        };
> > +      VkPipelineStageFlags *stage_flags = NULL;
> >        if (i == 0) {
> >           /* We only need/want to wait on semaphores once.  After that, we're
> >            * guaranteed ordering since it all happens on the same queue.
> >            */
> >           submit_info.waitSemaphoreCount = pPresentInfo->waitSemaphoreCount,
> >           submit_info.pWaitSemaphores = pPresentInfo->pWaitSemaphores,
> > +
> > +         /* Set up the pWaitDstStageMasks */
> > +         stage_flags = vk_alloc(&swapchain->alloc,
> > +                                sizeof(VkPipelineStageFlags) *
> > +                                pPresentInfo->waitSemaphoreCount,
> > +                                8,
> > +                                VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
> > +         if (!stage_flags) {
> > +            result = VK_ERROR_OUT_OF_HOST_MEMORY;
> > +            goto fail_present;
> > +         }
> > +         for (uint32_t s = 0; s < pPresentInfo->waitSemaphoreCount; s++)
> > +            stage_flags[s] = VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT;
> > +
> > +         submit_info.pWaitDstStageMask = stage_flags;
> 
> Since VkSwapchain is required to be externally synchronized, you could
> embed stage_flags directly in struct wsi_swapchain, doubling its size
> when needed. But meh.

Since stage_flags gets freed at the end of the function, you could make
the code simpler by using the stack.

    VkPipelineStageFlags stage_flags[submit_info.waitSemaphoreCount];

But some people don't like stack-allocated arrays.

> Reviewed-by: Chad Versace <chadversary at chromium.org>


More information about the mesa-dev mailing list