fix(vk): Grass distance reaches the short grass in Zora's Domain too, so its patches no longer pop in at 30 m #2929
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2929
Loading…
Reference in a new issue
No description provided.
Delete branch "cuecuemoar/Longshot:fix/grass-distance-culling-radius"
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?
Summary
Above Game's, Grass distance makes the short grass on Zora's Domain's terraces pop in: a terrace across the room
stays bare until Link is a few steps closer, then a whole patch appears at once. At Game's the same grass dithers in, as
the game intends.
Why: in Kokiri Forest and Hyrule Field the short blades' patches are picked around Link by
383a566958350efe, andits scene buffer's word 75, the patch radius, is what #1382 scales. In Zora's Domain
383adoesn't run: the game's GPUculling,
b612216258832b9c, hands the blades their patches, within the same word 75 of the same scene buffer(30 m there). The row left
b612's copy alone and only moved the blades' fade (words 46 and 47 of43ec86f35fd937b9and
8a8304edb7bdf4bf) outward, so above Game's the fade ran past the 30 m radius and the radius's edge showed. Thisscales word 75 for
b612as for383a. Game's changes nothing.To see it on main: adult Zora's Domain, Grass distance 4x, walk toward a grassy terrace that is more than about 30 m
from Link: it is bare, then covered all at once a few steps on. At Game's it fades in instead.
How the word was found:
RX_VK_DRAW_STATSandRX_VK_SKIP_FILEat the entrance's stair top gave the bladeprograms and the program writing their indirect arguments (
b612). A local debug build (not part of this PR) thenscaled words of
b612's c3 copy one at a time, with the blade programs' task groups as the measure: only word 75 movedthem (24,288 to 43,488 at x2); words 36, 67, 71, 77, 94, 96, 98, 100, 102, 124 and 127 to 133 did nothing to the
blades, and word 37 (#1784's pebble cut) moved only the pebbles (3,328 to 5,088), which shows the copy reaches
b612.Pulling word 75 to 15 m made the terrace across the pool go bare at a hard edge: the pop-in, on demand.
Read first:
gpu/vk/grass_distance.h(grass_words),tests/grass_distance_test.cpp.See #1382 (the row). See #1784 (the pebble kind's own cut, the same scene buffer's words 37 and 118). See #1877 (larger
grass lists, closed: the overflow this must not bring back, below).
Testing
Tested: Windows 10 (build 19045), RTX 4090, NVIDIA 617.42. A base of main @
018dd2efand this PR's pack over it(the renderer alone, the head
c3f66749), and before the rebase the same on main @e6a71a1d(1a81d337, the same diff).Adult Zora's Domain, the entrance's stair top (6.66, 102.24, -20.86), the save loaded headless, Grass distance changed
live; the blade programs' indirect arguments (
43ec86f35fd937b9, patch groups) fromRX_VK_DRAW_STATS:018dd2ef: blade patch groupsc3f66749: blade patch groupse6a71a1d/ this PR @ 1a81d337and the log says
vk: Grass distance 2x: program b612216258832b9c word 75 30 -> 60. At the reporter's own terrace, byhand: still to come (see Still to test; an earlier hand run is not counted, its settings file had left Grass distance at
Game's).
RX_VK_FORCE_MESH_FALLBACK=1, the RADV and Steam Deck path) at 4x, same spot: 1,335 patchgroups, the blade program's 744,405 vertices (248,135 primitives), under half of the 1.52M records #2121's area holds
for it; no white or missing blades (0.00 % near-white pixels in the lower half, as with mesh shaders).
a2dc5385with the same word scaled by the debug build at 4x, two frames each side: KokiriForest: no program changes. Hyrule Field (where
b612hands out some of the short blades too): only the four bladeprograms change (+25 % patch groups), simulated turf, pebbles and everything else stay inside frame-to-frame noise.
scaled as without (median 386 against 377 pixels); the patch count is the same from one frame to the next. It stops
growing where the area runs out of grass, at a different count in different places (1,360 at the stair top, ~1,670 at
the entrance), not at a list's size.
longshot.exeis the same file inboth, the PR changes
longshot_vk.dllalone) the game crashed in adult Lost Woods while the save loaded, before anyGrass distance change, where this PR's code changes nothing: one is #2442's (guest return
0x83331040, which #1709'sruns also saw on main, 1 launch in 13), the other a null write in the game's code at guest return
0x833316e8, in thesame place. Neither run was measured.
tests/test_grass_distance.pyfails on main @018dd2ef(program b612216258832b9c word 75 at 4x: 12, expected 48) and passes here, with g++ 11 and clang 23.1.5; with the fix's case taken out it fails again. The wholesuite on Linux (WSL, Ubuntu 22.04,
--strict), main against this PR: 821 passed, 91 failed, 10 skipped on both main @018dd2efandc3f66749, the same 91 files (this WSL environment's; list below; before the rebase, 86 one6a71a1dand 1a81d337 alike). The renderer builds on Linux (and, in thepack, on Windows with llvm-mingw) at the head.
Still to test:
the same spot, expecting bare on main and covered here (by hand, the reporter).
short grass there from afar, no white or flickering blades, no patch coming and going (@Beanstalk).
Measurements
Verdict: costs 0.3 ms of GPU time a frame at 4x where it acts: 5.60 against 5.90 ms (+5 %), every run of this PR
above every run of main; fps 120.2 against 117.6 (-2 %; the frame waits on the render thread, 8.4 ms, not the GPU). That
is the short grass drawn out to 4x its radius here (blade patch groups 730 against 1,329). At Game's nothing changes.
Setup: Windows 10 (build 19045), RTX 4090, NVIDIA 617.42, i9-13900K (32 threads), 32 GB. A base of main @
e6a71a1dandthis PR's pack over it (built from 1a81d337, the same diff as the head). Adult Zora's Domain, the entrance's stair top
(within 0.3 m of (6.66, 102.24, -20.86), facing the room), headless, 2560x1440 output; the rows set through the control
bridge and read back before measuring: Grass distance 4x, Frame rate cap Uncapped, Render resolution 67 %, V-Sync Off,
Frame generation Off, the rest at their defaults (no upscaler SDK in these builds). Each run through the job queue in
timing mode, 20 s after arriving, then 60 s measured: the median of the
vk: GPU timelines (one every 120 presents) andof the fps lines. 4 interleaved pairs, main first.
e6a71a1dc3f66749)43ec86f35fd937b9's indirect arguments)Measured before the rebase onto
018dd2ef. The numbers still hold: main's commits in between (#2899's and #2920'sdescriptor reuse, #2903's occlusion rasterizer, #2876's process priority, #2926's DLSS FG row) change CPU work and
none of the blade programs' GPU work, and at the stair top the blade patch groups are the same on both mains (above).
Not measured: Hyrule Field at 4x (where
b612hands out some of the blades, +25 % of them here), memory (no buffer isadded: the game's own lists hold them), loading.
Risks
b612's copy of word 75 (the game's memory and every other program's copy areleft as they are). Where
b612hands out the short blades (Zora's Domain, part of Hyrule Field), 2x to 4x now drawthem out to 2x to 4x its radius: more blades, the GPU time above.
are steady and stop where the grass runs out. The compute fallback's records area holds the blades at 4x here with
room to spare, but a denser area than this one is untested on it.
longshot_options.ini.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened.mainand here, for a change that shows on screen. Not yet: the reporter's two shots of main (the terrace bare, then covered a few steps on) are in a comment; the same spot on this PR is still to come.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.The 91 files failing in this WSL environment, on main @
018dd2efand on this PR aliketests/f2i_immediate,tests/global_load_16,tests/native_suatom,tests/test_blocks_at_start.py,tests/test_bug_report.py,tests/test_cloth_kernels.py,tests/test_cloth_loops.py,tests/test_cloth_sphere.py,tests/test_cloth_step12.py,tests/test_cloth_step8.py,tests/test_cloth_step9.py,tests/test_control_picture.py,tests/test_coop_spirv.py,tests/test_crash_record.py,tests/test_crt_options.py,tests/test_dead_targets_sweep.py,tests/test_default_point_size.py,tests/test_depth_sample_types.py,tests/test_dev_update.py,tests/test_dlss_actor.py,tests/test_dlssg_pace.py,tests/test_draw_parameters.py,tests/test_draw_stream_visibility.py,tests/test_framegen_hdr.py,tests/test_framegen_resources.py,tests/test_fsr3_math.py,tests/test_fsr3_shaders.py,tests/test_fsr3fi_hud_layer.py,tests/test_fsr3fi_hudless_colour.py,tests/test_fsr4_tune.py,tests/test_fsr_uniform_ownership.py,tests/test_game_boundary.py,tests/test_guest_holes.py,tests/test_image_arrays.py,tests/test_image_reaper_threads.py,tests/test_image_view_retry.py,tests/test_input_background.py,tests/test_keyboard_option.py,tests/test_late_fix_shaders.py,tests/test_lens_eye_pass.py,tests/test_lifter.py,tests/test_linux_pressure.py,tests/test_loaded_modules_drop.py,tests/test_log_levels.py,tests/test_lower_depbar.py,tests/test_lower_lds_after_sts.py,tests/test_lower_register_markers.py,tests/test_menu_keys.py,tests/test_menu_save_atomic.py,tests/test_mesh_fallback_capacity.py,tests/test_mesh_fallback_layout.py,tests/test_mesh_first_types.py,tests/test_mesh_unreachable_outputs.py,tests/test_native_suatom.py,tests/test_nonuniform_image_arrays.py,tests/test_oot_cloth.py,tests/test_oot_occ_raster.py,tests/test_oot_song_inventory.py,tests/test_option_ids.py,tests/test_perf_send.py,tests/test_pipeline_tour.py,tests/test_present_source_crop.py,tests/test_prof_clock.py,tests/test_program_answer_domains.py,tests/test_program_cache_cleanup.py,tests/test_program_cache_one_variant.py,tests/test_reactive_mask.py,tests/test_readback_timeout_reuse.py,tests/test_recording_admission.py,tests/test_reshade_fx.py,tests/test_scene_tonemap_pass.py,tests/test_screensaver.py,tests/test_sim_turf_pools.py,tests/test_spirv_struct_identity.py,tests/test_switch_table.py,tests/test_target_pool_cap.py,tests/test_target_retention.py,tests/test_temporal_present_bandwidth.py,tests/test_tex_desc_memo.py,tests/test_texture_phi_dominance.py,tests/test_thinlto_tls.py,tests/test_unsigned_image_types.py,tests/test_upscaler_round_trip.py,tests/test_vcore_video_acquire.py,tests/test_video_catchup.py,tests/test_video_hold_early.py,tests/test_video_input_limit.py,tests/test_vram_compact.py,tests/test_windows_display_startup.py,tests/test_windows_on_linux.py,tests/test_wmma16_spirv_val.py🤖 Generated with Claude Code
https://claude.ai/code/session_01VxeaZjejwdGWMMg5Zt4p48
Tested in game: Windows 10, RTX 4090, NVIDIA 617.42, main @
018dd2ef+ this PR: adult Zora's Domain at the entrance's stair top, Grass distance 2x and 4x now scale the culling program's patch radius (log: b612216258832b9c word 75 30 -> 60), blade patch groups 739 -> 1,329 at 4x (main stays at 739); no white blades on the compute fallback; GPU +0.3 ms a frame at 4x. By hand, the reporter at their own terrace (maina2dc5385+ this change): no more pop-in.Before, on main (the reporter's own shots, Grass distance 4x, adult Zora's Domain): from the top of the stairs the terrace across the room is bare (first), and a few steps on the same terrace is covered at once (second). The same spot on this PR is still to come.
Correction to the tested-in-game note above: the reporter's hand run is withdrawn. Its log shows the settings file it read had Grass distance at Game's (no "Grass distance Nx" line), where this PR changes nothing, so it can't show the fix. The in-game evidence that stands is the stair-top run: blade patch groups 739 -> 1,329 at 4x on main @
018dd2ef+ this PR, against 739 on main. The reporter's terrace at 4x, main and this PR from the same spot, is now in Still to test.@review
Recommendation: Approve. The code is ready: only testing is left. The patch increases the intended grass patch count, but the reported terrace pop-in has not yet been checked with the fix at the correct setting. The affected AMD and Steam Deck paths and the cost in Hyrule Field also need runs before merge. Recommend approval; not approved on the forge.
Grass distance above Game's also scales the culling radius used for short grass in Zora's Domain and part of Hyrule Field. That should prevent a hard patch boundary, at the cost of drawing more grass; the reported RTX 4090 run costs 0.3 ms of GPU time per frame at 4x.
Testing before merging (3) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/grass_distance.h:15: The target terrace has not been checked with the corrected setting. (more on the line) Do: Compare the same terrace on base and head at 4x, including a walk toward it and matching screenshots.gpu/vk/grass_distance.h:15: The additional patches have not been exercised on the affected RADV and Steam Deck paths. (more on the line) Do: Run the terrace and a dense grass area at 4x on RADV and Steam Deck, checking for missing, white or flickering grass and list capacity.gpu/vk/grass_distance.h:15: The frame-time cost in Hyrule Field is unmeasured, although this change increases its blade patch count too. (more on the line) Do: Compare base and head in a representative heavy Hyrule Field scene at 4x with interleaved runs, including frame times and 1% lows.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven for the reported visual bug: at the stair top, patch groups increased from 739 to 1,329 at 4x on the head comparison, but the reporter's terrace comparison is still outstanding. The game-free test reportedly fails on base and passes on head.
Other systems: The same culling program also affects some Hyrule Field blades. Mesh shaders and the compute fallback can consume the additional patches; the fallback was exercised on NVIDIA, but RADV and Steam Deck remain untested. Game's leaves the radius unchanged.
Switches: No switch added or removed. The existing RX_VK_GRASS_DISTANCE override, unset by default, now also affects this culling program at values above 1; the Grass distance row remains at Game's by default. Documentation was updated.
Reviewed:
c3f6674918against018dd2ef40: Read AGENTS.md, CONTRIBUTING.md, the PR template, standards, the full diff and both commits, grass_distance.h, grass_distance_test.cpp, test_grass_distance.py and the relevant menu module in full. Read the changed portions and descriptor callers in vk_draw.cpp; the rest of that large file and the surrounding documentation were not read in full. The requested docs/review-checklist.md and ../Tooling/AGENTS.md are absent. Reviewed the supplied run reports and comments; screenshots were not available locally.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run, as requested. The supplied CI checks are still running.
Overlaps and merge order: Not checked; network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -12,0 +12,4 @@// game's GPU culling, b612, which hands the blades their patches where 383a doesn't run, as in Zora's Domain, 30 m there.// Left at the game's for b612, a reach above 1x moved the blades' fade past it and whole patches popped in at its edge)case 0x383a566958350efeull:case 0xb612216258832b9cull: words[0] = 75, power[0] = 1; return 1;L1 (should fix): The target terrace has not been checked with the corrected setting.
When: At 4x, the patch count rises at the stair top, but that count alone does not show whether the reporter's terrace stops popping in or whether its appearance is correct.
Do: Compare the same terrace on base and head at 4x, including a walk toward it and matching screenshots.
L2 (should fix): The additional patches have not been exercised on the affected RADV and Steam Deck paths.
When: At 4x, denser grass can increase the game's patch lists and fallback output beyond the NVIDIA stair-top case; an overflow could make patches disappear or flicker.
Do: Run the terrace and a dense grass area at 4x on RADV and Steam Deck, checking for missing, white or flickering grass and list capacity.
L3 (should fix): The frame-time cost in Hyrule Field is unmeasured, although this change increases its blade patch count too.
When: The reported debug run found about 25% more blade patch groups there at 4x; the Zora's Domain GPU timing does not quantify the cost in that scene.
Do: Compare base and head in a representative heavy Hyrule Field scene at 4x with interleaved runs, including frame times and 1% lows.
WIP: fix(vk): Grass distance reaches the short grass in Zora's Domain too, so its patches no longer pop in at 30 mto fix(vk): Grass distance reaches the short grass in Zora's Domain too, so its patches no longer pop in at 30 mSame spot, by hand, the reporter's save, both on main @
018dd2efwith Grass distance 4x (each run's log checked: the settings file was config/settings.ini, "Grass distance 4x" lines on both, andb612216258832b9c word 75 30 -> 120on this PR only). First main, then this PR, then a zoom on the far ledges beside the mosaic pillar and the bridge stairs: bare on main, moss on this PR. The near tiers are covered on both.Merged while I was finishing the last item, so the description stays as it was; for the record, on BeanBot's three:
018dd2efand this PR, both at 4x with each log checked (b612216258832b9c word 75 30 -> 120on this PR only). The far ledges beside the mosaic pillar and the bridge stairs are bare on main and covered here.