[pr-feature][rendering] Depth of field off (DARNER_DOF=0, off by default; F1 PICTURE > DEPTH OF FIELD, next start) #9

Open
Jesper-A wants to merge 1 commit from Jesper-A/Darner:pr4-dof into main
Contributor

Contributor role (optional)

  • Fluxer ID:

What it changes

Re-filed from CodeFloe #316 (the CodeFloe repo is gone; nothing was migrated). Same branch and commit.

This is a draft. The change has not been run in the game on this base yet (see "How it was tested"), and current main conflicts with it in two files (see "Checklist").

Base: the branch is on f2bccf656, the main commit it was cut from. main is now dd2f061d5. Not rebased (we rebase only if you ask). A text-only trial merge (git merge-tree --write-tree trustno1/main pr4-dof) conflicts in crates/darner-gpu/src/host/menu.rs and docs/findings.md; the other files merge cleanly.

Credit: a port of the depth of field part of PR #3590 of the project's earlier GitHub repository (author NICKNAMErutschovkonikovan; that repository is gone, so there is no link). The idea, the place in the title's code and the offsets are theirs. The code is re-written with our names for the current tree and without the lens flare switch it sat on there. The commit message names them.

New switch: DARNER_DOF=0. Default: off, meaning not set: the title's own depth of field, nothing written. With DARNER_DOF=0 at the start, the game's depth of field (blur by distance, in cutscenes and scopes too) is set up as none.

How: the title has one depth of field object whose kind is decided once, when the object is made, and read every frame. Kind 0 (what a failed setup leaves) skips all its passes. The kind comes from a small routine that stores a kind pair. With the switch at 0, the kind's byte in that routine is patched to 0 before any title thread runs (darner_hle::viewhook::install, darner_loader::callhook::patch_bytes, which checks the old byte). The routine, its one call site and the place where the setup takes the kind are compared with their expected bytes first. If any differs (a build of the title this does not know), nothing is written, depth of field: NOT ACTIVE is logged and F1 shows NOT ACTIVE.

