WIP: EXPOSURE: the composer fallback is bounded, and the offset is read once #469

Draft
Jesper-A wants to merge 2 commits from Jesper-A/Darner:up-exposure-recursion-fix into Main
Collaborator

Refs #305

What it changes

Follow-up to #305 (merged at 170688480). It answers two review points on that PR. It is a new PR because #305 is merged.

  • The problem on main: read from the code only, not run. With DARNER_EXPOSURE set, a whole plane picks the plane composer. When the composer is still pending or cannot be made, show_base_only calls present_planes again. That call picks the composer again, so, reading the code, the fallback can repeat without a bound (crates/darner-gpu/src/host.rs, present_placed, show_base_only). On the main before #305 the same fallback ended in a copy (per iBooM72, comment 872386).
  • What this does: the retry is now a base-only present that runs once (PresentComposition::fallback_to_base). With it set, exposure is off for that present, so a copyable plane is shown as it is. If that present also needs a fallback, it returns None instead of retrying. The same three log lines (two-plane composer not made, two-plane composer not made after resize, could not record display composite) now report fallback = can_fallback.
  • exposure_ev() read the environment twice per present. It is now read once and kept in an atomic. The F1 row updates it through set_exposure (host/menu.rs). A unit test checks that the "not read yet" marker can never be produced by parse_exposure.
  • docs/findings.md says both of these, and says the frame-generation gap below is open.

Credit:

  • The bound is andrewpozdnakov7-jpg's commit 4bc7d8c, kept with its author (the first commit here, 50ff98107). He found the repeated composer attempts on #305: #305 (comment)
  • iBooM72 found that the repeat is unbounded and so likely a stack overflow, and pointed out the double environment read: #305 (comment)

Not fixed here: iBooM72's frame-generation point. DLSS-FG and FSR get the scene plane before the composer as the colour without the interface, while the back buffer is scaled by 2^EV. Where frame generation finds the interface by difference (always in HDR10), every pixel then differs with the offset on. Fixing it would need the same scale on that copy. It stays open and is written down in docs/findings.md. The game run below includes it.

How it was tested

  • Tested revision: branch up-exposure-recursion-fix @ d324094f5, based on main 47d21cd3b.
  • Based on main 47d21cd3b. main is now d91d8e4d6; git merge-tree merges the branch cleanly there. Not rebased, not re-tested on the new main (WIP).
  • Commands and results (scoped; the three workspace gates were not run):
    • cargo clippy -p darner-gpu, with and without --all-features, and the compose tests of darner-gpu (the exposure tests among them; 7 passed), reported clean by the porter; exact clippy flags not kept.
    • cargo xtask policy: ok (as reported).
  • Changes a default: no. With DARNER_EXPOSURE unset or 0 the present path is as before.
  • A/B result: none. No speed claim is made.
  • Gates run on that revision: only the scoped ones above. Not run: cargo clippy --workspace --all-targets --locked -- -D warnings, the same with --all-features, cargo test --workspace --locked.
  • Gameplay: not run in game.
  • Shader wave sizes tested: no shader change.
  • Hardware dependence: see "Spec dependence".
  • Coverage gaps, to check in the game run before WIP: comes off:
    • SDR, with EXPOSURE -1, 0 and +1: the picture changes with the F1 row, with and without the interface drawn.
    • A forced composer failure (for example DARNER_COMPOSER_ASIDE=1 while the composer is pending): the game keeps running and shows the plane as it is, once, with no repeated two-plane composer not made lines.
    • Frame generation on (DLSS-FG, and FSR if available) with EXPOSURE -1 and +1: whether generated frames show the interface or flicker. This is the open point above.
    • HDR10 output.

Spec dependence

  • Likely general (helps any card): the bounded fallback and the single read are plain control flow, with no GPU specifics.
  • May depend on our specs (RTX 2070 SUPER Turing wave32, 8 GB VRAM, ReBAR off, Ryzen 7 5800X, 32 GB, Series S + DLSS Performance): nothing known.
  • Untested elsewhere: everything in game: other GPUs (AMD, Intel), Series X, HDR10, frame generation, ray tracing.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only). Not run in game yet; this is a draft.
  • This PR contains one change based on main: the exposure fallback and read. Both commits are about #305's follow-up on the same function.
  • The diff follows docs/asset-policy.md. (cargo xtask policy ok on the branch; text only.)
  • 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 (open PRs only; file lists read through the API, 2026-12-05):
    • #75 and #143 change crates/darner-gpu/src/compose.rs, as this does. A textual conflict is likely there, most of all with #143, whose first hunk (about lines 13 to 18) is a few lines from ours (about 23 to 31). iBooM72 warned on #305 about CONSTANTS in that file.
    • #344 changes Host::present next to this (iBooM72 noted it on #305) and host/menu.rs. Its host.rs hunks are well below ours; #143 also edits host.rs near ours (about line 20095). Many other open PRs list host.rs or host/menu.rs; I did not compare them all.
    • #450, #451, #459 and #460 (ours) also edit docs/findings.md. Their hunks are on other lines; #459's starts a few lines below ours. A trivial merge is possible; I do not claim it is conflict-free.
  • Replaces or overlaps: none found (no open PR bounds this fallback).

