feat(vk): add adaptive per-area simulated-turf controls #2093
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2093
Loading…
Reference in a new issue
No description provided.
Delete branch "erlo68/Longshot:experiment/grass-adaptive"
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
This is a dependent proposal, not a competing replacement for the existing vegetation and turf work:
main, controls how far short decorative blades used for details such as Kokiri tufts and moss remain visible.This proposal keeps #1877's original commit and author, then adds adaptive sizing and player-facing controls on top. It does not replace or duplicate #1382's Grass distance setting.
The renderer measures the two simulated-turf blade lists and four pool lists independently, keeps 25% aligned headroom, grows immediately, and shrinks from a 600-present quiet-window high-water mark. Capacity can fall below the game's stock counts and reaches zero when simulated turf is disabled.
RX_VK_SIM_TURF_ADAPTIVE=0restores fixed private sizing for A/B testing;RX_VK_SIM_TURF_POOLS=0disables the private-buffer path.The Graphics menu adds a six-row Simulated turf page: Use global multipliers, Fade start, Turf density, Minimum blades, Far power, and Reset current area. Its explanatory text identifies simulated turf as the broad field grass animated by the game's fluid simulation and points players to the separate Grass distance row for short decorative blades. Area edits persist in
sim_turf_settings.ini; global multipliers preserve each area's installed profile; Fade start 0 plus Minimum blades 0 provides a supported no-simulated-turf mode for lower-end systems. Changes apply live and Reset removes the current area's saved override.The review fixes carried into the current head
df6880b5make the private path compatible with independently patched programs. Each bound private producer mirrors a bounded stock-compatible record window back into the game's original storage after dispatch, with reverse lists end-aligned. An unpatched consumer therefore still sees the producer's records. The copy uses the exact private buffer bound for that dispatch, and retired buffers remain timeline-safe. If demand readback cannot be created, the recording fails closed to the game's buffers, logs the failure, and retries later instead of allowing an unmonitored private buffer to shrink.Review the capacity policy in
gpu/vk/sim_turf_capacity.h, buffer lifecycle and compatibility copy ingpu/vk/vk_draw.cpp, shader demand instrumentation ingpu/vk/eden/shader_recompiler/ir_opt/sim_turf_pool_pass.h, and settings/UI ingpu/vk/menu/sim_turf_settings.handgpu/vk/menu/sim_turf.cpp.Testing
Tested: Current head
df6880b5, rebased onto currentmain1101b612, on Windows 11 with an AMD Radeon RX 7900 XT and driver 26.11.2. The focused checks and 268-file Vulkan renderer build pass on that final code.git range-diffreports all 13 proposal commits patch-identical to the prior tested head. The exact-base full package, live stress cases, and main-versus-PR performance measurement below were made at8aa74983/9a6eb383; they are kept under their exact hashes rather than relabelled. Since that measurement, main added DualSense speaker/headphone audio, per-control reset/confirm UI, BC3-kept ASTC upload batching, and expanded randomized tests. None changes the simulated-turf shader instrumentation, buffer lifecycle, demand policy, or compatibility copies; the affected shared menu/settings fixtures pass on the combined code. The historical A/B remains evidence for the proposal's measured overhead at its exact base, not a claim about current-main absolute performance.The reviewer findings are addressed as follows:
tests/sim_turf_settings_test.cppnow usesVirtualAllocon Windows andmmap/mprotecton POSIX. The same guard-page behavior remains in both paths. A real Linux compile/run is still listed below rather than claimed.std::u8string/char8_tbefore constructingstd::filesystem::path; the fixture persists through a Unicodesim-turf-測試directory.RUN_ALL_ARGS = ["--cxx", "{cxx}"].mainbelow, including frame times and renderer-owned capacity.main1101b612; the full package and performance measurement retain their exact tested pair, base8aa74983and proposal9a6eb383.Focused checks passed on the final head:
On final head
df6880b5,scripts/dev.py vkcompiled 268 renderer files with zero failures, linkedlongshot_vk.dll, and passed symbol checks. The earlier exact-basescripts/dev.py packbuilt and linked bothlongshot.exeandlongshot_vk.dllagainstmain8aa74983with zero compile failures. The official A/B harness then made clean base/PR runtimes from those artifacts.tests/test_menu_modules.pycurrently fails two ReShade preset-name assertions on this branch and on untouched exact base8aa74983; the generated Graphics layout otherwise includes the Simulated turf page in the intended position. This base-reproduced mismatch is not counted as a proposal regression.Live Windows AMD coverage from the earlier stress pass remains applicable to the unchanged turf implementation:
Still to test:
mise run lintandmise run test, expecting the complete suite to pass (by hand).Measurements
Complete default path against exact main
Verdict: faster: +1.0% FPS (median 113.9 against 112.8), with every PR run above every
mainrun. The effect is small; the practical conclusion is that the complete default adaptive path and compatibility copies show no gameplay-performance regression.Setup: Windows 11, RX 7900 XT driver 26.11.2, saved Hyrule Field child view from
slot_02, window 2150x900, 67% of 3440x1440 (2294x960), Custom quality, VSync and frame generation off,HOS_FPS_MAX=1000.dev.py abran two interleaved 60-second pairs (A1 B1 A2 B2), each after at least 10 seconds and until no frame had waited for a shader or pipeline. Renderer, window, and menu settings matched; only the per-runHOS_CONTROLsocket identifier was allowed to differ.8aa749839a6eb383The measurement's installed Hyrule profile settled the PR to two 47,616-record blade lists, two 35,136-record main pools, and two 9,632-record secondary pools: 4.83 MiB of renderer-owned record capacity in total.
mainhas no renderer-owned simulated-turf buffers; both sides retain the game's original storage. During the PR runs telemetry reported zero retaken, absent, or lost mappings. Overall driver VRAM moves with streamed textures and is not presented as a stable feature delta; the direct record-capacity count is the isolated incremental memory cost.Continuous-monitor isolation
The earlier rollback-switch A/B isolates the continuous demand monitor from the private-buffer foundation. In the same saved Hyrule Field view, three interleaved 60-second runs per side measured 141.6 FPS / 7.03 ms median with
RX_VK_SIM_TURF_ADAPTIVE=0and 141.4 FPS / 7.04 ms with the adaptive default. The 0.2 FPS / 0.01 ms difference was below run-to-run variation. This secondary result supports keeping monitoring continuous; the exact-main comparison above covers the complete shipped path.Capacity stress results (renderer-owned record capacity, excluding allocation alignment):
Risks
The simulated-turf programs are identified by version-specific signatures and guest buffer addresses. Unexpected programs are not patched. The compatibility mirror preserves original-buffer records for independently unpatched consumers; if the monitor or private allocation is unavailable, the current recording uses the game's buffers and retries later.
RX_VK_SIM_TURF_POOLS=0disables all private simulated-turf buffers, andRX_VK_SIM_TURF_ADAPTIVE=0keeps private buffers at fixed sizing.The compatibility mirror adds bounded GPU buffer copies after producer dispatches. The exact-main A/B above exercises that default path and shows no measurable regression on the tested RX 7900 XT. Other GPU/driver combinations remain in Still to test.
Abrupt debug teleports or instant large setting changes can show one turf pop-in while a zero/small buffer grows. The zero-to-high stress test showed no flicker or oscillating partial state, and normal scene transitions are hidden by the game's black fade. The 25% headroom and 600-present high-water quiet window avoid resize churn during ordinary movement.
Changing simulated-turf settings creates
sim_turf_settings.ini. It stores renderer settings only and does not modify game saves. Reset current area removes that area's override.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.gpu/vk/switches.def.tests/that reads changed source is updated, not weakened.mainand here, for a change that shows on screen.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.Above 2x the short grass asks for more blades than the game's lists hold (143360 blades in d5a9475f2790532e, 138240 48-byte records in each of 3de6d86ec7e6720e's two pools): which patches get in changes from frame to frame, and whole patches of grass come and go in Hyrule Field, even standing still. An IR pass (ir_opt/grass_pool_pass.h) moves the records to storage buffers of the renderer's own (524288 blades, 393216 records in pool 2) and raises the caps in the producers and the mesh readers; the 64-byte headers stay in the game's buffers. 3de6's pool-2 writes are taken in both forms the program has (the record's address, and that address + 8). Every edit is checked first; a program that does not look as expected is left as it is and logged ("vk: grass: program ...: ... left as it is: <why>"). RX_VK_GRASS_POOLS=0 leaves the programs as they were. The renderer's buffers are found by the guest address the game's descriptor names (vk_draw.cpp grass_private_binding). A line every 600 frames, when it changed, counts the lookups over the run ("vk: grass: frame N: ..."), and the binding log stops at 64 lines. tests/test_grass_pools.py runs the pass on synthetic programs shaped as the game's (tests/grass_pools_ir.cpp): the three made larger, pool 2's records at the same place in the new buffer, eleven that differ a little left as they are, and vk_shader.cpp's grass_pools both ways (unset, and RX_VK_GRASS_POOLS=0). Co-Authored-By: Claude Opus 5.5 <[email protected]>Possibly related, for context:
Player-facing grass controls
The final proposal preserves the basic mod's six-row layout. The page switches between per-area values and global multipliers without adding a preset row. Fade start 0 plus Minimum blades 0 is the supported no-grass configuration.
Please include screenshot of the settigns!
Fixed screenshots
12272fd89df5dca2cb98Rebased the proposal onto main
d2f0e8dc(#1382) and force-updated the branch with lease tof5dca2cb. The release renderer/pack/runtime build passes on Windows AMD. The current-main live regression passed: zero simulated turf settled all six lists to zero; a same-frame jump to simulated-turf values 25.2/200/23/1.00 grew safely to measured demand with zero retaken, absent or lost mappings; restoring 8.0/200/12/1.00 shrank below stock after the quiet window; and a normal Hyrule Field-to-Market gate transition used the expected black fade, arrived complete and settled Market to zero capacity. The description now distinguishes these fluid/simulated-turf controls from #1382's separate short decorative-blade Grass distance row. Focused grass, menu-model, settings-table, handle-table and capacity checks pass. No screenshot comments were changed.f5dca2cb982f05b3b637Main advanced again after the live run, so the branch is now rebased onto
d76d202fat2f05b3b6. The rebase dropped ourc52adf31allocator-call fix because #2098 merged the identical fix upstream; range-diff shows every grass commit otherwise unchanged. On the final head, all focused grass/menu/settings-table/handle-table checks pass (126 saved keys, 149 module rows/headings), git diff --check passes, and the queued release renderer build compiled 266 files with zero failures and linked with symbols checked. The live Windows AMD results remain applicable to the unchanged grass patches. No screenshot comments were changed.2f05b3b637951b62d042This looks great!
@review
WIP: feat(vk): add adaptive per-area grass controlsto WIP: feat(vk): add adaptive per-area simulated-turf controlsRenamed this proposal from generic grass terminology to simulated turf throughout the player-facing page and its implementation. The page/header is now Simulated turf; internal files, namespaces, descriptors, renderer state, tests and rollback switches use sim_turf, while Grass distance remains the distinct #1382 short-decorative-blade path. Rebased onto current main
1bd93a48at951b62d0; range-diff reports all 11 proposal commits unchanged, the focused suite passes, and the queued release renderer build compiled 266 files with zero failures and linked successfully. The earlier screenshot comment now documents the superseded header; replacement menu screenshots are pending.@review
Recommendation: Request changes. The private-buffer path can leave producers and consumers using different buffers when one shader cannot be patched, and the settings test cannot build on Linux. Persistence also fails for some Windows user paths.
This adds per-area simulated-turf controls and adaptive renderer-owned buffers. The reported Windows AMD run shows live settings and substantial private-buffer savings, at the cost of new shader, buffer-lifetime and guest-memory complexity.
@fixwill do (5)gpu/vk/eden/shader_recompiler/ir_opt/sim_turf_pool_pass.h:476: Patching each program independently does not fail closed as a pipeline. (more on the line)tests/sim_turf_settings_test.cpp:4: This fixture unconditionally includes windows.h and uses VirtualAlloc, so the new settings check cannot compile on Linux. (more on the line)gpu/vk/menu/sim_turf_settings.h:175: Constructing a Windows filesystem path from the narrow UTF-8 options path uses the native narrow encoding. (more on the line)gpu/vk/vk_draw.cpp:6360: If the host-visible readback allocation fails, sampling silently stops for that recording and adaptive buffers can shrink or remain too small without ever growing to demand. (more on the line)tests/test_sim_turf_capacity_policy.py:18: This check lacks the runner's RUN_ALL_ARGS declaration, so the suite does not pass its selected CXX and the check defaults to clang++ even on a machine configured with another compiler. (more on the line)Before merging, for the author (2) (a run, a measurement or a decision; it doesn't hold the recommendation)
@fixor@rebasetry first).Checks: Still running:
CI / Conventional Commit title (pull_request),CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request),CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request),CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request),CI / Workflow lint (actionlint) (pull_request),CI / Website build and checks (pull_request),Guide screenshots / Guide images and local UI source review (pull_request),Third-party parts / As their notes say (pull_request),Third-party parts / The same as upstream (pull_request),Website / Website on Cloudflare (pull_request).More: does it help, other systems, switches, what was read
Does it help: Unproven against main. The reported fixed-private versus adaptive comparison reduced settled private capacity from 80.0 MiB to 8.61 MiB, with median FPS 141.6 versus 141.4 across three interleaved runs per side. It does not measure the complete change against main.
Other systems: The live run covers Windows on an RX 7900 XT; NVIDIA, Linux AMD and Intel, and Steam Deck runs are outstanding. Shader patching and buffer ownership affect compute and mesh stages across vendors. The settings path reads and writes guest resources and persists a separate file.
Switches: RX_VK_SIM_TURF_POOLS defaults on and disables the private path when set to 0. RX_VK_SIM_TURF_ADAPTIVE defaults on and retains stock private sizing when set to 0. Their defaults need the outstanding platform and against-main validation.
Reviewed:
951b62d042against1bd93a4890: Read the repository instructions, contributing guide, PR template, commit log, changed settings, capacity policy, test fixtures and renderer diff. Inspected shader pass and related call sites. The requested review checklist and sibling Tooling instructions were absent. Other changed code, generated documentation and the full surrounding renderer were not read in full; this limits the completeness of this review.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no builds, scripts or tests were run. The supplied CI checks are still running.
Overlaps and merge order: #1877 supplies the private-buffer foundation included here; the description identifies it as dependent work. #1382 is already merged and controls separate decorative blades.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -0,0 +473,4 @@/// else a line for the log: "made larger" or why it was left as it isinline std::string SimTurfPools(IR::Program& program, u64 key) {if (program.stage == Stage::Compute) {if (std::find(std::begin(kSimTurfBladeKeys), std::end(kSimTurfBladeKeys), key) != std::end(kSimTurfBladeKeys)) {L1: Patching each program independently does not fail closed as a pipeline. For example, if a pool producer does not match and stays on the game's buffers but its blade producer was patched, it reads the game's blade records while the producer writes the private list; similarly an unpatched mesh reader cannot see a patched pool producer's records. Coordinate enablement across producers and consumers, or retain compatible writes until all participating programs are known to be supported.
@ -0,0 +172,4 @@std::filesystem::path config_path() {const std::string options = options_path();return options.empty() ? std::filesystem::path{} : std::filesystem::path(options).parent_path() / "sim_turf_settings.ini";L3: Constructing a Windows filesystem path from the narrow UTF-8 options path uses the native narrow encoding. A user directory containing characters outside that encoding can produce the wrong path or throw, preventing settings from loading or saving. Convert the UTF-8 path to a native wide path using the project's path helpers.
@ -6162,0 +6357,4 @@}r.sim_turf_samples.clear();}if (!r.sim_turf_readback) {L4: If the host-visible readback allocation fails, sampling silently stops for that recording and adaptive buffers can shrink or remain too small without ever growing to demand. Log and disable adaptive shrinking, or otherwise retain a safe capacity and retry until monitoring is available.
@ -0,0 +1,159 @@// SPDX-License-Identifier: GPL-3.0-or-later// The per-area simulated-turf settings over a sparse stand-in for the guest window, without Vulkan or the game.#define NOMINMAX#include <windows.h>L2: This fixture unconditionally includes windows.h and uses VirtualAlloc, so the new settings check cannot compile on Linux. Provide a Linux allocation implementation and run the same behavior checks on both supported platforms.
@ -0,0 +15,4 @@def main() -> None:parser = argparse.ArgumentParser(description=__doc__)parser.add_argument("--cxx", default="clang++")L5 (minor): This check lacks the runner's RUN_ALL_ARGS declaration, so the suite does not pass its selected CXX and the check defaults to clang++ even on a machine configured with another compiler. Declare RUN_ALL_ARGS as the other new C++ checks do.
@fix
I didn't fix this pull request: it doesn't allow edits from maintainers (the author can turn on Allow edits from maintainers).
Automated fix by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
951b62d0421f30fb71dfRebased onto current
mainc7bd8f80and force-updated the PR to1f30fb71with the requested fixes:VirtualAllocon Windows andmmap/mprotecton POSIX.char8_t; persistence is exercised in a Unicode directory.L6 now has a complete
mainversus PR measurement from the newest saved Hyrule Field position (slot_02), using the officialdev.py abharness: two interleaved 60-second pairs at fixed 67% render resolution, with matching renderer/window/menu settings. The accepted verdict is no difference shown: 105.3 versus 107.3 median FPS (+1.8%, within spread), 9.37 versus 9.28 ms median frame time, and 12.36 versus 10.59 ms p99. The PR settled to 4.80 MiB of renderer-owned turf records in that view and reported zero retaken, absent, or lost mappings.The Graphics page also now explains that Simulated turf is the broad field grass animated by the fluid simulation and distinguishes it from the separate short-blade Grass distance row.
Focused settings/capacity/pool/menu/Vulkan checks,
scripts/dev.py vk, and an exact-base fullscripts/dev.py packpass with zero compile failures. Actual Linux execution, NVIDIA/Steam Deck coverage, the completemisesuite, and replacement screenshots remain explicit WIP items.@review
1f30fb71df9a6eb38305Rebased onto current
main8aa74983and force-updated the PR to9a6eb383, preserving both upstream's new guest-page-table/input-recording work and this proposal's simulated-turf paths.Post-rebase verification:
scripts/dev.py vk: 267 renderer files, zero failures, linked DLL, symbols checked.mainand the PR: both binaries compile and link with zero failures.tests/test_menu_modules.pyhas two ReShade preset-name assertions that fail identically on untouchedmain8aa74983; the generated Graphics layout includes the Simulated turf page correctly.I repeated the official complete-path A/B from the newest saved Hyrule Field
slot_02, with two interleaved 60-second pairs, fixed 67% render resolution, VSync/frame generation off, and matching settings. The harness verdict is faster: +1.0% FPS, with every PR run above every main run:8aa749839a6eb383The practical conclusion is no performance regression from continuous adaptive monitoring plus compatibility copies. The installed Hyrule profile settled to two 47,616-record blade lists, two 35,136-record main pools, and two 9,632-record secondary pools (4.83 MiB total renderer-owned record capacity), with zero retaken, absent, or lost mappings.
The description now carries the current hashes, exact-main measurements, build results, and the current-main-only ReShade test mismatch. Linux execution, NVIDIA/Steam Deck coverage, the full
misesuite, and author-approved replacement screenshots remain explicit WIP items.@review
9a6eb38305183b96b562183b96b562df6880b55aRebased onto current
main1101b612and force-updated the PR todf6880b5.git range-diffreports all 13 proposal commits patch-identical to the prior head.Current main now includes DualSense controller-speaker/headphone audio, per-control reset/confirm UI, BC3-kept ASTC upload batching, and expanded randomized tests. The shared menu changes combine cleanly: Controller speaker remains under Audio and Simulated turf under Graphics, with the correct page labels, navigation, independent scroll state, and test-fixture coverage.
Post-rebase verification:
scripts/dev.py vk: 268 renderer files, zero failures, linked DLL, symbols checked.8aa74983/9a6eb383: both binaries compile and link with zero failures.tests/test_menu_modules.pyhas two ReShade preset-name assertions that fail identically on untouchedmain8aa74983; the generated Graphics layout includes the Simulated turf page correctly.The official complete-path A/B used the newest saved Hyrule Field
slot_02, with two interleaved 60-second pairs, fixed 67% render resolution, VSync/frame generation off, and matching settings. It remains labelled with the exact tested pair8aa74983/9a6eb383. The intervening changes do not alter the simulated-turf shader instrumentation, buffer lifecycle, demand policy, or compatibility copies, so the result remains exact-base evidence of the proposal's overhead; it is not relabelled as current-main absolute performance. The harness verdict was faster: +1.0% FPS, with every PR run above every main run:8aa749839a6eb383The practical conclusion is no performance regression from continuous adaptive monitoring plus compatibility copies. The installed Hyrule profile settled to two 47,616-record blade lists, two 35,136-record main pools, and two 9,632-record secondary pools (4.83 MiB total renderer-owned record capacity), with zero retaken, absent, or lost mappings.
The description now separates final-head verification from the exact-hash performance evidence. Linux execution, NVIDIA/Steam Deck coverage, the full
misesuite, and author-approved replacement screenshots remain explicit WIP items.@review
WIP: feat(vk): add adaptive per-area simulated-turf controlsto feat(vk): add adaptive per-area simulated-turf controls