Commit 9dd96d0
committed
Port Video Super Resolution (MetalFX) from upstream PR moonlight-stream#704
Adds an optional MetalFX spatial upscaler to the tvOS video pipeline,
ported from upstream PR moonlight-stream#704 with tvOS-specific fixes and hardening.
Off by default; when enabled it decodes on a dedicated queue, converts
YUV->RGB via Core Image, and MetalFX-upscales the stream to the display
size before enqueuing to the display layer. Only engages when the display
is larger than the stream (e.g. 1080p -> 4K); at native 4K it is bypassed.
tvOS integration the PR omitted / got wrong:
- Add the "Video Super Resolution (MetalFX)" toggle to Moonlight TV
Settings.bundle (key videoSuperResolution, default off). Without this the
feature was permanently off on Apple TV as shipped.
- Skip the PR's iOS-only SettingsViewController + storyboard changes.
Hardening over the raw PR:
- +[VideoSuperResolution isDeviceSupported] gates the feature on actual
MetalFX MTLFXSpatialScaler support so unsupported GPUs fall back to the
normal pipeline instead of dropping every frame (black screen).
- Disable VSR for the session when the display is not larger than the
stream, or when scaler configuration fails, instead of running a pointless
second decode/convert or dropping frames.
- Runtime per-frame fallback: after repeated failures, revert to direct
enqueue and request a fresh IDR (avoids mixing decoded-RGB and mid-GOP
compressed samples on one layer).
- Wait for GPU completion before handing the upscaled buffer to the display
layer (runs on the VSR queue, not main, so no input-latency cost) to fix a
tearing / pixel-buffer-pool recycle race.
- Make the HDR reconfigure path serialize on the VSR queue without a
queue->main->queue deadlock against stop().
MetalFX auto weak-links (introduced tvOS 16 > deployment target), so no
extra linker flags are needed. Private-API-free; fork/self-signed only is
not a concern here (this is standard framework usage).
Claude-Session: https://claude.ai/code/session_01QiVtyqxowFKZc8gKnNjevy1 parent a1c78dd commit 9dd96d0
8 files changed
Lines changed: 1143 additions & 11 deletions
File tree
- Limelight
- Database
- Stream
- Moonlight TV/Settings.bundle
- Moonlight.xcodeproj
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| 84 | + | |
83 | 85 | | |
84 | 86 | | |
85 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| 152 | + | |
152 | 153 | | |
153 | 154 | | |
154 | 155 | | |
| |||
179 | 180 | | |
180 | 181 | | |
181 | 182 | | |
182 | | - | |
| 183 | + | |
| 184 | + | |
183 | 185 | | |
184 | 186 | | |
185 | 187 | | |
186 | 188 | | |
| 189 | + | |
187 | 190 | | |
188 | 191 | | |
189 | 192 | | |
| |||
0 commit comments