wsi/x11: Rewrite implementation to always use threads.

The current implementation has many different code paths which get very
messy to reason about and maintain.

- FIFO mode worked well enough.
- IMMEDIATE did not need a thread at all, but present wait
  implementation complicated a lot of things since we had to handle
  concurrent special event reads.
- MAILBOX (and Xwayland) adds even more jank on top of this where
  have present thread, but no acquire thread, so there are tons of
  forward progress issues to consider.

In the new model, we have two threads:

- Queue thread is only responsible for receiving presents, waiting for
  them if necessary, and submitting them to X.
- Event thread pumps the special event queue and notifies
  other threads about frame completions.
- Application thread does not interact with X directly, only through
  acquire/present queues and present wait condvar.

Two threads are required to implement IMMEDIATE and MAILBOX well.
IDLE events can come back at any time and the queue thread might be
waiting for a new presentation request to come through.

This new model has the advantage that we will be able to implement
VK_EXT_swapchain_maintenance1 in a more reasonable way, since we can
just toggle the present mode per present request as all presentation
go through the same system.

Some cleanups were done as well:

- We no longer need the busy bool. Since everything goes through thread,
  we just rely on acquire/present queues.
- SW/non-MITSHM path is also moved to thread. Move acquire-specific
  logic to the thread as well.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Acked-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26954>
This commit is contained in:
Hans-Kristian Arntzen 2024-01-09 15:33:54 +01:00 committed by Marge Bot
parent 0a3784ae33
commit 19dba854be

File diff suppressed because it is too large Load diff