<div dir="ltr"><div dir="ltr"></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 16, 2020 at 5:57 AM Michel Dänzer <<a href="mailto:michel@daenzer.net" target="_blank">michel@daenzer.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 2020-03-16 4:50 a.m., Marek Olšák wrote:<br>
> The synchronization works because the Mesa driver waits for idle (drains<br>
> the GFX pipeline) at the end of command buffers and there is only 1<br>
> graphics queue, so everything is ordered.<br>
> <br>
> The GFX pipeline runs asynchronously to the command buffer, meaning the<br>
> command buffer only starts draws and doesn't wait for completion. If the<br>
> Mesa driver didn't wait at the end of the command buffer, the command<br>
> buffer would finish and a different process could start execution of its<br>
> own command buffer while shaders of the previous process are still running.<br>
> <br>
> If the Mesa driver submits a command buffer internally (because it's full),<br>
> it doesn't wait, so the GFX pipeline doesn't notice that a command buffer<br>
> ended and a new one started.<br>
> <br>
> The waiting at the end of command buffers happens only when the flush is<br>
> external (Swap buffers, glFlush).<br>
> <br>
> It's a performance problem, because the GFX queue is blocked until the GFX<br>
> pipeline is drained at the end of every frame at least.<br>
> <br>
> So explicit fences for SwapBuffers would help.<br>
<br>
Not sure what difference it would make, since the same thing needs to be<br>
done for explicit fences as well, doesn't it?<br></blockquote><div><br></div><div>No. Explicit fences don't require userspace to wait for idle in the command buffer. Fences are signalled when the last draw is complete and caches are flushed. Before that happens, any command buffer that is not dependent on the fence can start execution. There is never a need for the GPU to be idle if there is enough independent work to do.<br></div><div><br></div><div>Marek<br></div></div></div>