[Mesa-dev] [PATCH v11 09/15] vulkan/wsi/x11: Cleanly handle shutdowns in FIFO thread

Jason Ekstrand jason at jlekstrand.net
Wed Feb 21 20:50:06 UTC 2018


On Wed, Feb 21, 2018 at 6:05 AM, Daniel Stone <daniels at collabora.com> wrote:

> The FIFO thread signals shutdown by pushing UINT32_MAX into the acquire
> queue, and shutdown is signaled to it by pushing UINT32_MAX into the
> present queue.
>
> Explicitly catch a push of UINT32_MAX in either direction and treat this
> as error.
>
> Signed-off-by: Daniel Stone <daniels at collabora.com>
> ---
>  src/vulkan/wsi/wsi_common_x11.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_
> x11.c
> index e84572810d3..dadada82ef1 100644
> --- a/src/vulkan/wsi/wsi_common_x11.c
> +++ b/src/vulkan/wsi/wsi_common_x11.c
> @@ -832,7 +832,7 @@ x11_acquire_next_image_from_queue(struct
> x11_swapchain *chain,
>     VkResult result = wsi_queue_pull(&chain->acquire_queue,
>                                      &image_index, timeout);
>     /* On error, the thread has shut down, so safe to update chain->status
> */
> -   if (result < 0)
> +   if (result < 0 || image_index == UINT32_MAX)
>

This only fixes an issue created by the previous patch.


>        return x11_swapchain_result(chain, result);
>
>     assert(image_index < chain->base.image_count);
> @@ -938,7 +938,7 @@ x11_manage_fifo_queues(void *state)
>        result = wsi_queue_pull(&chain->present_queue, &image_index,
> INT64_MAX);
>        if (result < 0) {
>           goto fail;
> -      } else if (chain->status < 0) {
> +      } else if (chain->status < 0 || image_index == UINT32_MAX) {
>

The one time UINT32_MAX is pushed onto the queue, chain->status is set to
VK_ERROR_OUT_OF_DATE_KHR.


>           /* The status can change underneath us if the swapchain is
> destroyed
>            * from another thread.
>            */
> --
> 2.14.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180221/211cedde/attachment-0001.html>


More information about the mesa-dev mailing list