Add live RenoDX HDR tonemapper and PQ/scRGB output blit #554

Open
Swaizhd wants to merge 1 commit from Swaizhd/Darner:feat/hdr-renodx into Main
First-time contributor

What it changes

The problem on main: Darner's DARNER_HDR=1 already enables and presents the title's native HDR output, so the limitation is in the title's own HDR pipeline rather than Darner's presentation path. Like many console ACES HDR implementations, the title's baked ACES 3D LUT (CS_BakeACESWithGamutCompressTonemapOnlyLUT_QuasiLogShaper) and secondary blit (PS_BlitHDRACES) use a fixed curve with no user control over tonemapper, peak rolloff, paper white, shadow/highlight grading, or black-floor flare (the same issues players typically address with RenoDX). In addition, DARNER_HDR_PAPER_WHITE is currently read once at startup rather than adjustable live from the F1 menu.

This PR adds an opt-in, live-tunable RenoDX-style HDR tonemapping and display output pipeline (DARNER_RENODX, default off) under F1 -> DISPLAY:

  1. 3D tonemap LUT hook (crates/darner-gpu/src/renodx.rs, draw.rs, pipeline.rs):
    • Intercepts CS_BakeACESWithGamutCompressTonemapOnlyLUT_QuasiLogShaper, backs up the title's original 64x64x64 FP16 AP1 3D LUT so switching back to OFF restores vanilla rendering bit-for-bit without restarting.
    • Bakes a replacement 3D LUT matching the title's Quasi-Log shaper into AP1 nits using MIT-licensed algorithms adapted from clshortfuse/renodx (daniele.hlsl, reno_drt.hlsl, DICE.hlsl, hermite_spline.hlsl, colorgrade.hlsl v4, color/oklab.hlsl):
      • RENODRT: Daniele filmic curve (ACES-matched c_d = 10 on 100 reference white and shadow toe) + OkLab hue preservation + highlight blowout.
      • DICE / HERMITE: filmic toe pre-curve with luminance-preserving exponential / cubic-Hermite rolloff to display peak.
    • Rebakes the 3D LUT live whenever any F1 HDR slider changes (DARNER_RENODX, DARNER_RENODX_PEAK, DARNER_RENODX_PAPER_WHITE, DARNER_RENODX_EXPOSURE, DARNER_RENODX_CONTRAST, DARNER_RENODX_SHADOWS, DARNER_RENODX_HIGHLIGHTS, DARNER_RENODX_SATURATION, DARNER_RENODX_BLOWOUT, DARNER_RENODX_FLARE). PEAK = AUTO reads display max luminance via DXGI (hdr_display_info).
  2. HDR blit replacement (PS_BlitHDRACES):
    • Once the world 3D LUT is active and HDR output is enabled (hdr_active()), replaces the title's secondary curve blit with a clean D60 AP1 -> D65 BT.2020 -> ST.2084 PQ (or scRGB) output pass with 10-bit triangular IGN dithering.
  3. Live UI paper white (host/hdr.rs, host/menu.rs, apps/darner/src/play.rs):
    • Makes DARNER_HDR_PAPER_WHITE (HDR UI WHITE NITS) live-adjustable via atomic storage on the F1 DISPLAY page and persists DARNER_RENODX* and DARNER_HDR_PAPER_WHITE in darner-settings.txt.

