WIP: [pr-feature][rendering] Texture LOD bias for the title's samplers (DARNER_MIP_BIAS, off by default) #8
Loading…
Reference in a new issue
No description provided.
Delete branch "Jesper-A/Darner:up-mip-bias"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Contributor role (optional)
What it changes
Re-filed from CodeFloe #345 (the CodeFloe repo is gone; nothing was migrated). Same branch and commit.
Base: the branch is on
4db98e011, themaincommit it was cut from.mainis nowdd2f061d5. Not rebased (we rebase only if you ask). A text-only trial merge (git merge-tree --write-tree trustno1/main up-mip-bias) conflicts incrates/darner-gpu/src/host/menu.rs(the F1 menu table);README.mdandstreamline.rsmerge cleanly.Under DLSS the game draws a smaller picture than the display shows, so it picks texture mip levels for the small picture and textures can look soft. NVIDIA's DLSS guide asks the engine to lower the texture LOD bias to make up for it. This adds an optional bias. It is off by default, so nothing changes unless you turn it on.
DARNER_MIP_BIAS: empty or unset = the game's own bias (the default);auto;auto-soft; or a number such as-1.5.auto=log2(render width / display width) - 1, NVIDIA's formula (DLSS Programming Guide 3.5:DlssMipLevelBias = NativeBias + log2(Render XResolution / Display XResolution) - 1.0 + epsilon; we use epsilon = 0). It applies only while DLSS is on; without DLSS it adds 0. At 720p to 1080p / 1440p / 2160p that is -1.585 / -2.0 / -2.585. At DLAA (ratio 1) the literal formula gives -1.0, and that is whatautodoes there.auto-soft=log2(render/display)only, the bound the guide gives ifautoflickers (-0.585 / -1.0 / -1.585).descriptor/host.rs, theView::ConsoleSamplerarm), right aftersampler::console. The new code is incrates/darner-gpu/src/mip_bias.rs. The render ratio comes from a newstreamline::render_ratio()(two atomic loads: the last DLSS upscaling's render/output width, else the asked mode's scale). With the switch off, the cost is one atomic load per sampler.MinLOD >= MaxLOD; samplers without a mip filter arrive flat already, becausesampler::consolesetsMaxLODtoMinLODwhen the title's mip filter is none,crates/darner-gpu/src/sampler.rs:57), and point-filtered samplers (point minification and magnification, not anisotropic).docs/findings.mdentry, and unit tests.Precedents for adding a bias to the game's own: DXVK
d3d11.samplerLodBias(additive, range -2..1) and OptiScaler[Mipmap] MipmapBiasOverride(additive). Intel's XeSS guide useslog2(input/target)without the -1, which matches ourauto-soft. The formulas are the vendors', not ours.Not covered in this first step:
Spec dependence. Likely general: the fixed offsets only change D3D12 sampler descriptors and should behave the same on any GPU. May depend on our specs:
autoandauto-softneed DLSS (NVIDIA RTX); on other setups they add 0. Our expectation of the visual result comes from NVIDIA's guidance, and we only have an RTX 2070 SUPER with Series S + DLSS Performance. Untested elsewhere: other GPUs, Series X, DLSS modes other than Performance, other render sizes.No upstream issue covers this, so there is no
FixesorRefsline.How it was tested
1b45773b6(on main4db98e011; main has moved since, nowdd2f061d5, see the checklist).cargo clippy --workspace --all-targets --locked -- -D warnings -A clippy::unnecessary_lazy_evaluations: exit 0. Note the extra-A clippy::unnecessary_lazy_evaluations; the gate as upstream states it, without that flag, was not run.--all-features, same extra flag: exit 0.cargo testruns:mip_bias6 passed;host::menu38 passed, 1 ignored;sampler::5 passed.cargo xtask policy: 543 ok.cargo test -p darner-gpuin full andcargo test --workspace --locked. Results will be added here.auto(-1.0 by the literal formula, not looked at in game); any GPU other than the 2070 SUPER; the clippy gate without the-Aflag. There is no CI upstream; none of this is a CI result.Checklist
main. (The branch is directly on4db98e011; main is now atdd2f061d5; the branch stays on its base unless you ask for a rebase; a trial merge conflicts inhost/menu.rs, see Base.)docs/asset-policy.md. (Text only;cargo xtask policy543 ok.)Checked for overlap
host/menu.rs,host/panel.rsandhwrt.rs: same filemenu.rsas this change's F1 row, different change. Our own other F1 rows from earlier CodeFloe PRs (depth of field, aspect ratio and others; not migrated) also editmenu.rs; the depth of field one is re-filed as branchpr4-dof. Expect small merge conflicts in the F1 menu table.This change was made with AI assistance (Claude Code).
darner rig, F1 AUTO-DETECT row, per-start switches (DARNER_AUTO_SWITCHES, on by default, =0 turns it off) #25