Skip to content

True HiDPI past the scaled-backing cap via a mirrored virtual display - #68

Draft
didriksg wants to merge 5 commits into
mainfrom
hidpi-ultrawide-mirroring
Draft

True HiDPI past the scaled-backing cap via a mirrored virtual display#68
didriksg wants to merge 5 commits into
mainfrom
hidpi-ultrawide-mirroring

Conversation

@didriksg

Copy link
Copy Markdown
Owner

Fixes #65, and delivers the HiDPI half asked for in #66.

On 5K2K ultrawides WindowServer refuses scaled backings wider than about 6720px, so the smooth-scaling ladder tops out around "looks like 3360x945" and the sizes between that and native only exist as plain 1x modes. This gets them as real HiDPI: slider stops past the ladder top now create a hidden virtual display that carries the 2x backing (rendered, not scanned out, so the cap doesn't apply), set it to the wanted looks-like size, and hardware-mirror the panel onto it. The scanout engine does the downscale.

How it holds together:

  • MirroredModeService owns the lifecycle, lazily: the virtual display only exists while a beyond-cap size is active. Leaving one unmirrors first, then destroys.
  • The slider grows synthetic stops on the same 16px grid, with negative mode ids so they can never reach the CG apply path. Every mode switch goes through the one serialized path, so picking a real resolution while mirrored tears the mirror down correctly.
  • Teardown covers quit, unplug, the virtual dying underneath us, and a stranded mirror left by a crashed session (a serial marker on the virtual display identifies those). Wake's saved-mode reapply skips mirrored panels so it can't fight the mirror.

Verified so far, on a 2560x1440 AOC with scripts/mirror-hidpi-probe.swift: virtual display creation, the looks-like HiDPI mode enumerating and applying, hardware mirroring (hwMirrorSet true), 165Hz surviving the whole chain, clean restore. The probe encodes the three findings the implementation rests on: backing-only mode declarations (applySettings rejects the whole set somewhere above ~360 objects), create-before-query ordering in a CLI (CG's display cache never refreshes there), and unmirror before destroy.

Not verified yet, and why this stays a draft: whether a virtual framebuffer actually escapes the cap. I don't have an ultrawide until Thursday; the probe answers that in two minutes there (swift scripts/mirror-hidpi-probe.swift 3840x1080), then a live pass with the app. Extra Brightness while mirrored also needs a look on real hardware.

Not in tonight's release; this ships in the next one once the Thursday run confirms it.

Three findings baked in: alloc/init ownership must stay Unmanaged (claiming
both over-releases), the looks-like HiDPI mode only materializes when both
the 2x backing and the half-size pixel mode are declared, and a bare CLI's
CG display-info cache never refreshes (create first, query after). Verified
end to end on a 2560x1440 external: hardware mirror set, 165Hz preserved.
…lay (#65)

Lazy lifecycle: first apply creates a hidden virtual display (stable
per-monitor identity, MIRR serial marker, backing-only mode ladder for
every beyond-cap stop), drives it to the looks-like HiDPI mode and
hardware-mirrors the physical panel onto it; later applies just switch
the virtual's mode. restore() unmirrors first, then destroys. Quit
teardown unmirrors synchronously before the virtual displays die.
Synthetic stops (negative ids, same 16px grid) fill the gap between the
enumerable HiDPI ladder top and native on capped panels. switchTo routes
them to MirroredModeService and unmirrors before applying any real mode,
so every entry point (slider, resolution row, refresh row) handles the
mirror lifecycle through the one serialized path. Readback needs no new
code: while mirrored the physical reports the virtual's looks-like mode,
which matches the synthetic stop by size.
Unplugging a mirrored panel or losing the virtual master drops the
bookkeeping (and orphan virtual) via refreshDisplays; a stray mirror
virtual from a crashed session gets its panel unmirrored on every
refresh (MIRR serial marker identifies it); wake's saved-mode reapply
skips mirrored displays so it cannot fight the mirror; and a re-apply
re-arms a mirror that a wake or WindowServer reset silently dropped.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

True HiDPI smooth scaling on ultrawide monitors (virtual display + mirroring)

1 participant