How it was tested

  • Tested revision: 7cc7bd3245f26b3afa743f39291074a9a13557b6 (based on origin/main c8258f95569c10fe75b5bfb785d3865b5deeefd9).
  • Commands and results:
    • cargo xtask policy — asset policy: 577 files ok (pass)
    • cargo clippy --workspace --all-targets --locked -- -D warnings — 0 warnings/errors (pass)
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings — 0 warnings/errors (pass)
    • cargo test --locked -p darner-core --lib — 50 passed, 0 failed
    • cargo test --locked -p darner-loader --lib — 98 passed, 0 failed
    • cargo test --locked -p darner --bins — 208 passed, 0 failed, 1 ignored
    • cargo test --locked -p darner-gpu --lib — 1826 passed, 81 ignored (1 pre-existing parallel flake watch::watch_pipe_epoch_tests::ask_once_delta_reask_direct_carves_refreshes_and_updates_page_epochs passed when re-run solo); renodx::tests 4/4 passed including bake_and_blit_hlsl_compile_and_roundtrip_on_warp (D3DCompile + root signature + compute/graphics PSO creation on WARP).
  • Changes a default: no (DARNER_RENODX defaults to off; when off, the title's original LUT and PS_BlitHDRACES are used unchanged).
  • A/B result: Off by default, no performance claim. Verified in-game visually by toggling HDR TONEMAPPER live between OFF and RENODRT / DICE / HERMITE and adjusting peak/paper-white/grading sliders in real time, confirming shadow black floor, midgray balance, highlight rolloff, and exact restoration on OFF.
  • Gates run on that revision: Gate 1 (clippy --workspace --all-targets), Gate 2 (clippy --workspace --all-targets --all-features), cargo xtask policy, plus targeted unit tests on darner, darner-gpu, darner-loader, and darner-core. Gate 3 full cargo test --workspace was not run (darner-shader is untouched by this PR).
  • Gameplay: Windows x64, Ryzen 7 7800X3D, NVIDIA GeForce RTX 5070, VESA DisplayHDR 1400 (1600 nits calibrated), Series S profile, 1440p output, DLSS Performance, DLSS Frame Generation x2, Hardware Ray Tracing, DARNER_HDR=1. In-game test ran on the identical RenoDX v2 shader/hook code prior to downgrading one-shot probe logs to debug and removing the unused custom-LUT probe for this clean branch.
  • Shader wave sizes tested: N/A (host HLSL SM 5.1 compute/pixel passes; no RDNA2 translator changes).
  • Hardware dependence: likely general across D3D12 HDR10/scRGB GPUs and displays (peak reads DXGI MaxLuminance automatically when PEAK = AUTO); untested on AMD/Intel GPUs and scRGB (R16G16B16A16_FLOAT) swap chains in-game (scRGB PSO compilation is covered by the WARP unit test).
  • Coverage gaps: Untested in-game on AMD/Intel GPUs, scRGB swap chains, and Linux/Proton; full darner-shader test suite not run as translator code was not modified.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only).
  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md.
  • I recorded this PR's dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: #456 (also touches crates/darner-gpu/src/host/menu.rs for an unrelated reflection-resolution setting).
  • Replaces or overlaps: none found
