gpu: LEONIDA_MIP_BIAS=1, a texture LOD bias for the title's samplers under DLSS (off by default) #3415

Code

Clone this repository

Checkout

From your project repository, check out a new branch and test the changes.

git fetch -u origin "feat/dlss-mip-bias:feat/dlss-mip-bias"
git switch "feat/dlss-mip-bias"
Open
leonida/mandy
MoonEyes wants to merge 2 commits from feat/dlss-mip-bias into main

This pull request has changes conflicting with the target branch.

Merge manually to resolve the conflicts.

Conversation
Reviewers 0 approvals
  • No reviewers
Details

This pull request has changes conflicting with the target branch.

Merge manually to resolve the conflicts.

  • d3d12/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 origin 'feat/dlss-mip-bias:feat/dlss-mip-bias'
git switch 'feat/dlss-mip-bias'
Member

Head: 6e80a61d1f (commits a3af17b139, 6e80a61d1f), on main 5286146626.

Change. New leonida-gpu/src/mip_bias.rs, called where descriptor/host.rs writes a console sampler (CreateSamplerX). With LEONIDA_MIP_BIAS=1 (or auto) the title's own bias gets NVIDIA's DLSS-guide offset log2(render width / output width) - 1 added, from the widths of the last DLSS upscale (dlss::record reports them; nothing is added before one, or with the stretch). auto-soft leaves out the minus 1; another number is added as it is (1.0 for +1). Comparison, min/max reduction, flat-LOD-range and point samplers keep the title's bias. Unset, empty or 0: the descriptor is untouched (one OnceLock read). A descriptor is written once, so a sampler made before the first upscale keeps its bias. One INFO line says the mode, one summary after 30 s or 256 samplers gives a histogram of the title's own biases and what was changed or kept. Under LEONIDA_AB (diagnostics) the switch follows the phase. Not touched, as in Darner: static samplers, the plain D3D12 CreateSampler form, the F1 menu row. d3d12/docs/findings.md and the generated switches.md are updated.

