With a multi-display guest the presented image is the composed view, which
may be a single display's crop, but the cursor scale and position still
divided by the guest's whole virtual desktop. On a two monitor guest this
drew the cursor at half size in X and half way to its true position:
visibly stretched and offset from where clicks landed. Input mapping
already used the view; drawing now does too.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WxYTZ8oBdHX3YrHGgdLKwC
Two faults found on the first run against a real DXGI multi-monitor host,
each of which left the composed view black while every geometry check
passed:
- Compose setup ran on the frame thread via onFrameFormat, but the VAO and
FBO it creates are container objects that only exist in the creating
context. The render thread drew with empty ones. Setup is now deferred to
the render thread and picked up before the next draw
(composeSetupPending), and a post-process pass is forced afterwards so a
frame that arrived before setup completed is not presented stale.
- A DMA-imported atlas is an external image and must be sampled with
samplerExternalOES. Compose only compiled the plain sampler2D variant, so
the DMA path sampled black. Both variants are now compiled and setup
selects one, mirroring what the desktop shaders already do.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WxYTZ8oBdHX3YrHGgdLKwC
Two items found reviewing the alignment work, kept out of the Sphinx
docs because they are development handover rather than user facing.
LG_DISPLAY_ALIGN_PIXELS divides by bpp, which only yields a 256 byte
boundary when bpp is a power of two. No call site can reach a 3 byte
format today, but the RGB24 paths mean one plumbing change would make
it silently produce misaligned offsets.
The two-deep frame queue is documented as deliberate, and the reasoning
holds, but a consumer that pins a buffer until its next flip completes
leaves the host blocked until vblank, serialising capture against
scanout. Whether the extra buffer is worth the discarded captures it
allows is a measurement to take once DXGI multi-monitor capture runs on
real hardware, so the note records the tradeoff and its shm sizing and
KVMFR_VERSION consequences rather than changing anything.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tybacp8BEQgQeNBtwt2hrC
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.
host/build-win was swept in by git add -A: .gitignore covered */build but
not the build-win directory used for the Windows cross compile. Removes
275 tracked files (6.3MB of objects, generated makefiles and CMake caches)
and widens the ignore rules so no build directory is tracked again.
Records what is proven versus unproven, how to rebuild and test from
nothing, the DXGI bring-up procedure, the design decisions that should not
be undone, and the gotchas that cost time to find the first time.
Nested and virtual X servers accept xrandr --setmonitor but ignore it, so
there is no way to describe a multi-monitor desktop to Xvfb or Xephyr.
xcb:monitors lets a layout be given directly, which makes any X server
usable as a multi-monitor capture source.
demo-multimon.sh uses it to run the whole pipeline locally: a virtual
desktop with real applications on three monitors, captured by the host,
packed, and composed back by the real client, with the result captured to
a PNG.
Damage is now gathered from every output that presented this cycle rather
than reporting the whole frame. An output that did not present contributes
nothing, so a static monitor costs no transfer at all — which matters when
the atlas is tens of megabytes and only one display is moving.
The translation clips each rectangle to the display it came from, so one
output's damage can never reach into another's part of the atlas, and
scaling is applied after placement since the downscale applies to the frame
as a whole. If the combined damage cannot be described the count is left at
zero, meaning full damage: redrawing too much only costs time, whereas
redrawing too little leaves stale pixels on screen.
lgDisplaysRectToAtlas is in common and unit tested, including a sweep of
awkward inputs asserting no translated rectangle ever escapes its display.
The DXGI plumbing around it still needs hardware.
Marks the DXGI path as implemented but unproven on hardware, documents
the fallback conditions, and notes that packing every display into one
frame means they share a frame rate.
Duplicates every attached output on the chosen adapter and composes them
into an atlas texture with CopySubresourceRegion, handing that to the post
processors in place of the acquired texture. Nothing downstream is aware
of the difference.
Secondary outputs are polled with a zero timeout rather than waited on,
since outputs present independently and waiting in turn would drag the
frame rate down to that of the slowest monitor. A display with nothing new
keeps the pixels it already has in the atlas. Acquired frames are released
at the start of the next capture, not after the copy, because the copies
are only recorded into the device context and releasing a frame
invalidates its surface.
Falls back to capturing a single output, which is what this backend has
always done, whenever the situation cannot be handled safely: mixed
capture formats, since a subresource copy cannot convert between them, a
rotated output, since the packer expects final orientation, or a specific
output having been requested. A wrong atlas is worse than one display.
Damage is reported as full frame while composing. The dirty rectangles
come from the primary alone and in its own coordinates, so they say
nothing about the other displays, and a wrong damage rectangle leaves
stale pixels on screen.
Cross compiles clean. Untested on hardware: the acquire, release and
timing behaviour needs a real multi-monitor Windows machine.
Only trying running totals in packing order missed layouts where the
displays sharing a shelf are not the first few. A 4K above two 1440p side
by side is the common case: the 4K sorts first by height but belongs on a
shelf of its own, so the useful width is the sum of the other two.
For that arrangement the atlas drops from 3840x5040 to 5120x3600, about
5% fewer pixels per frame. With at most 8 displays this is 255 subsets,
so the extra search costs nothing.
Records the exact packages needed to build the client, the Linux host,
the test suite and the Windows cross compiler, so a fresh machine can
bootstrap without rediscovering them.
The composition pass flipped Y when writing into its framebuffer, but the
desktop shader that samples it treats row 0 as the top, so the composed
desktop reached the screen inverted. The layout metadata was correct
throughout, which is why the geometry checks never caught it.
Adds a rendering test that catches this class of bug: a synthetic host
publishes three displays stacked vertically in the atlas but laid out in a
row on the desktop, and the client is rendered into a virtual X server and
sampled. Each display carries a marker in its top left corner, so an
inverted or transposed composition fails even though the colours would
otherwise land in the right places.
Records the non-obvious build invocations (sanitizers, stub platform
symbols, linking the verifier against the host's built libraries) so the
suite can be run with one command.
The frame format, packer and client compositor are backend agnostic and
already work; this backend still reports a single display. Records the
shape of the change and the hazards found reading it: mixed formats,
per-output HDR and rotation, frame timing, release discipline and COM
lifetime.
Covers how the packed frame works, the shared memory sizing that the
feature depends on, display selection, running one client per guest
display, and the current limitations.
Moves the per-display copy out of the XCB backend into common so it can
be unit tested directly and reused by other backends. The test uses a
unique value per source pixel, so a copy landing at the wrong offset
cannot pass by coincidence, and checks truncation against guard bytes.
Also adds a scripted end-to-end test and teaches the verification tool
to report a blank capture source as a skip rather than a failure.
captureStop never called the capture interface's stop(), so a backend
running its own threads was torn down while those threads were still
using it. The XCB pointer thread also ran before the host had allocated
the pointer buffers.
The verification tool subscribes as a real client and checks the
published multi-display frame for consistency.
Capture every guest display into a single frame and compose it back into
the guest's desktop on the client, so one Looking Glass session can carry
a multi-monitor guest instead of one instance per display.
KVMFR gains a per-frame display layout (version 24). A frame with
displayCount == 0 is a conventional single-display frame and behaves
exactly as before, so existing capture backends are unaffected.
- common: shared display layout and a shelf packer that minimises atlas
area, plus atlas/desktop coordinate mapping helpers and unit tests
- host: capture interface and host app carry the layout; a layout change
invalidates the format so clients re-read it
- host/XCB: enumerate RandR monitors and repack the root window into the
atlas directly in shared memory
- client/EGL: compose the atlas into the presented view as its own pass,
leaving post processing, HDR, cursor and damage handling unchanged
Also fixes the XCB backend writing a single row per frame instead of the
whole image.