## What it changes The problem on main: Darner's DARNER_HDR=1 already enables and presents the title's native HDR output, so the limitation is in the title's own HDR pipeline rather than Darner's presentation path. Like many console ACES HDR implementations, the title's baked ACES 3D LUT (CS_BakeACESWithGamutCompressTonemapOnlyLUT_QuasiLogShaper) and secondary blit (PS_BlitHDRACES) use a fixed curve with no user control over tonemapper, peak rolloff, paper white, shadow/highlight grading, or black-floor flare (the same issues players typically address with RenoDX). In addition, DARNER_HDR_PAPER_WHITE is currently read once at startup rather than adjustable live from the F1 menu. This PR adds an opt-in, live-tunable RenoDX-style HDR tonemapping and display output pipeline (`DARNER_RENODX`, default `off`) under F1 -> `DISPLAY`: 1. **3D tonemap LUT hook (`crates/darner-gpu/src/renodx.rs`, `draw.rs`, `pipeline.rs`)**: - Intercepts `CS_BakeACESWithGamutCompressTonemapOnlyLUT_QuasiLogShaper`, backs up the title's original `64x64x64` FP16 AP1 3D LUT so switching back to `OFF` restores vanilla rendering bit-for-bit without restarting. - Bakes a replacement 3D LUT matching the title's Quasi-Log shaper into AP1 nits using MIT-licensed algorithms adapted from `clshortfuse/renodx` (`daniele.hlsl`, `reno_drt.hlsl`, `DICE.hlsl`, `hermite_spline.hlsl`, `colorgrade.hlsl` v4, `color/oklab.hlsl`): - `RENODRT`: Daniele filmic curve (ACES-matched `c_d = 10` on `100` reference white and shadow toe) + OkLab hue preservation + highlight blowout. - `DICE` / `HERMITE`: filmic toe pre-curve with luminance-preserving exponential / cubic-Hermite rolloff to display peak. - Rebakes the 3D LUT live whenever any F1 HDR slider changes (`DARNER_RENODX`, `DARNER_RENODX_PEAK`, `DARNER_RENODX_PAPER_WHITE`, `DARNER_RENODX_EXPOSURE`, `DARNER_RENODX_CONTRAST`, `DARNER_RENODX_SHADOWS`, `DARNER_RENODX_HIGHLIGHTS`, `DARNER_RENODX_SATURATION`, `DARNER_RENODX_BLOWOUT`, `DARNER_RENODX_FLARE`). `PEAK = AUTO` reads display max luminance via DXGI (`hdr_display_info`). 2. **HDR blit replacement (`PS_BlitHDRACES`)**: - Once the world 3D LUT is active and HDR output is enabled (`hdr_active()`), replaces the title's secondary curve blit with a clean D60 AP1 -> D65 BT.2020 -> ST.2084 PQ (or scRGB) output pass with 10-bit triangular IGN dithering. 3. **Live UI paper white (`host/hdr.rs`, `host/menu.rs`, `apps/darner/src/play.rs`)**: - Makes `DARNER_HDR_PAPER_WHITE` (`HDR UI WHITE NITS`) live-adjustable via atomic storage on the F1 `DISPLAY` page and persists `DARNER_RENODX*` and `DARNER_HDR_PAPER_WHITE` in `darner-settings.txt`. ## How it was tested - Tested revision: `7cc7bd3245f26b3afa743f39291074a9a13557b6` (based on `origin/main` `c8258f95569c10fe75b5bfb785d3865b5deeefd9`). - Commands and results: - `cargo xtask policy` — `asset policy: 577 files ok` (pass) - `cargo clippy --workspace --all-targets --locked -- -D warnings` — 0 warnings/errors (pass) - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` — 0 warnings/errors (pass) - `cargo test --locked -p darner-core --lib` — 50 passed, 0 failed - `cargo test --locked -p darner-loader --lib` — 98 passed, 0 failed - `cargo test --locked -p darner --bins` — 208 passed, 0 failed, 1 ignored - `cargo test --locked -p darner-gpu --lib` — 1826 passed, 81 ignored (1 pre-existing parallel flake `watch::watch_pipe_epoch_tests::ask_once_delta_reask_direct_carves_refreshes_and_updates_page_epochs` passed when re-run solo); `renodx::tests` 4/4 passed including `bake_and_blit_hlsl_compile_and_roundtrip_on_warp` (D3DCompile + root signature + compute/graphics PSO creation on WARP). - Changes a default: no (`DARNER_RENODX` defaults to `off`; when `off`, the title's original LUT and `PS_BlitHDRACES` are used unchanged). - A/B result: Off by default, no performance claim. Verified in-game visually by toggling `HDR TONEMAPPER` live between `OFF` and `RENODRT` / `DICE` / `HERMITE` and adjusting peak/paper-white/grading sliders in real time, confirming shadow black floor, midgray balance, highlight rolloff, and exact restoration on `OFF`. - Gates run on that revision: Gate 1 (`clippy --workspace --all-targets`), Gate 2 (`clippy --workspace --all-targets --all-features`), `cargo xtask policy`, plus targeted unit tests on `darner`, `darner-gpu`, `darner-loader`, and `darner-core`. Gate 3 full `cargo test --workspace` was not run (`darner-shader` is untouched by this PR). - Gameplay: Windows x64, Ryzen 7 7800X3D, NVIDIA GeForce RTX 5070, VESA DisplayHDR 1400 (1600 nits calibrated), Series S profile, 1440p output, DLSS Performance, DLSS Frame Generation x2, Hardware Ray Tracing, `DARNER_HDR=1`. In-game test ran on the identical RenoDX v2 shader/hook code prior to downgrading one-shot probe logs to `debug` and removing the unused custom-LUT probe for this clean branch. - Shader wave sizes tested: N/A (host HLSL SM 5.1 compute/pixel passes; no RDNA2 translator changes). - Hardware dependence: likely general across D3D12 HDR10/scRGB GPUs and displays (peak reads DXGI `MaxLuminance` automatically when `PEAK = AUTO`); untested on AMD/Intel GPUs and scRGB (`R16G16B16A16_FLOAT`) swap chains in-game (scRGB PSO compilation is covered by the WARP unit test). - Coverage gaps: Untested in-game on AMD/Intel GPUs, scRGB swap chains, and Linux/Proton; full `darner-shader` test suite not run as translator code was not modified. ## Checklist - [x] I ran this change in the game, or say below why it can't be (docs, tests only). - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md`. - [x] I recorded this PR's dependencies below. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: #456 (also touches `crates/darner-gpu/src/host/menu.rs` for an unrelated reflection-resolution setting). - Replaces or overlaps: none found
First-time contributor

