WIP: feat(options): Ground detail distance, so the pebbles and small flowers stop popping in 35 m away #1784
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1784
Loading…
Reference in a new issue
No description provided.
Delete branch "Jiro113/Longshot:fix/gpu-culled-props-popin"
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?
Type: feat · Risk: low · Tested on: Windows 11, RTX 4090 · Needs: an 8 or 12 GB card (Auto = 200% there), any OS
TL;DR
The small pebbles and white flowers along the paths stop being drawn about 35 m from the camera, so they pop in a few
steps ahead as Link walks. That distance is the game's own, written each frame by its foliage setup. This PR adds a
Graphics row, Ground detail distance, that draws them up to four times as far, shadows included. Its default, Auto,
follows the card's memory like Shadow resolution. On an RTX 4090 the frame time doesn't move. A new game-free test fails
on main and passes here, and I watched the pebbles in Hyrule Field at each setting.
Breakdown
Why
On the path out of the Kokiri Forest and across Hyrule Field, pebbles and small white flowers pop in a few steps ahead of
Link: the game stops drawing them about 35 m away. It's the game's own choice, not a Longshot bug, but on a PC with
memory and GPU time to spare it can draw them farther, as it already does for shadows (Shadow resolution) and the
draw distance sliders asked for in #205. PR #227's sliders (Object detail, Foliage distance) don't reach this family: it
is culled on the GPU by a distance of its own (below).
See #205. See #227.
What changed
The game's foliage setup writes a per-frame block for its GPU culling. Its word 37 is the pebble family's cut, and word
118 is the same distance squared that the task and mesh stages use. A hook after that write scales word 37 by the
setting and word 118 by its square, so the fade keeps its shape and moves out. The row is read each frame, so a change
applies at once.
nx2/oot_scatter.pyinstalls the hook at the store of word 118 in the foliage setup, for this game build only,after checking the instructions around it;
nx2/lift.pycalls it with the other standalone hooks.host/oot_scatter.chos_oot_scatter()readsrx_option(HOS_OPT_GROUND_DETAIL)and scales the two words onthe stack; 100 (or anything outside 101 to 400) leaves them alone, as does a value that isn't a distance (0 when the fade is off).
opts.ground_detail, iniground_detail_distance): Auto, then 100% to400% in steps of 50.
menu_ground_detail()ingpu/vk/vk_menu.cppresolves Auto by the memory tier, asmenu_shadow_res()does: 100% on Minimum and Low, 200% on Balanced and High, 400% on Ultra. The Quality presets putit back on Auto (
apply_preset).HOS_OPT_GROUND_DETAIL = 76ingpu/vk/vk_api.h(an option id, not the interface:no
MKWVK_API_VERSIONchange);vk_replay.cppanswers it.gpu/vk/menu_i18n.h.docs/development.md's options file rows.tests/test_oot_scatter.pycompiles the host helper against an authored stack block and checks the install,the menu wiring and Auto's tiers.
How the cut was found: the pebbles and small flowers are mesh programs
8e2f7af4245747ef(colour),51183fe750d5d0c8(the same objects, a second pass) and
28dd2baa17ba10e1(the sun's three cascades), fed by indirect arguments thatcompute
b612216258832b9cwrites. Scaling the scene buffer's words in the replay showed b612 cuts this kind at word 37(39.4 m at the default field of view), and the task stage again at sqrt(word 118 / word 119), the same distance. Moving
both (x4, x16) took the colour pass from 1760 to 3360 mesh groups and the shadow pass from 3904 to 6464; moving either
alone did not. The game computes word 37 as 35 m times the lens factor, from a fade of 25 to 35 m in its data: a
constant, so this is the game's design rather than a Longshot fault.
Measurements
Verdict: no cost measured. At 100% the branch matches main (GPU 8.01 against 8.02 ms a frame), and Auto (400% on
this card) is within the spread of the runs (7.90 ms). The scene is CPU-bound at about 91 to 95 fps on both sides.
Hardware: Windows 11 Home 10.0.26300, RTX 4090 24 GB, NVIDIA 621.24, Core i9-13900K, 64 GB RAM
Scene: Hyrule Field on the path (position 119.09, 161.4, 198.91), standing still, camera untouched; output 2560x1440
with ultrawide on, presented 5120x1440 SDR; DLSS 3414x960 to 5120x1440, preset K; frame generation off;
HOS_FPS_MAX=1000; Quality preset Auto (Ultra tier, memory_budget 5)Method: packs over the same main base, one for main @
9ea65c7band one for this PR @ 5c0228fe; job queue in timingmode; a warm-up run of each, then 3 interleaved rounds of main, 100%, Auto; each run 45 s in play after 900 presents,
the last 30 log samples (
vk: GPU timelines, 0.1 ms steps), mean GPU time and median fps; the median of the 3 runsHow to reproduce: a save on that path,
ground_detail_distance=1(100%) or=0(Auto) inlongshot_options.ini9ea65c7bAn earlier series on this branch at 100%, 200% and 400% (same spot, same settings) gave 8.01, 8.00 and 8.08 ms. With
RX_VK_PASS_TIMING=1the pebble passes take about 0.1 ms each at 400%. The build, loading, memory and the launchercan't be affected beyond a few small draws: one hook of a few instructions, no new image or buffer.
The PR was rebased onto main
3653c9c5after these runs; its diff is the same (the translation tables were merged againby hand, entry for entry). The 10 commits in between are the Mods tab and ExeFS patches (#134), vibration (#405), the
FSR frame generation HUD (#1755), build speed (#756), TLS (#755), the Tracy build, the release channels and the window
icon: they touch
nx2/build.py,nx2/exefs_patches.py,nx2/make_game.py, the host's mods, cheats and pad code,vk_menu.cppandvk_framegen.cpp, and nothing in the foliage setup or the passes these objects draw in. The rebasedcommits, run again at the same spot (main @
3653c9c5against this PR @ d5fadaa0 on Auto), draw exactly the counts ofthe timed runs (Testing), so the timing still holds; it was not re-timed. It was then rebased once more, onto main
a433db32, over two commits that don't reach these passes either (#1747, the amiibo model number in NFC; #1778, therenhdrum DLL in the release build); the diff is unchanged. The last commit,
f162d3fb, only changes which part of thebug report lists this row (Testing); main @
a433db32against this PR @f162d3fbon Auto, at the same spot, draw thesame counts again (colour 1760 against 3360 mesh groups, shadow 2496 / 3904 against 23520 / 6464).
Flags and settings
One menu row and its ini key.
ground_detail_distance)Testing
Tested: on Windows 11, RTX 4090, NVIDIA 621.24, in Hyrule Field on the path: at 100% the pebble passes draw exactly
main's mesh groups; at 400% the colour pass goes from 1760 to 3360 mesh groups and the shadow pass from 3904 to 6464,
the same on two runs each, and the pebbles and flowers far ahead stay drawn as Link walks. Auto resolved to 400% here
(the log's
auto_tier=5), the timing series above, no device lost, NGX started in every run.After the rebase, main @
3653c9c5(longshot v3.0.0-rc.8-62-g3653c9c57) against this PR @ d5fadaa0 (rc.8-65-gd5fadaa0b)on Auto, same spot, one run each, from one base:
python -I -B tests/run_all.py: 701 passed, 46 failed, 120 skipped on this branch atf162d3fb(rebased ona433db32;the 45 files below and
test_longshot_ctl.py, see below); main3653c9c5on the same PC: 700 passed, the same 45 files failed (this PC's Windows failures, e.g.test_tested_configurations.py's CRLFpipe check). One of them,
test_bug_report_defaults.py's auto-profile case, already fails on main with "Auto-controlledshadow_res missing" (it did on main @
9ea65c7btoo; I believe since #773, which made Shadow resolution follow Auto): itwants every row
apply_presetsets in the report's "depends on this PC" part. This row is one of them, soreport_default_depends_on_pc()now puts it there while a Quality preset is on (the preset leaves it on Auto, whichthe memory tier resolves); on Custom its default is plain Auto and a moved value reads "(default: Auto)". The case's
output on this branch is now main's, line for line: only "shadow_res missing", whose fix is a PR of its own.
test_longshot_ctl.pyfailed once in a full run while a Linux build ran beside it (a temporary file still held,WinError 32) and passed twice alone; it doesn't read the files this PR changes.
Linux, in a WSL 2 Ubuntu 22.04 with
scripts/linux/Dockerfile's packages, atf162d3fb: the renderer alone(
RX_VK_ONLY=1 nx2/build.py --standalone, 0 failed) andhost/oot_scatter.cwith tools.lock's clang 23 and its sysrootand with gcc 11, both with the host's flags and
-Wall -Wextra -Werror;test_oot_scatter.pypasses there andtest_bug_report_defaults.pyfails only on shadow_res, as on Windows. No run in the game on Linux.tests/test_oot_scatter.pyfails on main ("nx2/oot_scatter.py is missing ...") and catches a wrong tier mapping and amissing preset reset.
Screenshots
Hyrule Field on the path (position 119.09, 161.4, 198.91, camera untouched), 5120x1440, the Measurements settings, one
run each from one base (also in this comment).
Why they barely differ. Standing still, the two frames differ only where grass, leaves, mist, Link and Navi move
from one run to the next. The pebbles and small flowers this row adds lie 35 to 140 m out: most are behind the rise in
front of Link, and the rest are a few pixels each at that distance. 100% against 400% switched live in one run, from 10
camera views, gave the same: no still where the difference reads. What the row fixes is the pop-in as Link walks, which
a still can't show; the draw counts above (colour 1760 against 3360 mesh groups, shadow 3904 against 6464) are what
show it ran.
Whole frame (JPEG, quality 92):
The field beyond the rise, a full-resolution crop (x 1000-3600, y 500-860, PNG):
Not tested: other regions (Kakariko, Lon Lon Ranch, Death Mountain, Lake Hylia) beyond Hyrule Field; a run in the game on Linux; AMD and
Intel cards.
Must be tested:
detail distance between 100% and Auto, expecting the GPU time to move by a small fraction of a millisecond
(Test Farm: @Beanstalk an 8-12 GB card, Ground detail distance 100% against Auto at the Hyrule Field path).
Risks
What could break: a game update that moves the foliage setup: the hook checks the build id and the instructions
around its site, and installs nothing otherwise (the game's distance). More pebbles in the cascades cost a little on
small cards, which is why Auto keeps 100% on Minimum and Low.
Turning it off: the row at 100% (
ground_detail_distance=1).Compatibility: the options file gains
ground_detail_distance(absent: Auto); the Quality presets now also set thisrow back to Auto. No cache, save or ABI change.
Checklist
Everyone
type(scope): description) of the status line's type.can't be run by hand is in Testing's Not testable by hand, with why.
in Risks.
main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.Screenshots; a still barely shows this change, said there)
docs/tested/for each new measured run (format indocs/tested-configurations.md).mainand passing here.tests/that reads changed source updated in this PR, not weakened.🤖 Generated with Claude Code
Tested in game: RTX 4090, NVIDIA 621.24, Windows 11: Hyrule Field, on the path out of the forest. At 100% the pebble passes draw main's counts; on Auto (400% here) the pebbles and small flowers far ahead stay drawn as Link walks, shadows included (colour pass 1760 -> 3360 mesh groups, shadow pass 3904 -> 6464, rebased build checked again). No device lost, DLSS on, no visible cost: GPU time 8.02 ms on main, 7.90 ms on Auto.
Screenshots, Hyrule Field on the path (position 119.09, 161.4, 198.91, camera untouched), 5120x1440, same settings as
Measurements, one run each from one base.
Why they barely differ. Standing still, the frames differ only where grass, leaves, mist, Link and Navi move from
one run to the next. The pebbles and small flowers this row adds are 35 to 140 m out: most sit behind the rise in front
of Link, and the rest are a few pixels each at this distance. What the row fixes is the pop-in as Link walks, which a
still can't show; the draw counts in the description's Testing (colour 1760 against 3360 mesh groups, shadow 3904
against 6464) are what shows it ran.
Whole frame (JPEG, quality 92):
The field beyond the rise, a full-resolution crop (x 1000-3600, y 500-860, PNG):
Pushed
f162d3fb(rebased on maina433db32): the bug report now lists Ground detail distance with this PC's settings while a Quality preset is on, so test_bug_report_defaults' auto-profile case prints main's output line for line (only its shadow_res failure, already on main, is left). main @a433db32against this PR @f162d3fbon Auto draw the same counts as before. Built and checked on Linux (WSL 2 Ubuntu 22.04: the renderer alone, host/oot_scatter.c with clang 23 and gcc 11 under -Werror, test_oot_scatter passes). Description: Testing gains a Screenshots part (the pictures of the previous comment) and why a still barely shows this change; the Screenshots, check and Linux boxes are ticked.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.