<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Aug 4, 2017 at 1:43 AM, Chris Wilson <span dir="ltr"><<a href="mailto:chris@chris-wilson.co.uk" target="_blank">chris@chris-wilson.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Quoting Jason Ekstrand (2017-08-04 02:25:21)<br>
<span class="gmail-">> Vulkan allows you to do a submit whose only job is to wait on and<br>
> trigger semaphores.  The easiest way for us to support that right<br>
> now is to insert a dummy execbuf.<br>
> ---<br>
</span><span class="gmail-">> diff --git a/src/intel/vulkan/anv_device.<wbr>c b/src/intel/vulkan/anv_device.<wbr>c<br>
> index 793e519..0f0aa22 100644<br>
> --- a/src/intel/vulkan/anv_device.<wbr>c<br>
> +++ b/src/intel/vulkan/anv_device.<wbr>c<br>
> @@ -1014,6 +1014,28 @@ anv_device_init_border_colors(<wbr>struct anv_device *device)<br>
>                                                      border_colors);<br>
>  }<br>
><br>
> +static void<br>
> +anv_device_init_trivial_<wbr>batch(struct anv_device *device)<br>
> +{<br>
> +   anv_bo_init_new(&device-><wbr>trivial_batch_bo, device, 4096);<br>
<br>
</span>Is this created with ASYNC?</blockquote><div><br>No, it isn't but I'm happy to set the flag.  This patch predates the ASYNC stuff, I believe. <br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> Just thinking that you only want the<br>
external ordering constraints on this bo, and not accidentally serialize<br>
between contexts.<span class="gmail-"><br></span></blockquote><div><br></div><div>Is this really an issue?  No other process will ever see this BO.  I suppose the kernel is still doing unneeded flushing but this shouldn't cause cross-context synchronization.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">
> +   void *map = anv_gem_mmap(device, device->trivial_batch_bo.gem_<wbr>handle,<br>
> +                            0, 4096, 0);<br>
> +<br>
> +   struct anv_batch batch = {<br>
> +      .start = map,<br>
> +      .next = map,<br>
> +      .end = map + 4096,<br>
> +   };<br>
> +<br>
> +   anv_batch_emit(&batch, GEN7_MI_BATCH_BUFFER_END, bbe);<br>
> +   anv_batch_emit(&batch, GEN7_MI_NOOP, noop);<br>
> +<br>
> +   if (!device->info.has_llc)<br>
> +      gen_clflush_range(map, batch.next - map);<br>
> +<br>
> +   anv_gem_munmap(map, device->trivial_batch_bo.size)<wbr>;<br>
> +}<br>
<br>
</span><span class="gmail-">> diff --git a/src/intel/vulkan/anv_<wbr>private.h b/src/intel/vulkan/anv_<wbr>private.h<br>
> index b599db3..bc67bb6 100644<br>
> --- a/src/intel/vulkan/anv_<wbr>private.h<br>
> +++ b/src/intel/vulkan/anv_<wbr>private.h<br>
> @@ -745,6 +745,7 @@ struct anv_device {<br>
>      struct anv_state_pool                       surface_state_pool;<br>
><br>
>      struct anv_bo                               workaround_bo;<br>
> +    struct anv_bo                               trivial_batch_bo;<br>
<br>
</span>Do you use all 4096 bytes of the workaround_bo, or could you spare 64?<br>
;)<span class="gmail-"><br></span></blockquote><div><br></div><div>I could... Then again, I can also easily spare a single 4K page per context and prevent myself from accidentally overwriting my little batch. :-)<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">
> diff --git a/src/intel/vulkan/anv_queue.c b/src/intel/vulkan/anv_queue.c<br>
> index 446c3de..9934fef 100644<br>
> --- a/src/intel/vulkan/anv_queue.c<br>
> +++ b/src/intel/vulkan/anv_queue.c<br>
> @@ -159,6 +159,23 @@ VkResult anv_QueueSubmit(<br>
>     pthread_mutex_lock(&device-><wbr>mutex);<br>
><br>
>     for (uint32_t i = 0; i < submitCount; i++) {<br>
> +      if (pSubmits[i].<wbr>commandBufferCount == 0) {<br>
> +         /* If we don't have any command buffers, we need to submit a dummy<br>
> +          * batch to give GEM something to wait on.  We could, potentially,<br>
> +          * come up with something more efficient but this shouldn't be a<br>
> +          * common case.<br>
> +          */<br>
> +         result = anv_cmd_buffer_execbuf(device, NULL,<br>
> +                                         pSubmits[i].pWaitSemaphores,<br>
> +                                         pSubmits[i].<wbr>waitSemaphoreCount,<br>
> +                                         pSubmits[i].pSignalSemaphores,<br>
> +                                         pSubmits[i].<wbr>signalSemaphoreCount);<br>
<br>
</span>Might as well just pass &pSubmits[i] along?<span class="gmail-HOEnZb"><font color="#888888"><br>
</font></span></blockquote></div><br></div><div class="gmail_extra">I can't.  See below where we only pass the wait semaphores to the first execbuf in the batch and only pass the signal semaphores to the last.<br><br></div><div class="gmail_extra">--Jason<br></div></div>