Question: The game its self has HDR settings as well right. How do they compare with your new settings? Are those in game settings ignored and overwritten by your version?

Got any visual comparison what the difference will be?

Question: The game its self has HDR settings as well right. How do they compare with your new settings? Are those in game settings ignored and overwritten by your version? Got any visual comparison what the difference will be?
Author
First-time contributor

Good question — here is how the two interact:

  1. In-game HDR settings vs. RenoDX settings:

    • Overwritten / ignored for 3D scene tonemapping & output: When DARNER_RENODX is active (RenoDRT / DICE / Hermite), it overwrites the game's baked 3D ACES LUT (CS_BakeACESWithGamutCompressTonemapOnlyLUT_QuasiLogShaper) using DARNER_RENODX_PEAK, DARNER_RENODX_PAPER_WHITE, and the RenoDX grading sliders, and replaces PS_BlitHDRACES with a direct AP1 -> BT.2020 -> ST.2084 PQ / scRGB pass with 10-bit dithering. So the game's own HDR peak/paper-white calibration and stock ACES tonemapping curve are effectively bypassed for the 3D world.
    • Still active: The game still needs to be running in HDR mode (DARNER_HDR=1, in-game HDR enabled) so the HDR LUT & blit path are used. Any separate in-game HUD/UI brightness (rendered outside PS_BlitHDRACES) or pre-tonemap exposure adjustments remain controlled by the game, while Darner's own overlay uses DARNER_HDR_PAPER_WHITE.
    • Switching DARNER_RENODX back to OFF restores the backed-up original 3D LUT bit-for-bit and falls back to the vanilla PS_BlitHDRACES pass immediately.
  2. Visual difference:

    • Compared to the stock ACES LUT, RenoDRT/DICE/Hermite keep mid-gray anchored cleanly to paper white while scaling specular highlights all the way up to your display's actual peak nits, preserve hue/chroma cleanly in Oklab (avoiding washed-out or hue-shifted highlights), add live grading controls in the F1 menu (exposure/contrast/shadows/highlights/saturation/blowout/flare), and reduce gradient banding via 10-bit triangular IGN dithering.
    • (Note: I don't have side-by-side HDR comparison captures attached yet—note that standard SDR screenshots won't accurately convey the highlight headroom—but you can toggle OFF vs RenoDRT live in the F1 menu to see the difference instantaneously.)
Good question — here is how the two interact: 1. **In-game HDR settings vs. RenoDX settings:** - **Overwritten / ignored for 3D scene tonemapping & output:** When `DARNER_RENODX` is active (`RenoDRT` / `DICE` / `Hermite`), it overwrites the game's baked 3D ACES LUT (`CS_BakeACESWithGamutCompressTonemapOnlyLUT_QuasiLogShaper`) using `DARNER_RENODX_PEAK`, `DARNER_RENODX_PAPER_WHITE`, and the RenoDX grading sliders, and replaces `PS_BlitHDRACES` with a direct `AP1 -> BT.2020 -> ST.2084 PQ / scRGB` pass with 10-bit dithering. So the game's own HDR peak/paper-white calibration and stock ACES tonemapping curve are effectively bypassed for the 3D world. - **Still active:** The game still needs to be running in HDR mode (`DARNER_HDR=1`, in-game HDR enabled) so the HDR LUT & blit path are used. Any separate in-game HUD/UI brightness (rendered outside `PS_BlitHDRACES`) or pre-tonemap exposure adjustments remain controlled by the game, while Darner's own overlay uses `DARNER_HDR_PAPER_WHITE`. - Switching `DARNER_RENODX` back to `OFF` restores the backed-up original 3D LUT bit-for-bit and falls back to the vanilla `PS_BlitHDRACES` pass immediately. 2. **Visual difference:** - Compared to the stock ACES LUT, RenoDRT/DICE/Hermite keep mid-gray anchored cleanly to paper white while scaling specular highlights all the way up to your display's actual peak nits, preserve hue/chroma cleanly in Oklab (avoiding washed-out or hue-shifted highlights), add live grading controls in the F1 menu (exposure/contrast/shadows/highlights/saturation/blowout/flare), and reduce gradient banding via 10-bit triangular IGN dithering. - *(Note: I don't have side-by-side HDR comparison captures attached yet—note that standard SDR screenshots won't accurately convey the highlight headroom—but you can toggle `OFF` vs `RenoDRT` live in the F1 menu to see the difference instantaneously.)*
TrustNo1 changed title from [pr-feature][rendering] Add live RenoDX HDR tonemapper and PQ/scRGB output blit to Add live RenoDX HDR tonemapper and PQ/scRGB output blit 2026-12-06 03:27:11 +00:00
Owner