viewhook::install is called only when DARNER_DOF=0 is in the environment at the start (Armed::from_env().dof, in apps/darner/src/run.rs, with a // SAFETY: comment). Unset or any other value: nothing is read or written.

Not live: changing the kind while the title runs would leave its targets unresized on a resolution change, so F1 > PICTURE > DEPTH OF FIELD (ON / OFF) applies at the next start. No shader change, so the shader cache key is unchanged.

Also: a README row (Picture and upscaling, 27 to 28 settings) and a docs/findings.md entry.

Files (git diff --stat f2bccf656 ba8cf0e4e, 9 files, +387/-2): crates/darner-hle/src/viewhook.rs (new, 246 lines), crates/darner-gpu/src/view_fx.rs (new, 99 lines), crates/darner-gpu/src/host/menu.rs, crates/darner-gpu/src/lib.rs, crates/darner-hle/src/lib.rs, apps/darner/src/play.rs, apps/darner/src/run.rs, README.md, docs/findings.md.

Spec dependence

Likely general: no GPU or shader code is touched, so no card, driver or wave size dependence is expected. The F1 row and the README text are plain UI and docs.

May depend on our setup: the patch is a byte in the title's own code, so it depends on the title build, not on the card. The offsets are for one known build; the checks above refuse anything else. Our PC, where nothing was run for this commit yet: RTX 2070 SUPER 8 GB (Turing), driver 621.40, Resizable BAR off, Ryzen 7 5800X, 32 GB, Windows 11 Pro Insider 26320, Series S profile with DLSS Performance.

Untested elsewhere: any other card, any other title build (it should answer NOT ACTIVE; not tried), cutscenes and scopes one by one, DLSS and frame generation combinations.

How it was tested

  • Tested revision: ba8cf0e4e on main f2bccf656. main has moved since (now dd2f061d5); not retested there.
  • Commands and results (cargo only, on ba8cf0e4e):
    • cargo test --locked -p darner-gpu --lib -- view_fx menu: 40 passed, 0 failed, 1 ignored.
    • cargo test --locked -p darner-hle --lib viewhook: 4 passed.
    • cargo clippy --locked --all-features -p darner-gpu -p darner-hle -p darner -- -D warnings -A clippy::unnecessary_lazy_evaluations: clean. This is narrower than upstream's gate 2 (three crates, no --workspace --all-targets, and one lint allowed).
    • cargo xtask policy: ok.
    • The unit tests use synthetic code and images only.
  • Pending, not run: gate 1 (cargo clippy --workspace --all-targets --locked -- -D warnings), gate 2 (the same with --all-features) and gate 3 (cargo test --workspace --locked). There is no CI upstream, so nothing else has checked this.
  • Gameplay: not run in the game on this base.
  • Before and after: not measured. The README row says "None measured".
  • Shader wave sizes: no shader change.
  • Coverage gaps: everything under "Untested elsewhere" above; whether any picture or cutscene breaks without depth of field is unknown; behaviour with DLSS or frame generation on is unknown.

Checklist

  • This PR contains one change based on main (f2bccf656; see the last bullet).
  • The diff follows docs/asset-policy.md (cargo xtask policy: ok). No game data: the code holds a few expected instruction bytes and offsets for the checks.
  • I recorded this PR's dependencies below.
    • Depends on: none
  • Conflicts with current main: a trial merge of ba8cf0e4e into dd2f061d5 (git merge-tree --write-tree) conflicts in crates/darner-gpu/src/host/menu.rs and docs/findings.md (the other files merge cleanly). This PR stays on f2bccf656; I will update this same PR if the maintainer asks, and retest then. main has added picture rows to F1 since, so the DEPTH OF FIELD row's place and the menu tests will need adjusting then.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: none found for depth of field. On 2026-12-03 this host had 3 issues and 5 pull requests in total (#3 by another contributor; #5 to #8 are ours, re-filed today). I searched their titles and bodies: none is about depth of field, DARNER_DOF, viewhook or blur, and DARNER_DOF is not on main (dd2f061d5). The one open pull request (#3, ray tracing mode in F1) changes host/menu.rs, host/panel.rs and hwrt.rs: same file menu.rs as this change's F1 row, different change. The earlier CodeFloe search (nothing about depth of field among 19 open pull requests; CodeFloe numbers, not migrated) found the same.
  • Our own re-filed PRs that touch the same files: #8 (texture LOD bias: README.md, crates/darner-gpu/src/host/menu.rs, crates/darner-gpu/src/lib.rs, docs/findings.md), #6 (radial wheel hold: README.md, crates/darner-gpu/src/lib.rs, docs/findings.md) and #7 (long frames: docs/findings.md). Different changes; whichever lands first, the others take the new rows when they are rebased.

Update 2026-12-03: marked ready as it stands; the 'draft' and 'not rebased' wording above is out of date, nothing was re-run in the game, and the maintainer will handle the rebase.

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

## Contributor role (optional) - Fluxer ID: ## What it changes Re-filed from CodeFloe #316 (the CodeFloe repo is gone; nothing was migrated). Same branch and commit. This is a draft. The change has not been run in the game on this base yet (see "How it was tested"), and current `main` conflicts with it in two files (see "Checklist"). **Base:** the branch is on `f2bccf656`, the `main` commit it was cut from. `main` is now `dd2f061d5`. Not rebased (we rebase only if you ask). A text-only trial merge (`git merge-tree --write-tree trustno1/main pr4-dof`) conflicts in `crates/darner-gpu/src/host/menu.rs` and `docs/findings.md`; the other files merge cleanly. **Credit:** a port of the depth of field part of PR #3590 of the project's earlier GitHub repository (author **NICKNAMErutschovkonikovan**; that repository is gone, so there is no link). The idea, the place in the title's code and the offsets are theirs. The code is re-written with our names for the current tree and without the lens flare switch it sat on there. The commit message names them. **New switch: `DARNER_DOF=0`.** Default: off, meaning not set: the title's own depth of field, nothing written. With `DARNER_DOF=0` at the start, the game's depth of field (blur by distance, in cutscenes and scopes too) is set up as none. How: the title has one depth of field object whose kind is decided once, when the object is made, and read every frame. Kind 0 (what a failed setup leaves) skips all its passes. The kind comes from a small routine that stores a kind pair. With the switch at 0, the kind's byte in that routine is patched to 0 before any title thread runs (`darner_hle::viewhook::install`, `darner_loader::callhook::patch_bytes`, which checks the old byte). The routine, its one call site and the place where the setup takes the kind are compared with their expected bytes first. If any differs (a build of the title this does not know), nothing is written, `depth of field: NOT ACTIVE` is logged and F1 shows NOT ACTIVE. `viewhook::install` is called only when `DARNER_DOF=0` is in the environment at the start (`Armed::from_env().dof`, in `apps/darner/src/run.rs`, with a `// SAFETY:` comment). Unset or any other value: nothing is read or written. **Not live:** changing the kind while the title runs would leave its targets unresized on a resolution change, so F1 > PICTURE > DEPTH OF FIELD (ON / OFF) applies at the next start. No shader change, so the shader cache key is unchanged. Also: a README row (Picture and upscaling, 27 to 28 settings) and a `docs/findings.md` entry. Files (`git diff --stat f2bccf656 ba8cf0e4e`, 9 files, +387/-2): `crates/darner-hle/src/viewhook.rs` (new, 246 lines), `crates/darner-gpu/src/view_fx.rs` (new, 99 lines), `crates/darner-gpu/src/host/menu.rs`, `crates/darner-gpu/src/lib.rs`, `crates/darner-hle/src/lib.rs`, `apps/darner/src/play.rs`, `apps/darner/src/run.rs`, `README.md`, `docs/findings.md`. ## Spec dependence **Likely general:** no GPU or shader code is touched, so no card, driver or wave size dependence is expected. The F1 row and the README text are plain UI and docs. **May depend on our setup:** the patch is a byte in the title's own code, so it depends on the title build, not on the card. The offsets are for one known build; the checks above refuse anything else. Our PC, where nothing was run for this commit yet: RTX 2070 SUPER 8 GB (Turing), driver 621.40, Resizable BAR off, Ryzen 7 5800X, 32 GB, Windows 11 Pro Insider 26320, Series S profile with DLSS Performance. **Untested elsewhere:** any other card, any other title build (it should answer NOT ACTIVE; not tried), cutscenes and scopes one by one, DLSS and frame generation combinations. ## How it was tested - Tested revision: `ba8cf0e4e` on `main` `f2bccf656`. `main` has moved since (now `dd2f061d5`); not retested there. - Commands and results (cargo only, on `ba8cf0e4e`): - `cargo test --locked -p darner-gpu --lib -- view_fx menu`: 40 passed, 0 failed, 1 ignored. - `cargo test --locked -p darner-hle --lib viewhook`: 4 passed. - `cargo clippy --locked --all-features -p darner-gpu -p darner-hle -p darner -- -D warnings -A clippy::unnecessary_lazy_evaluations`: clean. This is narrower than upstream's gate 2 (three crates, no `--workspace --all-targets`, and one lint allowed). - `cargo xtask policy`: ok. - The unit tests use synthetic code and images only. - **Pending, not run:** gate 1 (`cargo clippy --workspace --all-targets --locked -- -D warnings`), gate 2 (the same with `--all-features`) and gate 3 (`cargo test --workspace --locked`). There is no CI upstream, so nothing else has checked this. - Gameplay: not run in the game on this base. - Before and after: not measured. The README row says "None measured". - Shader wave sizes: no shader change. - Coverage gaps: everything under "Untested elsewhere" above; whether any picture or cutscene breaks without depth of field is unknown; behaviour with DLSS or frame generation on is unknown. ## Checklist - [x] This PR contains one change based on `main` (`f2bccf656`; see the last bullet). - [x] The diff follows `docs/asset-policy.md` (`cargo xtask policy`: ok). No game data: the code holds a few expected instruction bytes and offsets for the checks. - [x] I recorded this PR's dependencies below. - Depends on: none - Conflicts with current `main`: a trial merge of `ba8cf0e4e` into `dd2f061d5` (`git merge-tree --write-tree`) conflicts in `crates/darner-gpu/src/host/menu.rs` and `docs/findings.md` (the other files merge cleanly). This PR stays on `f2bccf656`; I will update this same PR if the maintainer asks, and retest then. `main` has added picture rows to F1 since, so the DEPTH OF FIELD row's place and the menu tests will need adjusting then. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: none found for depth of field. On 2026-12-03 this host had 3 issues and 5 pull requests in total (#3 by another contributor; #5 to #8 are ours, re-filed today). I searched their titles and bodies: none is about depth of field, `DARNER_DOF`, `viewhook` or blur, and `DARNER_DOF` is not on `main` (`dd2f061d5`). The one open pull request (#3, ray tracing mode in F1) changes `host/menu.rs`, `host/panel.rs` and `hwrt.rs`: same file `menu.rs` as this change's F1 row, different change. The earlier CodeFloe search (nothing about depth of field among 19 open pull requests; CodeFloe numbers, not migrated) found the same. - Our own re-filed PRs that touch the same files: #8 (texture LOD bias: `README.md`, `crates/darner-gpu/src/host/menu.rs`, `crates/darner-gpu/src/lib.rs`, `docs/findings.md`), #6 (radial wheel hold: `README.md`, `crates/darner-gpu/src/lib.rs`, `docs/findings.md`) and #7 (long frames: `docs/findings.md`). Different changes; whichever lands first, the others take the new rows when they are rebased. Update 2026-12-03: marked ready as it stands; the 'draft' and 'not rebased' wording above is out of date, nothing was re-run in the game, and the maintainer will handle the rebase. This change was made with AI assistance (Claude Code).
Port of the depth of field part of PR #3590 of the project's earlier
GitHub repo (author NICKNAMErutschovkonikovan). With DARNER_DOF=0 at the
start the title sets its depth of field up as none; F1 PICTURE > DEPTH OF
FIELD shows it, and NOT ACTIVE when the build's bytes differ. The install
is called only when DARNER_DOF=0 is set.

This change was made with AI assistance (Claude Code).
Jesper-A changed title from WIP: [pr-feature][rendering] Depth of field off (DARNER_DOF=0, off by default; F1 PICTURE > DEPTH OF FIELD, next start) to [pr-feature][rendering] Depth of field off (DARNER_DOF=0, off by default; F1 PICTURE > DEPTH OF FIELD, next start) 2026-12-03 18:28:47 +00:00
This pull request has changes conflicting with the target branch.
  • README.md
  • crates/darner-gpu/src/host/menu.rs
  • docs/findings.md
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

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-pr4-dof'
git switch 'Jesper-A-pr4-dof'
git rebase 'main'
git switch 'main'
git merge --ff-only 'Jesper-A-pr4-dof'
git switch 'Jesper-A-pr4-dof'
git rebase 'main'
git switch 'main'
git merge --no-ff 'Jesper-A-pr4-dof'
git switch 'main'
git merge --squash 'Jesper-A-pr4-dof'
git switch 'main'
git merge --ff-only 'Jesper-A-pr4-dof'
git switch 'main'
git merge 'Jesper-A-pr4-dof'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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!9
No description provided.