Skip to content

feat: HDR / EDR has an Auto choice: on where the window's screen can show HDR, off elsewhere - #2222

Open
1395490241lhj-code wants to merge 1 commit into
ly05010419:mainfrom
1395490241lhj-code:feat/hdr-edr-auto
Open

1395490241lhj-code wants to merge 1 commit into
ly05010419:mainfrom
1395490241lhj-code:feat/hdr-edr-auto

Conversation

@1395490241lhj-code

Copy link
Copy Markdown
Contributor

What

The HDR / EDR row (PR #1129; Tears of the Kingdom 1.4.3 on the Mac) becomes Off / Auto / On.

Auto is the same switch, on while the window's screen can show more than SDR white
(NSScreen.maximumPotentialExtendedDynamicRangeColorComponentValue > 1) and off everywhere else. It follows the window
when it changes screen, and a screen whose HDR is turned on or off in System Settings.

Why

On stays on wherever the window is. On an SDR monitor it still presents through the float surface, re-grades the
picture, costs GPU time and keeps frame interpolation off. A MacBook with an XDR screen and an SDR monitor needs the
switch flipped every time the window changes screen. With Auto, the SDR monitor gets exactly the Off path.

What does not change

  • The default is still off. Off and On behave as before on every screen.
  • TOTK_HDR=1 is on and wins over hdr.txt; any other value is off, as before. New: TOTK_HDR=auto, and auto in hdr.txt.
  • Builds without HDR (1.0.0 / 1.2.1, Breath of the Wild, the Switch 2 games) have no row and stay off.
  • Frame interpolation: On turns it off and picking it while HDR is on turns HDR off, as before. Auto keeps the
    interpolation choice, which runs wherever Auto leaves HDR off.
  • The row's order is Off / Auto / On so that a controller stepping from Off reaches Auto without passing On (which
    would turn interpolation off on the way).

How

  • games/totk/runtime/hdr_auto.h (plain C): the three words, TOTK_HDR's precedence, what a choice means on a screen.
  • frontend.m: hdrChoice beside hdrEnabled. front_hdr_update (the start, window screen / backing changes, the
    existing 0.5 s timer, the row) sets hdrEnabled from the choice on the window's screen; everything that reads the
    switch (the renderer's per-frame latch, mfx_latch) is untouched.
  • settings_panel.h: the row.

Tests

  • tests/test_hdr_auto.c (in C_TESTS, make check-c): words and precedence.
  • The settings probe has an hdr mode (no window; the screen's value comes from the probe), run by
    tests/test_hdr_auto.py for 1.2.1, 1.4.3 and Breath of the Wild 1.9.0: the start from TOTK_HDR / hdr.txt, a window
    moving between an SDR and an HDR screen with frame interpolation requested, the saved word, the row.
  • python -m unittest discover -s tests: 1694 tests, 4 failures, the same 4 on 49ff9ec without this change
    (test_texture_copy_gpu, test_shader_startup_memory, test_smaa,
    test_updates...test_running_app_is_preserved_until_its_process_exits). make check-c passes.

Tested on a Mac

MacBook Pro (M5 Pro, macOS 27.3) with its XDR screen (potential EDR 16) and an LG monitor with HDR off in macOS
(potential EDR 1). Tears of the Kingdom 1.4.3, scripted sessions (no hand play): start, title, load a save at the Temple
of Time, 30 s standing there, 2560x1440 + MetalFX. Runtime-only update of an existing app (update_runtime.py).
"GPU" is the median GPU time of a frame over the last 25 s.

build choice screen HDR surface GPU ms (3 runs)
this PR Off LG (SDR) off 8.07 / 8.14 / 8.40
this PR Auto LG (SDR) off 8.06 / 8.51 / 8.42
this PR On LG (SDR) on 10.66 / 10.65 / 10.67
49ff9ec Off LG (SDR) off 8.06 (1 run)
49ff9ec On LG (SDR) on 10.06 (1 run)
  • Auto on the XDR screen: [hdr] auto: Built-in Retina Display, potential EDR 16.00: HDR on, the surface goes on.
  • Auto on the LG with TOTK_MFX=interp60: the interpolator runs (every game frame interpolated in the world). The
    same on the XDR screen: frame interpolation 60+60 -> off, as with On.
  • Auto while the window is moved LG -> XDR -> LG -> XDR in the world: HDR on, off, on; the surface follows each time;
    no failure line.

The runs that name a screen used a test-only window placement aid in frontend.m (not in this PR); the PR build
itself was also run with Off, On and Auto.

Not done

  • Nobody has looked at the Auto transitions by eye on the XDR screen yet (logs and window screenshots only).
  • A minimized window and a display unplugged while playing were not tried.
  • Other game versions: frontend.m passes a syntax check with each of the seven game binaries' flags; only the 1.4.3
    app was built and run. iOS does not compile the touched files (frontend.m is excluded in ios/project.yml).

🤖 Generated with Claude Code

…show HDR, off elsewhere

The HDR / EDR switch (PR ly05010419#1129; Tears of the Kingdom 1.4.3 on the Mac) stays on wherever the window is. On an SDR
monitor that still presents through the float surface, re-grades the picture, costs GPU time (here 8.1 -> 10.7 ms a
frame at the Temple of Time, 2560x1440 + MetalFX) and keeps frame interpolation off. A MacBook with an XDR screen and
an SDR monitor therefore needs the switch flipped every time the window changes screen.

The row is now Off / Auto / On. Auto is the same switch, on while the window's screen can show more than SDR white
(NSScreen maximumPotentialExtendedDynamicRangeColorComponentValue above 1) and off elsewhere: on the SDR monitor the
picture, the cost and frame interpolation are those of Off. It follows the window when it changes screen and a screen
whose HDR is turned on or off, through the path the row already uses (front_hdr_update, the renderer's per-frame latch).

- games/totk/runtime/hdr_auto.h: the words, TOTK_HDR's precedence and what a choice means on a screen (plain C).
- hdr.txt holds off / on / auto. TOTK_HDR=auto is auto; TOTK_HDR=1 is on and any other value off, as before.
- The default is still off; Off and On are unchanged on every screen. Builds without HDR are unchanged.
- The row's order is Off / Auto / On, so a controller stepping from Off reaches Auto without passing On, which turns
  frame interpolation off. Auto keeps the interpolation choice; picking interpolation while HDR is on turns HDR off,
  as before.

Tests: tests/test_hdr_auto.c (make check-c) for the words and precedence; the settings probe's new `hdr` mode
(tests/test_hdr_auto.py; no window, the screen's value comes from the probe) for the start, a window moving between an
SDR and an HDR screen with frame interpolation, the saved word and the row, built as 1.2.1, 1.4.3 and Breath of the
Wild 1.9.0.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.

1 participant