Test needed — commit 7cc7bd32; what to check:

The problem on main: Darner's DARNER_HDR=1 already enables and presents the title's native HDR output, so the limitation is in the title's own HDR pipeline rather than Darner's presentation path. Like many console ACES HDR implementations, the title's baked ACES 3D LUT (CS_BakeACESWithGamutCompressTonemapOnlyLUT_QuasiLogShaper) and secondary blit (PS_BlitHDRACES) use a fixed curve with no user control over tonemapper, peak rolloff, paper white, shadow/highlight grading, or black-floor flare (the same issues players typically address with RenoDX). In addition, DARNER_HDR_PAPER_WHITE is currently read once at startup rather than adjustable live from the F1 menu.

This PR adds an opt-in, live-tunable RenoDX-style HDR tonemapping and display output pipeline (DARNER_RENODX, default off) under F1 -> DISPLAY:

  1. 3D tonemap LUT hook (crates/darner-gpu/src/renodx.rs, draw.rs, pipeline.rs):
    • Intercepts CS_BakeACESWithGamutCompressTonemapOnlyLUT_QuasiLogShaper, backs up the title's original 64x64x64 FP16 AP1 3D LUT so switching back to OFF restores vanilla rendering bit-for-bit without restarting.
    • Bakes a replacement 3D LUT matching the title's Quasi-Log shaper

Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture.

Reply testing to take this run; it's free again after 24 h with no results.

**Test needed** — commit `7cc7bd32`; what to check: The problem on main: Darner's DARNER_HDR=1 already enables and presents the title's native HDR output, so the limitation is in the title's own HDR pipeline rather than Darner's presentation path. Like many console ACES HDR implementations, the title's baked ACES 3D LUT (CS_BakeACESWithGamutCompressTonemapOnlyLUT_QuasiLogShaper) and secondary blit (PS_BlitHDRACES) use a fixed curve with no user control over tonemapper, peak rolloff, paper white, shadow/highlight grading, or black-floor flare (the same issues players typically address with RenoDX). In addition, DARNER_HDR_PAPER_WHITE is currently read once at startup rather than adjustable live from the F1 menu. This PR adds an opt-in, live-tunable RenoDX-style HDR tonemapping and display output pipeline (`DARNER_RENODX`, default `off`) under F1 -> `DISPLAY`: 1. **3D tonemap LUT hook (`crates/darner-gpu/src/renodx.rs`, `draw.rs`, `pipeline.rs`)**: - Intercepts `CS_BakeACESWithGamutCompressTonemapOnlyLUT_QuasiLogShaper`, backs up the title's original `64x64x64` FP16 AP1 3D LUT so switching back to `OFF` restores vanilla rendering bit-for-bit without restarting. - Bakes a replacement 3D LUT matching the title's Quasi-Log shaper Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture. Reply `testing` to take this run; it's free again after 24 h with no results.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'feat/hdr-renodx:Swaizhd-feat/hdr-renodx'
git switch 'Swaizhd-feat/hdr-renodx'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'Main'
git merge --no-ff 'Swaizhd-feat/hdr-renodx'
git switch 'Swaizhd-feat/hdr-renodx'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'Swaizhd-feat/hdr-renodx'
git switch 'Swaizhd-feat/hdr-renodx'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'Swaizhd-feat/hdr-renodx'
git switch 'Main'
git merge --squash 'Swaizhd-feat/hdr-renodx'
git switch 'Main'
git merge --ff-only 'Swaizhd-feat/hdr-renodx'
git switch 'Main'
git merge 'Swaizhd-feat/hdr-renodx'
git push origin 'Main'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!554
No description provided.