Tests. 8 unit tests in mip_bias.rs (parsing, the guide's numbers, clamping and NaN, the kept kinds, the mode that is on counting and stopping, the ratio from an upscale, the histogram). cargo test -p leonida-gpu --locked: 736 passed (Windows 11). python -I tests/test_d3d12_switches.py OK, check_no_game_data.py on the touched files clean. The dlss feature was not built (no SDK here): the call in dlss.rs sits after the successful evaluate and was read by the judge, not compiled.

In-game run required. Not played, nothing measured. Run on Series S at 720 lines with DLSS (RTX card), start with LEONIDA_MIP_BIAS=1, 300 s without a device loss. Look at: the two log lines (LEONIDA_MIP_BIAS: auto ... offset now -1.585 for 720 -> 1080, then the summary: how many samplers changed), fine texture detail (road markings, fences, text) sharper than without, shimmer or flicker in motion (then try auto-soft), and the frame time (a lower mip level costs memory bandwidth). An A/B by LEONIDA_AB only compares what it means to if the title makes its samplers again each phase; otherwise start twice.

AI-assisted. Written with Claude Opus 5.5 (orchestrating session) and Claude Sonnet 5.5 (the agent that wrote the code). Reviewed by a distinct read-only Claude agent (code-reviewer): verdict ACCEPTED; its findings (statistics stop after the summary, a test for the mode that is on, the A/B caveat in the notes) are fixed in the head.

Credit. Darner (https://github.com/tyr0nsur/Darner), crates/darner-gpu/src/mip_bias.rs, commit 1b45773 (Jesper-Andersson), GPL-3.0-or-later as this repository, credited in the module's header and in the commit message.

🤖 Generated with Claude Code

Head: `6e80a61d1f` (commits `a3af17b139`, `6e80a61d1f`), on main `5286146626`. **Change.** New `leonida-gpu/src/mip_bias.rs`, called where `descriptor/host.rs` writes a console sampler (`CreateSamplerX`). With `LEONIDA_MIP_BIAS=1` (or `auto`) the title's own bias gets NVIDIA's DLSS-guide offset `log2(render width / output width) - 1` added, from the widths of the last DLSS upscale (`dlss::record` reports them; nothing is added before one, or with the stretch). `auto-soft` leaves out the minus 1; another number is added as it is (`1.0` for +1). Comparison, min/max reduction, flat-LOD-range and point samplers keep the title's bias. Unset, empty or `0`: the descriptor is untouched (one `OnceLock` read). A descriptor is written once, so a sampler made before the first upscale keeps its bias. One INFO line says the mode, one summary after 30 s or 256 samplers gives a histogram of the title's own biases and what was changed or kept. Under `LEONIDA_AB` (diagnostics) the switch follows the phase. Not touched, as in Darner: static samplers, the plain D3D12 `CreateSampler` form, the F1 menu row. `d3d12/docs/findings.md` and the generated `switches.md` are updated. **Tests.** 8 unit tests in `mip_bias.rs` (parsing, the guide's numbers, clamping and NaN, the kept kinds, the mode that is on counting and stopping, the ratio from an upscale, the histogram). `cargo test -p leonida-gpu --locked`: 736 passed (Windows 11). `python -I tests/test_d3d12_switches.py` OK, `check_no_game_data.py` on the touched files clean. The `dlss` feature was not built (no SDK here): the call in `dlss.rs` sits after the successful evaluate and was read by the judge, not compiled. **In-game run required.** Not played, nothing measured. Run on Series S at 720 lines with DLSS (RTX card), start with `LEONIDA_MIP_BIAS=1`, 300 s without a device loss. Look at: the two log lines (`LEONIDA_MIP_BIAS: auto ... offset now -1.585` for 720 -> 1080, then the summary: how many samplers `changed`), fine texture detail (road markings, fences, text) sharper than without, shimmer or flicker in motion (then try `auto-soft`), and the frame time (a lower mip level costs memory bandwidth). An A/B by `LEONIDA_AB` only compares what it means to if the title makes its samplers again each phase; otherwise start twice. **AI-assisted.** Written with Claude Opus 5.5 (orchestrating session) and Claude Sonnet 5.5 (the agent that wrote the code). Reviewed by a distinct read-only Claude agent (code-reviewer): verdict ACCEPTED; its findings (statistics stop after the summary, a test for the mode that is on, the A/B caveat in the notes) are fixed in the head. **Credit.** Darner (https://github.com/tyr0nsur/Darner), `crates/darner-gpu/src/mip_bias.rs`, commit `1b45773` (Jesper-Andersson), GPL-3.0-or-later as this repository, credited in the module's header and in the commit message. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Under DLSS the scene is drawn below the output size, so the title's mip
levels fit the small picture. With LEONIDA_MIP_BIAS=1 (or auto) the
samplers made by CreateSamplerX get NVIDIA's DLSS-guide offset
log2(render width / output width) - 1 added to their own bias, from the
render and output widths of the last DLSS upscale (nothing before one, or
with the stretch). auto-soft leaves out the minus 1; another number is
added as it is. Comparison, min/max reduction, flat-LOD-range and point
samplers keep the title's bias. Unset, empty or 0: the descriptor is
untouched, at the cost of one OnceLock read.

Ported from the Darner fork's mip_bias.rs (tyr0nsur/Darner 1b45773,
GPL-3.0-or-later like this tree), fitted to this tree's dlss.rs and with
the 1 switch of our other variables. Static samplers and the plain
D3D12 CreateSampler form are not touched, as in Darner. Unit tests for
the parsing, the formula, the kept kinds and the histogram. Not played.

Credit: Darner (Jesper-Andersson, 1b45773).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
OreoFR referenced this pull request from a commit 2026-12-04 01:27:04 +00:00
OreoFR referenced this pull request from a commit 2026-12-04 01:27:04 +00:00
Sign in to join this conversation.
No description provided.