[Mesa-dev] [PATCH 7/9] anv: Implement VK_KHX_external_semaphore_fd
Jason Ekstrand
jason at jlekstrand.net
Tue Feb 28 17:25:55 UTC 2017
On Tue, Feb 28, 2017 at 9:14 AM, Chris Wilson <chris at chris-wilson.co.uk>
wrote:
> 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.)
>
Yes. The way Vulkan defines the wait/signaling semantics, you can't use
the same semaphore twice in a command buffer submission
> Or does execbuf_add_bo do a repeated use check?
>
Yes it does. Well, mostly. There appear to still be a few issues there
thanks to no longer having a direct GEM BO -> anv_bo mapping which need to
be sorted out.
> > + 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170228/d1a03854/attachment.html>
More information about the mesa-dev
mailing list