feat(vk): populate simulated turf around Link #2772
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
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2772
Loading…
Reference in a new issue
No description provided.
Delete branch "erlo68/Longshot:feat/actor-centered-turf"
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
Graphics → Simulated turf → Turf renderer now switches live between Game's and Longshot. Game's is the default for a fresh profile and uses the original shaders and buffers. Choosing Longshot reveals the preset, Density, Reach, and Fade start controls. Switching back keeps those values for later.
Supersedes #2241.
How turf population changes
Previous algorithm. The game's camera-dependent blade producer fills a shared list. On main, Longshot grows the record buffers as demand rises. GPU workers reserve list slots as they run, so reservation order determines which patches keep their blades if the list fills. #2241 kept that producer and added controls for its per-area settings.
Longshot renderer. The Vulkan population pass counts patches in one-patch-wide rings around Link and reserves space from the nearest ring outward. Workers fill each ring in parallel. Blade placement spreads the first samples across each patch and fills the gaps as density increases. Counts scale with patch footprint. The camera frustum culls patches outside the view, and distance to Link drives the taper. Fade start sets where thinning begins as a percentage of Reach, and density falls to zero at Reach.
Each turf update uses one producer. Longshot skips the stock blade pass, and mesh draws use the shader and buffers for the pool that was actually written. The existing Vulkan stages still split the blades into two mesh pools and draw them. When a pool's demand exceeds the GPU's workgroup limit, Longshot steepens the fade automatically. The menu shows a warning triangle, the workgroup usage at activation, and the live adjusted usage.
Players can lower Density, shorten Reach, or start the fade earlier to reduce the turf workload. Off disables simulated turf within the Longshot renderer. The separate Grass distance setting controls short decorative grass.
For the population pass, start with
gpu/vk/host_shaders/turf_population.comp. For the live selector, dispatch, shader variants, and pool limits, seegpu/vk/menu/sim_turf.cpp,gpu/vk/vk_draw.cpp,gpu/vk/vk_shader.cpp, andgpu/vk/sim_turf_population.h.Testing
Tested: The rebased head
88ba875dbuilt on Windows and ran in Hyrule Field on Windows 11 with a Radeon RX 7900 XT and Adrenalin 26.11.2. Each fresh PR profile started with Game's. The runs switched live to Longshot Default, verified its preset values, and recorded live blade and workgroup counts. The pre-rebase smoke build2d9a3a3dswitched Game's → Longshot → Game's repeatedly in one process and retained its Longshot preset.We tested the Auto GPU ceiling under simulated lower-end GPU constraints by reducing the turf mesh workgroup limit to 1% of the hardware limit in the earlier playable build based on
04ff0706. The Linux renderer compiled and linked atc01242b5. Gameplay and timing runs were on Windows.The full game-free
mise run testsuite ran on the final rebased PR and pinned main with the same Windows toolchain.b6d274d788ba875dAll 226 PR failures reproduced on pinned main. They include missing tools under the strict Windows runner and the missing
LONGSHOT_LAUNCHER_STARTUPswitch-table row. Main's extra control-bridge lifecycle failure passed on a targeted rerun. The updated draw, live shader, and host-interface checks pass on the rebased head.Shared Windows suite failures (226)
Still to test:
Measurements
Verdict: Both PR modes fell within main's observed FPS spread. Game's measured 131.56 FPS (+0.26%) and Longshot Default measured 131.01 FPS (−0.15%) against 131.21 FPS on main.
Setup: Windows 11, Radeon RX 7900 XT, Adrenalin 26.11.2, Vulkan. The same saved Hyrule Field position and camera view in a 2150×900 window at 100% field of view, with uncapped FPS and frame generation off. Two 15-second samples per mode after pipeline warm-up. Each pair ran main, then the fresh PR profile in Game's, then Longshot Default after a live switch in that profile. Every sample had zero cold frames. The opt-in
HOS_CONTROLbridge was enabled in every run for the replay and settings checks. It stays off by default.b6d274d788ba875d88ba875dMain's stationary buffer peak logs supply its blade counts and derived workgroup counts. Longshot reports live counters at the end of each sample. The Game's column comes from the frame trace.
Simulated turf UI
The new captures show Game's and the Longshot controls. Game's and Longshot settings
The earlier captures show the range of preset visuals. Preset comparison GIF
Risks
The first live switch may pause briefly while the alternate turf shaders compile. Game's is the out-of-box renderer and can be reselected in play. Profiles without a saved renderer start on Game's and retain any saved Longshot slider values. The earlier
sim_turf_settings.inistays available to older builds.RX_VK_SIM_TURF_POOLS=0forces the original shaders and buffers for the run. The same path applies when the required push descriptors are unavailable. With the override unset, the menu selection controls the renderer.Checklist
Ready for review
main. The title is a Conventional Commit. Rebased ontob6d274d7.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched.When it applies
RX_VK_SIM_TURF_POOLSis documented ingpu/vk/switches.def. Fresh profiles use Game's, which measured within main's spread.tests/that reads changed source is updated, not weakened.MKWVK_API_VERSIONbumped to 56. The existing keyboard callback keeps its slot.mainand here, for a change that shows on screen.Assisted-by:in the commits.Ready to merge
main, measured again or a comment says why the numbers still hold.Tested in game: Windows, Radeon RX 7900 XT, Adrenalin 26.11.2. In the playable build based on 04ff0706, checked all five presets from the same position and camera and verified the Max workgroup warning. We tested Auto GPU ceiling under simulated lower-end GPU constraints by reducing the turf mesh workgroup limit to 1% of the hardware limit. The rebased PR head passed Windows packaging and focused checks. Its in-game check is pending.
Possibly related, for context:
Five turf presets from the same position and camera in the earlier playable build. The GIF cycles through Off, Low, Default, High and Max.
@review
Recommendation: Request changes. The population pass reads Link’s live position during replay, so it can use a position from a different frame, and several failure and recovery paths can leave turf missing or permanently reduced. The reviewed head also needs in-game and performance validation.
The change replaces camera-centered turf population with Link-centered, prioritized rings and adds density and reach presets. It offers more predictable placement, at the cost of new GPU passes, buffer growth, readback and automatic density adjustment.
Blocking (1): must change before merging.
gpu/vk/sim_turf_dispatch.h:160: The replay reads Link’s current live position instead of the position associated with the submitted work. (more on the line) Do: Capture the actor position with the submission and use that snapshot during replay.Should fix (3): not blocking, but worth doing before merging.
gpu/vk/vk_draw.cpp:12878: A population setup failure skips the pool producer instead of falling back to usable stock turf. (more on the line) Do: Choose the stock shader and buffer path when population setup cannot be used, including pipeline and allocation failures.gpu/vk/vk_draw.cpp:550: A failed buffer growth is never retried for the same demand. (more on the line) Do: Clear or roll back actor_growth_target on allocation failure, and retry growth with suitable throttling.gpu/vk/sim_turf_population.h:90: Automatic fade only increases until the player changes settings. (more on the line) Do: Reduce the fade gradually after sustained headroom, with hysteresis to avoid oscillation.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L1, L2, L3 and L4.Checks: Still running: 10 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven. The preset demonstration used an earlier playable build, not head
f15f0d8571, and no same-scene frame-time or 1% low comparisons against base694ae582are provided.Other systems: The new path affects Vulkan compute, mesh and compute-fallback rendering, GPU memory, replay timing and menu persistence. Windows AMD was exercised on an earlier build; the reviewed head, Linux, NVIDIA, Steam Deck and the stock-shader fallback still need runs.
Switches: RX_VK_SIM_TURF_POOLS remains on by default when push descriptors are available, but now selects actor-centered population; its default has not been measured. RX_VK_SIM_TURF_ADAPTIVE is removed and recorded as GONE; RX_VK_SIM_TURF_ACTOR is also recorded as GONE.
Reviewed:
f15f0d8571against694ae5820a: Read the repository rules, standards, PR template, commit and core population shader, dispatch, capacity, settings, menu and replay changes. Skimmed the generated SPIR-V header, documentation, scripts and test changes; the full change and every changed code file were not read in full.; nothing run (a code review).Checked and fine:
Testing: No code, tests or project scripts were run, as requested. CI is still running and the reported head in-game check is pending.
Overlaps and merge order: The PR says it supersedes Longshot#2241; no merge order is established here.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
@ -0,0 +157,4 @@const BufferRef header = gpu_buffer_bind(indirect - prefix, prefix + Shader::Optimization::kSimTurfListHeader, true);if (!header || header.offset % dev.props.limits.minStorageBufferOffsetAlignment) return false;float actor[3]{};const bool actor_valid = host->turf_actor_position && host->turf_actor_position(actor);L1 (blocking): The replay reads Link’s current live position instead of the position associated with the submitted work.
When: If the game advances or changes maps before a queued dispatch is replayed, the terrain and uniforms come from the earlier submission while this callback supplies the later actor position. Turf is populated around the wrong position or disappears when the live position is invalid.
Do: Capture the actor position with the submission and use that snapshot during replay.
@ -0,0 +87,4 @@void observe(uint32_t controls, uint32_t applied, uint64_t frame, uint32_t groups, uint32_t limit) {if (!controls || controls != key || applied != power || frame < changed_frame) return;if (groups > limit && power < 64) {L4 (should fix): Automatic fade only increases until the player changes settings.
When: After a dense location exceeds the workgroup limit, moving to a sparse location leaves the increased fade power in force even when usage is well below the limit. Turf remains thinner for the rest of the session despite available capacity.
Do: Reduce the fade gradually after sustained headroom, with hysteresis to avoid oscillation.
@ -562,0 +547,4 @@for (size_t i = 0; i < 3; ++i) {for (auto& list : sim_turf_private[samples[i].pool]) {if (list.addr != samples[i].addr || demand <= list.policy.target() || target <= list.actor_growth_target) continue;list.actor_growth_target = target;L3 (should fix): A failed buffer growth is never retried for the same demand.
When: The target is recorded in actor_growth_target before allocation. If sim_turf_resize fails, install_failed resets the policy target, but later samples at the same demand are rejected by the actor_growth_target check, leaving the list at its old capacity even after memory becomes available.
Do: Clear or roll back actor_growth_target on allocation failure, and retry growth with suitable throttling.
@ -12855,0 +12875,4 @@if (sim_turf_pools_on() && !p.stages.empty()) {const Stage& stage = p.stages[0];if (std::find(std::begin(kSimTurfPoolKeys), std::end(kSimTurfPoolKeys), p.key) != std::end(kSimTurfPoolKeys) &&(!indirect || !turf_populate(cmd, s, stage, indirect, actor_budget, population))) {L2 (should fix): A population setup failure skips the pool producer instead of falling back to usable stock turf.
When: If the population pipeline cannot be created or a required private buffer allocation or binding fails, turf_populate returns false and the producer dispatch is skipped. Subsequent draws receive no newly produced turf even though the device supports the original shaders.
Do: Choose the stock shader and buffer path when population setup cannot be used, including pipeline and allocation failures.
The Simulated turf settings page at Default and Max in the earlier playable build. Max shows both the workgroup usage at activation and the live auto-adjusted usage.
Default
Max
Following up on BeanBot’s review. L1 and L3 are fixed in
ee9b43f4. The Windows build and focused game-free checks passed.RX_VK_SIM_TURF_POOLS=0switch still selects stock turf from startup.@review
Recommendation: Approve. The population and buffer-growth fixes address the reported replay-position and retry defects. The reviewed head still needs in-game validation and measurements of the new default path before its visual behavior and cost are known. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.
The change populates turf around Link, prioritizes nearby patches and adds density and reach controls. The follow-up snapshots Link’s position at submission and retries failed buffer growth, but population setup failure still drops turf and automatic fade remains latched.
Should fix (2): not blocking, but worth doing before merging.
gpu/vk/vk_draw.cpp:12878: A population setup failure skips the pool producer instead of falling back to usable stock turf. When: If the population pipeline cannot be created or a required private buffer allocation or binding fails, turf_populate returns false and the producer dispatch is skipped. Subsequent draws receive no newly produced turf even though the device supports the original shaders. Do: Choose the stock shader and buffer path when population setup cannot be used, including pipeline and allocation failures.gpu/vk/sim_turf_population.h:90: Automatic fade only increases until the player changes settings. When: After a dense location exceeds the workgroup limit, moving to a sparse location leaves the increased fade power in force even when usage is well below the limit. Turf remains thinner for the rest of the session despite available capacity. Do: Reduce the fade gradually after sustained headroom, with hysteresis to avoid oscillation.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L2 and L4.Since the last review (on
f15f0d8571)Resolved: L1 (The replay reads Link’s current live position instead of the position associated with the…); L3 (A failed buffer growth is never retried for the same demand.)
Still open: L2 (A population setup failure skips the pool producer instead of falling back to usable stock…); L4 (Automatic fade only increases until the player changes settings.); L5 (The reviewed head has not been checked in game across the rendering paths it changes.); L6 (The cost of the new default population path is not measured.)
Checks: Still running: 10 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven. Presets and the workgroup warning were checked on an earlier Windows RX 7900 XT build; same-scene frame times and 1% lows against the pinned base are pending.
Other systems: The population and replay paths affect Windows and Linux, Vulkan devices and drivers, and stock-shader fallback. The PR reports Windows build and focused game-free checks, but head in-game, Linux, NVIDIA and fallback checks remain pending.
Switches: RX_VK_SIM_TURF_POOLS retains the stock fallback when set to 0; the population path is enabled by default where supported. The default’s performance and behavior across affected systems remain unmeasured.
Reviewed:
ee9b43f4cfagainst694ae5820a: Read AGENTS.md, CONTRIBUTING.md, sim_turf_capacity.h, sim_turf_population.h and sim_turf_dispatch.h; inspected the follow-up diff, relevant allocation and replay paths, and the changed turf tests. The full original diff, all changed files, referenced standards and architecture documents, and generated shader output were not read in full.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run. The author reports a Windows build and focused game-free checks passing; head in-game checks, broader hardware coverage and the full suite remain pending. CI is still running.
Overlaps and merge order: The PR says it supersedes #2241; no other overlap was established.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
@review
Recommendation: Approve. The current head produces actor-centered turf on the tested Windows AMD system, but the fallback, ceiling adjustment and other affected rendering systems still need in-game checks. The measured default is also 4.8% slower in the reported scene. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.
The change populates turf around Link, prioritizes nearby patches and adds density, reach and preset controls. It adds rendering work and measured a 0.44 ms increase in median frame time at the default settings in the reported scene.
Should fix (2): not blocking, but worth doing before merging.
gpu/vk/vk_draw.cpp:12878: A population setup failure skips the pool producer instead of falling back to usable stock turf. When: If the population pipeline cannot be created or a required private buffer allocation or binding fails, turf_populate returns false and the producer dispatch is skipped. Subsequent draws receive no newly produced turf even though the device supports the original shaders. Do: Choose the stock shader and buffer path when population setup cannot be used, including pipeline and allocation failures.gpu/vk/sim_turf_population.h:90: Automatic fade only increases until the player changes settings. When: After a dense location exceeds the workgroup limit, moving to a sparse location leaves the increased fade power in force even when usage is well below the limit. Turf remains thinner for the rest of the session despite available capacity. Do: Reduce the fade gradually after sustained headroom, with hysteresis to avoid oscillation.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L2 and L4.Since the last review (on
ee9b43f4cf)Resolved: L6 (The cost of the new default population path is not measured.)
Still open: L2 (A population setup failure skips the pool producer instead of falling back to usable stock…); L4 (Automatic fade only increases until the player changes settings.); L5 (The remaining rendering paths have not been checked in game on the current head.)
Checks: Still running: 10 checks.
Also noticed (2; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: The feature works in the reported Windows AMD check. The default performance cost is measured: median FPS fell from 119.0 to 113.3 and 1% low FPS fell from 107.3 to 102.9 across two interleaved 60-second runs per revision; the comparison used each revision's default turf settings.
Other systems: The new Vulkan population and mesh-limit paths can affect other GPU drivers, Linux and devices with lower workgroup limits. The current head was checked in game on Windows AMD; Linux compiled and linked, while NVIDIA and the current-head ceiling and stock fallback paths remain to be checked in game.
Switches: RX_VK_SIM_TURF_POOLS defaults on when push descriptors are available and selects original shaders and buffers when set to 0; its new default costs 4.8% in the reported scene and has not been validated across affected systems. RX_VK_SIM_TURF_ADAPTIVE is removed because actor turf sizes buffers from demand; RX_VK_SIM_TURF_ACTOR is recorded as removed because actor turf is now the default.
Reviewed:
d9a9b89c8eagainst694ae5820a: Read the repository rules and pull request template, the changes sinceee9b43f4, the population dispatch implementation and AutoFade policy, and the relevant dispatch and sample handling. Skimmed the overall change statistics and reported runs; the remaining changed files and full base diff were not read in full.; nothing run (a code review).Checked and fine:
Testing: No commands from the project or tests were run. The reported Windows and Linux builds passed; the reported game-free suite had the same 211 failures on the PR and pinned main.
Overlaps and merge order: The pull request says it supersedes #2241; merge this instead of #2241 if accepted.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
-4% FPS is a big jump, can we optimize this?
@HumanBean wrote in #2772 (comment):
That's probably due to the different default presets, I'll run a test with similar blade counts.
d9a9b89c8ec01242b5d0I reran the Castle Town drawbridge benchmark on main (
01d6878b) and the PR (c01242b5) at similar blade counts. Main settled at 9,643 blades. The PR produced 9,560 at Density 13, Reach 25, a difference of 0.9%.FPS was effectively the same at those settings. Main recorded 116.0 FPS and the PR recorded 115.8 FPS across two interleaved 60-second runs per build. The 0.2% difference was within the spread of the runs.
The PR's Default preset (Density 70, Reach 35) produced 62,923 blades in the same view, about 6.5 times main's count.
Ok, may have found an Issue. It's not culling out of frame blades. So with similar bladecounts in total, performance is equal to main, but visual density is much lower on PR.
I'll work on making it camera sensitive, taking into account all available aspect ratios and also make it FOV sensible. This should restore the same visuals with equal performance.
c01242b5d088ba875d2cRebased onto
b6d274d7and pushed88ba875d. Game's is the default. The Simulated turf selector now switches live to Longshot, and each turf update uses one producer.At the same Hyrule Field view, median FPS was 131.21 on main, 131.56 in Game's, and 131.01 in Longshot Default. Both PR modes fell within the observed spread. The full Windows
misesuite found 226 failures on the PR, all reproduced on pinned main. The description has the measurements, failure list, and verified checklist items.Simulated turf settings
Game's keeps the original turf and hides the Longshot controls.
Longshot reveals the presets, Density, Reach, and Fade start, with a live workgroup readout.
UI captures from build 2d9a3a3d.
@review
Recommendation: Approve. The new renderer works in the reported Windows AMD gameplay check, but its fallback and live ceiling adjustment still need verification, as do the NVIDIA and Linux paths. The stock fallback and automatic fade recovery also remain incomplete. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.
The change adds an optional actor-centered turf renderer with density, reach and fade controls, while retaining the game's renderer as the default. It adds shader variants and population logic in exchange for more control over turf.
Should fix (2): not blocking, but worth doing before merging.
gpu/vk/vk_draw.cpp:12878: A population setup failure skips the pool producer instead of falling back to usable stock turf. When: If the population pipeline cannot be created or a required private buffer allocation or binding fails, turf_populate returns false and the producer dispatch is skipped. Subsequent draws receive no newly produced turf even though the device supports the original shaders. Do: Choose the stock shader and buffer path when population setup cannot be used, including pipeline and allocation failures.gpu/vk/sim_turf_population.h:90: Automatic fade only increases until the player changes settings. When: After a dense location exceeds the workgroup limit, moving to a sparse location leaves the increased fade power in force even when usage is well below the limit. Turf remains thinner for the rest of the session despite available capacity. Do: Reduce the fade gradually after sustained headroom, with hysteresis to avoid oscillation.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L2 and L4.Since the last review (on
d9a9b89c8e)Still open: L2 (A population setup failure skips the pool producer instead of falling back to usable stock…); L4 (Automatic fade only increases until the player changes settings.); L5 (The remaining rendering paths have not been checked in game on the current head.)
Checks: Still running: 10 checks.
Also noticed (2; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: The feature is shown working on Windows AMD. In two samples of one Hyrule Field view, main measured 131.21 FPS, the PR's Game's mode 131.56 FPS, and Longshot Default 131.01 FPS; both differences were within the observed spread.
Other systems: The Vulkan population, mesh and live-switch paths can affect other GPU drivers and Linux. The current head has a Windows AMD gameplay check; NVIDIA and Linux gameplay checks remain outstanding.
Switches: RX_VK_SIM_TURF_POOLS defaults to enabled availability; setting it to 0 forces stock turf. Fresh profiles select Game's, with Longshot available through the menu.
Reviewed:
88ba875d2cagainstb6d274d779: Read the repository rules and pull request template, sim_turf_population.h, and the relevant dispatch and fallback code. Skimmed the diff, shader changes, replay changes, commit list and reported runs; the remaining changed files and full code paths were not read in full.; nothing run (a code review).Checked and fine:
Testing: No commands from the project were run. The author reports a current-head Windows AMD gameplay check and a Windows game-free suite comparison against main; the remaining rendering checks are listed in L5.
Overlaps and merge order: The description says this supersedes #2241.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
Thanks!
WIP: feat(vk): populate simulated turf around Linkto feat(vk): populate simulated turf around Link