From e8d885fb4fecb53ef2a427fc8352a5d097266352 Mon Sep 17 00:00:00 2001 From: enricobuehler Date: Tue, 16 Jun 2026 17:18:41 +0000 Subject: [PATCH] =?UTF-8?q?fix(host/windows):=20WGC=20relay=20=E2=80=94=20?= =?UTF-8?q?set=20SudoVDA=20color=20to=20match=20session=20bit=20depth=20at?= =?UTF-8?q?=20build=20(kill=20persisted=20HDR)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Re-test still broken: the WGC helper captured HDR FP16 BT.2020 PQ from the FIRST frame (before any switch), feeding the 8-bit SDR encoder → broken normal-desktop image. Root cause: the SudoVDA's advanced-color (HDR) state PERSISTS on the monitor across sessions, so the 8-bit session inherited HDR left enabled by the earlier broken toggle — and gating the per-switch toggles can't undo a state that's already on at start. Fix: in build() (runs on initial create + every mode-switch/return-from-secure rebuild), force set_advanced_color(target, bit_depth>=10) BEFORE spawning the WGC helper, with a 250ms settle if it changed. An 8-bit session now always captures SDR via WGC (matching the encoder); 10-bit keeps HDR. Co-Authored-By: Claude Opus 4.8 --- crates/punktfunk-host/src/m3.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/punktfunk-host/src/m3.rs b/crates/punktfunk-host/src/m3.rs index c5b65c8..c824481 100644 --- a/crates/punktfunk-host/src/m3.rs +++ b/crates/punktfunk-host/src/m3.rs @@ -2344,6 +2344,20 @@ fn virtual_stream_relay( let target = vout.win_capture.clone().ok_or_else(|| { anyhow!("SudoVDA target not yet an active display (needs a WDDM GPU to activate it)") })?; + // Force the SudoVDA's advanced-color (HDR) state to MATCH the session bit depth BEFORE the WGC + // helper captures it. The advanced-color state PERSISTS on the monitor across sessions, so an + // 8-bit (SDR) session could otherwise inherit HDR left on by a prior 10-bit run (or our own + // earlier toggle) → the helper captures HDR FP16 while the encoder is 8-bit SDR → broken image. + // Runs on every build (initial + mode-switch + return-from-secure rebuild), keeping WGC's format + // consistent with the encoder. (HDR independent-flip on the secure desktop is handled separately + // by dropping to SDR for the DDA leg.) + #[cfg(target_os = "windows")] + unsafe { + if crate::vdisplay::sudovda::set_advanced_color(target.target_id, bit_depth >= 10) { + // Let the colorspace change settle before WGC creates its capture item / detects HDR. + std::thread::sleep(std::time::Duration::from_millis(250)); + } + } let relay = HelperRelay::spawn( &target, (mode.width, mode.height, effective_hz),