[Mesa-dev] [PATCH 7/9] anv: Implement VK_KHX_external_semaphore_fd

Chris Wilson chris at chris-wilson.co.uk
Tue Feb 28 17:14:55 UTC 2017


On Tue, Feb 28, 2017 at 08:56:45AM -0800, Jason Ekstrand wrote:
> This implementation allocates a 4k BO for each semaphore that can be
> exported using OPAQUE_FD and uses the kernel's already-existing
> synchronization mechanism on BOs.
> ---
>  VkResult
>  anv_cmd_buffer_execbuf(struct anv_device *device,
> -                       struct anv_cmd_buffer *cmd_buffer)
> +                       struct anv_cmd_buffer *cmd_buffer,
> +                       const VkSemaphore *in_semaphores,
> +                       uint32_t num_in_semaphores,
> +                       const VkSemaphore *out_semaphores,
> +                       uint32_t num_out_semaphores)
>  {
>     struct anv_execbuf execbuf;
>     anv_execbuf_init(&execbuf);
>  
> +   for (uint32_t i = 0; i < num_in_semaphores; i++) {
> +      ANV_FROM_HANDLE(anv_semaphore, semaphore, in_semaphores[i]);
> +      assert(semaphore->temporary.type == ANV_SEMAPHORE_TYPE_NONE);
> +      struct anv_semaphore_impl *impl = &semaphore->permanent;
> +
> +      switch (impl->type) {
> +      case ANV_SEMAPHORE_TYPE_BO:
> +         anv_execbuf_add_bo(&execbuf, &impl->bo, NULL, 0, &device->alloc);
> +         break;
> +      default:
> +         break;
> +      }
> +   }

Do the in/out semaphores[] have any constraints against repeated use? If
you pass in the same handle twice into the execbuf, it will EINVAL.
(Both within the in/out arrays and between them.)

Or does execbuf_add_bo do a repeated use check?

> +   for (uint32_t i = 0; i < num_out_semaphores; i++) {
> +      ANV_FROM_HANDLE(anv_semaphore, semaphore, out_semaphores[i]);
> +      assert(semaphore->temporary.type == ANV_SEMAPHORE_TYPE_NONE);
> +      struct anv_semaphore_impl *impl = &semaphore->permanent;
> +
> +      switch (impl->type) {
> +      case ANV_SEMAPHORE_TYPE_BO:
> +         anv_execbuf_add_bo(&execbuf, &impl->bo, NULL, EXEC_OBJECT_WRITE,
> +                            &device->alloc);
> +         break;
> +      default:
> +         break;
> +      }
> +   }

Seperate in/out arrays curtains the issues I could see with the implicit
fences accidentally serialising input-only semaphores.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the mesa-dev mailing list