common: align each display's atlas offset for direct scanout
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Failing after 22s
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Failing after 21s
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Failing after 21s
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Failing after 21s
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Failing after 21s
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Failing after 21s
build / module (push) Failing after 18s
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Failing after 21s
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Failing after 21s
build / host-linux (push) Failing after 21s
build / host-windows-cross (push) Failing after 19s
build / obs (clang) (push) Failing after 20s
build / docs (push) Failing after 3s
build / obs (gcc) (push) Failing after 19s
build / host-windows-native (push) Canceled after 0s
build / idd (push) Canceled after 0s
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Failing after 22s
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Failing after 21s
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Failing after 21s
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Failing after 21s
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Failing after 21s
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Failing after 21s
build / module (push) Failing after 18s
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Failing after 21s
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Failing after 21s
build / host-linux (push) Failing after 21s
build / host-windows-cross (push) Failing after 19s
build / obs (clang) (push) Failing after 20s
build / docs (push) Failing after 3s
build / obs (gcc) (push) Failing after 19s
build / host-windows-native (push) Canceled after 0s
build / idd (push) Canceled after 0s
The alignment argument only rounded up the atlas width, so a display's X offset was an arbitrary running sum of the widths before it. A consumer pointing display hardware at one display's region needs that region's base address 256 byte aligned, and with unaligned offsets some displays would land on legal addresses and some would not — giving the fast path to only some monitors, which is worse than uniform slowness because the difference is hard to diagnose. Each display's X offset is now aligned as well, and the candidate shelf widths account for the padding so they still describe shelves that can hold the set. Both capture backends pass an alignment derived from their pixel size. Costs nothing for common resolutions: 3840, 2560 and 1920 are all multiples of 64. Only unusual widths pad at all — a 2160 wide portrait display grows the atlas by 16 pixels. Also documents the consumer contract: the alignment guarantee, frame lifetime under the two deep queue and one second subscriber timeout, and that damage is in packed frame coordinates.
This commit is contained in:
1 parent
fc0c2cfc37
commit
5e2fd18b5c
6 files changed
+149
-7
No files matched your search
@@ -152,6 +152,78 @@ Be aware that when showing one display of several, the guest's cursor can
|
||||
move onto a display you are not watching, and will appear to vanish. Show
|
||||
the whole desktop, or run a client per display, if that is a problem.
|
||||
|
||||
.. _multimonitor_consuming:
|
||||
|
||||
Consuming frames directly
|
||||
-------------------------
|
||||
|
||||
The packed frame is designed so a consumer other than the Looking Glass
|
||||
client — a custom compositor, for instance — can use each display's region
|
||||
without copying it out first. This section is the contract such a consumer
|
||||
can rely on.
|
||||
|
||||
Layout
|
||||
^^^^^^
|
||||
|
||||
``KVMFRFrame::displays`` holds ``displayCount`` entries. Each gives the
|
||||
display's rectangle in the packed frame (``atlasX/Y/Width/Height``) and where
|
||||
it belongs on the guest's virtual desktop (``desktopX/Y/Width/Height``). The
|
||||
two rectangles are always the same size: packing relocates a display, it never
|
||||
scales it. Rotation is already applied to the pixels and is informational.
|
||||
|
||||
A display's base address within the frame is::
|
||||
|
||||
atlasY * pitch + atlasX * bytesPerPixel
|
||||
|
||||
.. _multimonitor_alignment:
|
||||
|
||||
Alignment guarantee
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Both ``atlasX`` and the frame's width are aligned so that every display's base
|
||||
address is a multiple of 256 bytes, which is what display controllers
|
||||
typically require of a scanout buffer. A consumer can therefore create one
|
||||
framebuffer per display, all pointing into the same underlying memory at
|
||||
different offsets, and page-flip them independently.
|
||||
|
||||
This holds for the 32 and 64 bit-per-pixel formats. It cannot be relied on for
|
||||
``FRAME_TYPE_RGB_24``, which most display hardware cannot scan out regardless.
|
||||
|
||||
Frame lifetime
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
A consumer that scans out directly holds a frame for at least a full vblank,
|
||||
rather than copying it and releasing immediately. That is safe, but the limits
|
||||
are worth knowing:
|
||||
|
||||
* The frame queue is **two** buffers deep. Pinning one leaves the host a
|
||||
single spare, so the host blocks waiting for room rather than overwriting a
|
||||
frame still in use. It will not recycle a buffer out from under a consumer
|
||||
that is keeping up.
|
||||
* The subscriber timeout is **one second**. A consumer that holds a frame
|
||||
longer than that is considered dead and its subscription is dropped. A
|
||||
vblank is far inside that, but a consumer stalled across a mode set should
|
||||
expect to reconnect rather than assume its frame is still valid.
|
||||
|
||||
The practical consequence is that the host cannot run ahead of a pinning
|
||||
consumer. For direct scanout that is the desired behaviour: it is what stops
|
||||
stale frames queueing up.
|
||||
|
||||
Damage
|
||||
^^^^^^
|
||||
|
||||
Damage rectangles are always in packed frame coordinates, so they can be
|
||||
intersected against each display's atlas rectangle to find which displays
|
||||
changed, and a display with no intersecting damage can skip its flip
|
||||
entirely. A ``damageRectsCount`` of zero means the whole frame changed.
|
||||
|
||||
Format changes
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
Any change to the display arrangement bumps ``formatVer``. A consumer must
|
||||
re-read the layout when it changes rather than caching it for the life of the
|
||||
session, since both the atlas dimensions and each display's position can move.
|
||||
|
||||
.. _multimonitor_limitations:
|
||||
|
||||
Limitations
|
||||
|
||||
Reference in new issue
Block a user