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
build / host-windows-native (push) Canceled after 0s
build / idd (push) Canceled after 0s
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.
build / host-windows-native (push) Canceled after 0s
build / idd (push) Canceled after 0s
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.
Validate mastering primaries and luminance independently so one
unsupported component does not discard the other.
Trust content chromaticities when extended target volumes are supported,
and report the exact values and reason when metadata must be omitted.
Convert HDR scRGB input to normalized linear Rec.2020 before CAS, then
convert the filtered result back to scRGB. Use the content metadata to
select an appropriate normalization peak while leaving SDR unchanged.
This follows AMD's documented recommendation for applying CAS to HDR
content and prevents HDR highlights from being clamped and dimmed.
PQ sources excluded every external filter from the post-process chain.
Decode PQ/BT.2020 into FP16 linear scRGB before active effects and pass
the resulting transfer state to the desktop shader.
Keep the raw PQ path when no effect is active. This avoids adding a
conversion pass or per-frame latency to the common case.
Describe PQ pixels with the protocol-defined primary luminance range and
keep mastering luminance in the target volume. Track extended target-volume
support and omit unsupported metadata instead of creating an invalid image
description.
Keep the reference white associated with the active PQ description until
a replacement is ready. If asynchronous description creation fails, the
renderer now retains the complete previous HDR state instead of combining
new white-level values with stale compositor metadata.
Decode PQ/BT.2020 desktop pixels into an FP16 linear scRGB target before
compositing the color cursor, ImGui, damage overlay, and letterboxing.
Encode the damaged result to PQ once at the surface boundary. Keep logical
AND/XOR cursor masks in the encoded domain.
This preserves premultiplied cursor edges, prevents encoded-domain
blending, uses the Wayland output reference white for local overlays, and
keeps guest cursor white and display calibration independent from frame
SDR white. It also corrects HDR-to-SDR absolute luminance scaling, gamut
matrices, black handling, and buffer-age repair for the extra pass.
Suppress overlays when their conversion framebuffer is unavailable rather
than allowing unconverted sRGB draws into an HDR target.
Use named transfer constants for cursor shader state. Convert clipped
surface rectangles explicitly before using the frame-damage merge helper,
which avoids mixing its unsigned type with the EGL surface rectangle type.
Only advertise native PQ when the FP16 composition target is available.
SDR and native scRGB retain their direct single-pass paths.
Queue the display-server surface format while the renderer lock still
serializes the matching onFrameFormat update. This prevents the render
thread from presenting a frame in a new HDR encoding before the Wayland
image description transition has been queued.
Serialize asynchronous image-description state and publish compositor
capabilities safely across the Wayland and render threads.
Use the predefined Windows-scRGB description, query each output image
description for its configured reference white, and reapply HDR when the
surface moves to an output with different colour settings.
Request true floating-point EGL configs for scRGB and expose the native
encodings supported by the selected surface. Fall back to software HDR
mapping when the surface cannot represent the incoming wire format.
Resample PQ in linear light, keep SDR-only effects out of native PQ
chains, and consume the cursor-specific white level without changing
binary monochrome cursor mask operations.
Keep software HDR mapping enabled until the display server activates the
requested image description. Re-evaluate the state while rendering so
asynchronous readiness or failure updates the desktop, cursor, and overlay
together with a full redraw.
Publish HDR metadata through a locked request snapshot and wait for
image-description readiness before using it. Commit encoding changes with
matching content, preserve the active description during same-format
metadata replacements, and handle creation failures without protocol
errors.
Honor the IddCx 3x4 XYZ matrix and post-transfer LUT in the IDD
conversion pipeline. Carry transform changes to the client so EGL applies
the same calibration to hardware cursors, and invalidate the full frame
whenever calibration changes.
Apply the same sampling margin to swap damage as buffer-age repair and
clip reported rectangles to the EGL surface. This ensures compositors
update every pixel affected by scaling or filtering.
This commit turns the icon handling into using a macro so we don't need to do
weird conversions from unsigned long (needed by X11) to uint32_t (needed by
Wayland).
Also simplified the error handling path on Wayland.
Render ImGui to an intermediate SDR framebuffer and map it into the
native PQ or scRGB output using the Wayland surface reference white.
Preserve premultiplied alpha during conversion and limit composition to
damaged overlay regions.
LGMP session validation may wait 500 ms for the shared-memory heartbeat
to advance. Run it on a worker so Wayland input remains responsive while
preserving stale-data detection.