On 2020-03-16 4:50 a.m., Marek Olšák wrote:
The synchronization works because the Mesa driver waits for idle (drains the GFX pipeline) at the end of command buffers and there is only 1 graphics queue, so everything is ordered.
The GFX pipeline runs asynchronously to the command buffer, meaning the command buffer only starts draws and doesn't wait for completion. If the Mesa driver didn't wait at the end of the command buffer, the command buffer would finish and a different process could start execution of its own command buffer while shaders of the previous process are still running.
If the Mesa driver submits a command buffer internally (because it's full), it doesn't wait, so the GFX pipeline doesn't notice that a command buffer ended and a new one started.
The waiting at the end of command buffers happens only when the flush is external (Swap buffers, glFlush).
It's a performance problem, because the GFX queue is blocked until the GFX pipeline is drained at the end of every frame at least.
So explicit fences for SwapBuffers would help.
Not sure what difference it would make, since the same thing needs to be done for explicit fences as well, doesn't it?