This change was made with AI assistance (Claude Code).

Refs #305 ## What it changes Follow-up to #305 (merged at `170688480`). It answers two review points on that PR. It is a new PR because #305 is merged. - The problem on main: read from the code only, not run. With `DARNER_EXPOSURE` set, a whole plane picks the plane composer. When the composer is still pending or cannot be made, `show_base_only` calls `present_planes` again. That call picks the composer again, so, reading the code, the fallback can repeat without a bound (`crates/darner-gpu/src/host.rs`, `present_placed`, `show_base_only`). On the main before #305 the same fallback ended in a copy (per iBooM72, comment 872386). - What this does: the retry is now a base-only present that runs once (`PresentComposition::fallback_to_base`). With it set, exposure is off for that present, so a copyable plane is shown as it is. If that present also needs a fallback, it returns `None` instead of retrying. The same three log lines (`two-plane composer not made`, `two-plane composer not made after resize`, `could not record display composite`) now report `fallback = can_fallback`. - `exposure_ev()` read the environment twice per present. It is now read once and kept in an atomic. The F1 row updates it through `set_exposure` (`host/menu.rs`). A unit test checks that the "not read yet" marker can never be produced by `parse_exposure`. - `docs/findings.md` says both of these, and says the frame-generation gap below is open. Credit: - The bound is andrewpozdnakov7-jpg's commit `4bc7d8c`, kept with its author (the first commit here, `50ff98107`). He found the repeated composer attempts on #305: https://git.gtahub.st/TrustNo1/Darner/pulls/305#issuecomment-866492 - iBooM72 found that the repeat is unbounded and so likely a stack overflow, and pointed out the double environment read: https://git.gtahub.st/TrustNo1/Darner/pulls/305#issuecomment-872386 **Not fixed here:** iBooM72's frame-generation point. DLSS-FG and FSR get the scene plane before the composer as the colour without the interface, while the back buffer is scaled by 2^EV. Where frame generation finds the interface by difference (always in HDR10), every pixel then differs with the offset on. Fixing it would need the same scale on that copy. It stays open and is written down in `docs/findings.md`. The game run below includes it. ## How it was tested - Tested revision: branch `up-exposure-recursion-fix` @ `d324094f5`, based on main `47d21cd3b`. - Based on main `47d21cd3b`. main is now `d91d8e4d6`; `git merge-tree` merges the branch cleanly there. Not rebased, not re-tested on the new main (WIP). - Commands and results (scoped; the three workspace gates were not run): - `cargo clippy -p darner-gpu`, with and without `--all-features`, and the compose tests of `darner-gpu` (the exposure tests among them; 7 passed), reported clean by the porter; exact clippy flags not kept. - `cargo xtask policy`: ok (as reported). - Changes a default: no. With `DARNER_EXPOSURE` unset or 0 the present path is as before. - A/B result: none. No speed claim is made. - Gates run on that revision: only the scoped ones above. Not run: `cargo clippy --workspace --all-targets --locked -- -D warnings`, the same with `--all-features`, `cargo test --workspace --locked`. - Gameplay: not run in game. - Shader wave sizes tested: no shader change. - Hardware dependence: see "Spec dependence". - Coverage gaps, to check in the game run before `WIP:` comes off: - SDR, with EXPOSURE -1, 0 and +1: the picture changes with the F1 row, with and without the interface drawn. - A forced composer failure (for example `DARNER_COMPOSER_ASIDE=1` while the composer is pending): the game keeps running and shows the plane as it is, once, with no repeated `two-plane composer not made` lines. - Frame generation on (DLSS-FG, and FSR if available) with EXPOSURE -1 and +1: whether generated frames show the interface or flicker. This is the open point above. - HDR10 output. ## Spec dependence - Likely general (helps any card): the bounded fallback and the single read are plain control flow, with no GPU specifics. - May depend on our specs (RTX 2070 SUPER Turing wave32, 8 GB VRAM, ReBAR off, Ryzen 7 5800X, 32 GB, Series S + DLSS Performance): nothing known. - Untested elsewhere: everything in game: other GPUs (AMD, Intel), Series X, HDR10, frame generation, ray tracing. ## Checklist - [ ] I ran this change in the game, or say below why it can't be (docs, tests only). Not run in game yet; this is a draft. - [x] This PR contains one change based on `main`: the exposure fallback and read. Both commits are about #305's follow-up on the same function. - [ ] The diff follows `docs/asset-policy.md`. (`cargo xtask policy` ok on the branch; text only.) - [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 (open PRs only; file lists read through the API, 2026-12-05): - #75 and #143 change `crates/darner-gpu/src/compose.rs`, as this does. A textual conflict is likely there, most of all with #143, whose first hunk (about lines 13 to 18) is a few lines from ours (about 23 to 31). iBooM72 warned on #305 about `CONSTANTS` in that file. - #344 changes `Host::present` next to this (iBooM72 noted it on #305) and `host/menu.rs`. Its `host.rs` hunks are well below ours; #143 also edits `host.rs` near ours (about line 20095). Many other open PRs list `host.rs` or `host/menu.rs`; I did not compare them all. - #450, #451, #459 and #460 (ours) also edit `docs/findings.md`. Their hunks are on other lines; #459's starts a few lines below ours. A trivial merge is possible; I do not claim it is conflict-free. - Replaces or overlaps: none found (no open PR bounds this fallback). This change was made with AI assistance (Claude Code).
When the plane composer is pending or cannot be made, show_base_only calls
back through the present path. With the exposure offset on, a whole plane
selected the composer again, so the retry could recurse without a bound.
The retry is now a base-only present that runs once.

