Repository navigation
Conversation
lypiut
force-pushed
the
feature/oot-native-hdr
branch
from
November 22, 2026 07:56
d89e8ee to
c3dcc2e
Compare
Ocarina of Time (Switch 2) renders HDR itself but nxnative always answered SDR, so its HDR picture never appeared. Answer vi::QueryDisplayHdrStatus from the game's window screen and present the game's RGB10A2 / BT.2100 PQ window unchanged in a PQ CAMetalLayer. Potential EDR headroom > 1.0 enables HDR; current headroom sets the reported peak (paper white x headroom, 10-nit steps with a one-second hold, capped at 1600) and a headroom shoulder compresses only highlights the game declares above what the screen can show. The PQ layer is kept until two non-PQ presents plus one main-thread reevaluation; transition frames convert via BT.709 with hue-preserving compression. CAEDRMetadata stays off: an isolated linear-EDR experiment found no visible benefit, higher host GPU cost, doubled drawable storage, unmeasured compositor cost and no mastering-metadata source. The existing Upscaling row (DM_PRESENT_UPSCALE=off|metalfx) is now the single player choice for SDR and HDR: Standard keeps bilinear and PQ bilinear; MetalFX keeps the perceptual SDR and linear-light HDR MetalFX scalers with separate resources. DM_HDR_UPSCALE is only a logged HDR-only diagnostic override. A failed PQ decode never feeds PQ codes to the HDR scaler, MetalFX is never reported unless decoding ran, and failures fall back to bilinear. Includes review fixes: a bounded capability settle timer, a one-shot HDR-to-SDR exit, a mode-4 shoulder compatible with MetalFX, valid GPU timing samples, and transient recovery and sharpness tests. Validation: t_hdr (251 checks), t_present_crop (322 checks x5), t_hdr_mfx, host tests and docs/settings tests pass; live four-way GPU timings and the CAEDRMetadata and VI calibration findings are recorded in the game note. Four comparison screenshots and upstream references (PRs seedds#1176, seedds#1249, seedds#3009) are preserved. Squashed from 29 commits of PR #1; full research remains on experiment/caedrmetadata.
lypiut
force-pushed
the
feature/oot-native-hdr
branch
from
November 22, 2026 13:29
eb9c26f to
87a553c
Compare
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Native HDR10 with one SDR/HDR upscaling setting
Branch
feature/oot-native-hdr, draft PR. Head87a553c5e22e3ecee6b3e498026fd1d7cdc0ebe3; reviewed from1af842919. No production code changed in the final documentation pass.1. Summary
Ocarina of Time (Switch 2) renders HDR itself, but nxnative previously always answered SDR so the game never drew its HDR picture. This PR answers HDR status from the game's window screen, presents the game's RGB10A2 / BT.2100 PQ window unchanged in a PQ
CAMetalLayer, and makes the existing Upscaling → Standard / MetalFX choice work in both SDR and native HDR10. Standard (bilinear) remains the default; MetalFX is an explicit player choice. No new launcher setting, second renderer, ScreenCaptureKit or productionCAEDRMetadata.2. Architecture
Capability: potential EDR headroom > 1.0 on the window's own
NSScreen(Apple's documented capability test), with a 500 ms hold so moving between screens does not flip the layer. Current headroom drives the game's peak and the shoulder. No display allowlist or model-name check.VI handshake: output format 1, 100-nit paper white, peak = paper white × current headroom in 10-nit steps with a one-second hold, capped at 1600. The game then switches its own window to
format 0x3d(RGB10A2). The PQ layer is kept until two consecutive non-PQ presents; the second one requests exactly one main-thread reevaluation.Present: the normal HDR-into-PQ case is a byte-for-byte passthrough (
fs_hdrmode 0) — no PQ-to-linear round trip and no second tone map. Transition frames (PQ→SDR, SDR→PQ) convert via BT.709 with hue-preserving highlight compression. The shoulder engages only when the game's declared output target exceeds what the screen can currently show.Upscaling: one player setting,
DM_PRESENT_UPSCALE=off|metalfx:A PQ source never enters the SDR perceptual scaler; a failed decode never feeds PQ codes to the HDR scaler. Decode/scaler failures fall back to bilinear.
DM_HDR_UPSCALEis only an HDR-only diagnostic override (unset follows the player,off/hdrfxforce a mode and are logged).Authoritative detail: Native HDR10 presentation. Game-specific evidence: Ocarina of Time note.
3. Design decisions
min(reported peak, 3.5 × paper white)— Ocarina's own policy, not a universal SDK rule — and is an authored output target, not a maximum pixel value or HDR10 mastering metadata. The host shoulder is therefore normally inactive at steady state and protects mainly transitional headroom changes or a fixed peak above current headroom.CAEDRMetadatanot adopted. An isolated experiment compared native PQ, linear EDR without metadata and linear EDR with metadata. The linear path was numerically validated and checked with real RGBA16Float drawables, but no visible image-quality benefit or advantage over native PQ was demonstrated; it added about 0.2 ms of host GPU time at 5K, doubled drawable pixel storage, left compositor cost unmeasured and had no defensible mastering-metadata source. This is an evidence-based decision, not a claim that Apple's API is inherently unsuitable. Full research remains onexperiment/caedrmetadata; the conclusions are in the game note.use = &g_fx_hdrand feed PQ codes tofs_hdr_fx— now any failure selects bilinear and MetalFX is never reported unless decoding ran; (2) the HDR→SDR exit could leave the PQ layer until an unrelated display event — the second SDR present now requests one main-thread reevaluation; (3) the shoulder was skipped in mode 4 exactly when limited headroom needed it — removed, with six headroom pairs covered; (4) GPU timing accepted zero/invalid samples — now rejects timeouts, errors and non-finite durations.mtl_hdr_fx_reset()releases decode texture, scaler and refusal cache together; pipeline caches are keyed by the acquired drawable's format; decode argument tables are per allocator slot. The 0.25 s headroom poll stops when HDR is off.Squashed to a single commit (
87a553c5) on request; the previous 29 commits and the full research remain onexperiment/caedrmetadata. Authored aslypiut <lypiut@gmail.com>. Prior art: PR #1176, PR #1249, PR #3009.4. Validation
make -C dm/host GAME=0400486024DEC000 dmhost— success;dm/host/tests run— pass.check_t_hdr— 251 checks, 0 failed (capability thresholds, independent headroom, exit sequence, concurrent state).check_t_present_crop— 322 checks in each of five runs, 0 failed (four-way Standard/MetalFX × SDR/HDR selection matrix, fault injection and recovery, six roll-off pairs, crop/scale, alpha, timing validity).check_t_hdr_mfx— both RGB10A2→RGB10A2 and RGBA16Float→RGBA16Float HDR descriptors accepted.test_triage_reportandtest_usagefail only in fixtures that callgit commit(globalcommit.gpgsign=trueneeds the 1Password signer on this Mac) — environment, not this change.73f23d41plus onet_counter_clocktiming flake that passed 7/7 isolated reruns; TSan/ASan/UBSan builds oft_hdrclean.regress.py impact upstream/main..HEAD: BOTW, Scarlet, Tears of the Kingdom via NVN present; Hades via a broad rule.check --gamesnot run: harness root, game builds and new-chain shader caches unavailable.Live play (user-driven, 2026-11-22, M4 Pro / Studio Display XDR, commit
176c171b; no automated inputs, no save/asset/cache changes):DM_HDR=0, DM_PRESENT_UPSCALE=off)DM_HDR=0, DM_PRESENT_UPSCALE=metalfx)DM_HDR=auto, DM_PRESENT_UPSCALE=off)DM_HDR=auto, DM_PRESENT_UPSCALE=metalfx)5. Known limitations / remaining work
kokiri-still/field-still, ≥3 runs each) with matched save, render scale, drawable, refresh rate and warm caches is still needed to confirm image quality.6. Screenshots (same Kokiri-village view, 5120×2880)