Port of andrewpozdnakov7-jpg's 4bc7d8c (PR #305 thread).

This change was made with AI assistance (Claude Code).
Review of #305 (iBooM72): exposure_ev() read the environment twice per
present. It is now cached in an atomic, filled from DARNER_EXPOSURE on
first use and updated by the F1 row (set_exposure). docs/findings.md
records the frame generation HUD-difference mismatch (the HUD-less copy
is not scaled) as open for the game run, and the bounded fallback.

This change was made with AI assistance (Claude Code).
Jesper-A force-pushed up-exposure-recursion-fix from d324094f5d to 372c0c6c76 2026-12-05 16:40:16 +00:00 Compare
Author
Collaborator

Closing this old-engine PR because post-merge replaced the code it fixes: the EXPOSURE composer (compose.rs) is gone, and brightness there is the title's own GAMMA row (settings.rs:557-575).

Written with AI assistance (Claude Code).

Closing this old-engine PR because post-merge replaced the code it fixes: the EXPOSURE composer (`compose.rs`) is gone, and brightness there is the title's own GAMMA row (`settings.rs:557-575`). Written with AI assistance (Claude Code).
Jesper-A closed this pull request 2026-12-06 01:26:28 +00:00
Jesper-A reopened this pull request 2026-12-06 01:52:05 +00:00
Author
Collaborator

Reopened: Main is the default branch again, so the close note above no longer applies.

Written with AI assistance (Claude Code).

Reopened: Main is the default branch again, so the close note above no longer applies. Written with AI assistance (Claude Code).
TrustNo1 changed title from WIP: [pr-fix][rendering][lighting] EXPOSURE: the composer fallback is bounded, and the offset is read once to WIP: EXPOSURE: the composer fallback is bounded, and the offset is read once 2026-12-06 03:28:34 +00:00
This pull request is marked as a work in progress.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'up-exposure-recursion-fix:Jesper-A-up-exposure-recursion-fix'
git switch 'Jesper-A-up-exposure-recursion-fix'

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 'Jesper-A-up-exposure-recursion-fix'
git switch 'Jesper-A-up-exposure-recursion-fix'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'Jesper-A-up-exposure-recursion-fix'
git switch 'Jesper-A-up-exposure-recursion-fix'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'Jesper-A-up-exposure-recursion-fix'
git switch 'Main'
git merge --squash 'Jesper-A-up-exposure-recursion-fix'
git switch 'Main'
git merge --ff-only 'Jesper-A-up-exposure-recursion-fix'
git switch 'Main'
git merge 'Jesper-A-up-exposure-recursion-fix'
git push origin 'Main'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
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!469
No description provided.