perf(vk): cut Market 1536x864 GPU time 2.9% (-80 MB VRAM, +1.0% FPS) across GPUs by keeping stock simulated turf on game buffers #2328

Open
Jer9 wants to merge 1 commit from Jer9/Longshot:perf/vk-sim-turf-stock-passthrough into main
Contributor

Summary

Longshot's simulated-turf system keeps a private GPU copy of the game's grass buffers so it can grow them when dense grass overflows the Switch 2's stock buffer size (#2174). Previously, it allocated those private buffers (~28 MB) immediately at stock size and copied ~14.4 MB of grass data back into the game's buffers every single frame with a full-GPU barrier — even in areas with almost no grass (like cobblestone Market, 0–197 blades) or normal Hyrule Field (~17,000 blades, well under the 143,360-blade stock limit).

This PR lets simulated turf write directly into the game's own buffers whenever demand fits within stock capacity, eliminating the per-frame ~14.4 MB mirror copy, the full-GPU barrier, and the duplicate VRAM allocation game-wide (Hyrule Field, Market, Kokiri Forest, dungeons — every scene that uses simulated turf within stock capacity). If dense grass ever approaches the stock limit (>= 7/8 * stock), it seamlessly promotes to a larger private buffer just as before and retires it back to the game's buffer after 600 quiet frames.

Where this helps vs. where it doesn't:

  • What a player notices: Not directly visible by eye (+0.3% to +1.0% FPS is too small to feel without an FPS counter). Its real value is quiet, zero-downside efficiency — stopping ~14.4 MB/frame of wasted GPU memory bandwidth and freeing 48–80 MB of VRAM everywhere in the game, which gives extra headroom on tight 6–8 GB GPUs and iGPU laptops/handhelds (Steam Deck, 780M/860M/890M) sitting near a frame-rate or VRAM edge.
  • Helps: All GPUs (AMD RDNA 3.5 tested; NVIDIA/Intel/RADV pending) in GPU-bound scenes game-wide at normal/stock turf density (including normal Hyrule Field with ~54,000 blades and Market at 100% render scale). Eliminates the 0.422 ms turf mirror-copy span (< 0.093 ms, total m dispatch -10.1%), cuts GPU frame time -0.47 ms (-2.9%) at Market 100% render scale (1536x864) and -0.50 ms (-2.5%) at Hyrule Field 100% render scale (1382x864), saves -80 MB steady VRAM in Market 100% render scale (from avoiding the ~28 MB private buffers plus VMA 64/32 MB block granularity), and lifts Median FPS +1.0% in Market 100% render scale and +0.3% in Hyrule Field 100% render scale (all 3 rounds non-overlapping in both zones).
  • No measurable impact: CPU-bound scenes (such as Market 67% render scale, 1024x576, on this 8-CU iGPU, where GPU time sits around 12.4–12.8 ms inside an ~18.4 ms frame, so FPS/VRAM deltas fall within run-to-run variance) and extreme dense-turf settings that exceed 7/8 * stock (which intentionally promote to a private buffer like main).

Technical details:

  • Keep simulated-turf lists on the game's own buffer while policy.target() <= stock in adaptive mode (gpu/vk/vk_draw.cpp: sim_turf_private_binding() and sim_turf_bound_result()), leaving sim_turf_bound() empty so mirrors is empty (0 MB/frame copied).
  • Narrow sim_turf_sample_demand()'s post-copy barrier from ALL_COMMANDS_BIT | MEMORY_READ_BIT to HOST_BIT | HOST_READ_BIT when mirrors.empty() (only the 4-byte demand readback copies ran).
  • Keep RX_VK_SIM_TURF_ADAPTIVE=0 as a runtime A/B and kill switch (want_private = !sim_turf_adaptive() || g.policy.target() > stock; gpu/vk/switches.def updated) and guard the stock-passthrough descriptor fallback against RX_VK_SSBO_STRETCH=1 and RX_VK_SSBO_WIDE (&& !Shader::IsSimTurfStorage(d)).

Read first: sim_turf_private_binding() and sim_turf_sample_demand() in gpu/vk/vk_draw.cpp.

See #2174, #2093.

Testing

How to test:

  1. Game-free tests: Run python -I -B tests/test_sim_turf_stock_passthrough.py (fails on main, passes here) plus tests/test_sim_turf_floor.py, tests/test_sim_turf_capacity_policy.py, tests/test_sim_turf_pools.py, and tests/test_switch_table.py.
  2. Confirm passthrough is active: Run the game into Market or Hyrule Field and check longshot_log.txt for vk: simulated turf: prog 3de6d86ec7e6720e — it should log : the game's own instead of : the private one.
  3. Verify the GPU span drop: Run with RX_VK_PASS_TIMING=2 in Market; dispatch indirect prog 3de6d86ec7e6720e should drop from ~0.42 ms out of the top-25 spans (< 0.093 ms) and m dispatch should drop by ~0.45 ms.
  4. Measure FPS / GPU time / VRAM: Use a GPU-bound scene (e.g., Market or Hyrule Field at 100% render scale — avoid CPU-bound 67% render scale (1024x576) where GPU savings are hidden by CPU frame time). Compare main vs. this PR (or toggle RX_VK_SIM_TURF_ADAPTIVE=0 vs. =1 on this build) across >= 3 interleaved rounds with >= 12.5 s post-load settle.
  5. Visual & promotion check: Walk Market -> Hyrule Field -> Kokiri Forest and confirm grass renders cleanly with 0 VK_ERROR_DEVICE_LOST. Optionally raise turf density past 7/8 * stock in Hyrule Field to verify promotion to a private buffer and clean retirement after 600 quiet frames back in Market.

Tested: Windows 11 (build 26200), AMD Ryzen AI 7 350 + AMD Radeon 860M (8 CUs, RDNA 3.5 iGPU, Adrenalin 26.10.1), 1600x1000, handheld_profile=1, sharpness=80, vsync=0, amd_anti-lag_2=1, RX_VK_PRECOMPILE=1, >= 12.5 s post-load settle:

  • Market_Child fountain-first route (67% render scale 1024x576 3 interleaved rounds, 100% render scale 1536x864 3 interleaved rounds) + RX_VK_PASS_TIMING=2 (67% render scale, 1024x576): vk: simulated turf: prog 3de6d86ec7e6720e logged : the game's own; span dropped from 0.422 ms to < 0.093 ms (absent from top 25 spans; total m dispatch 4.515 -> 4.060 ms, -10.1%).
  • HyruleField_Child in-bounds grassy-field orbit (castle-gate, 100% render scale, 1382x864 at 16:10, 3 interleaved rounds): all simulated turf bindings logged : the game's own (peak ~54,000 / 143,360 blades), 0 VK_ERROR_DEVICE_LOST, 0 exit/transition frames (min >= 17.67 ms), and GPU time + Median FPS beat main across all 3 rounds.
  • 3-zone tour (Market -> Hyrule Field -> Kokiri Forest, 67% render scale, 1024x576): 0 VK_ERROR_DEVICE_LOST, 0 write-back timeouts, turf rendered cleanly in Hyrule Field.
  • Stationary RX_VK_SHOT_FX=1 (sharpness=80) visual inspection: scene lighting, geometry, and textures match main cleanly with zero artifacts.
  • Game-free tests (on current main @ 0e32bc10 with dev.py env llvm-mingw + RX_CPM):
    • tests/test_sim_turf_stock_passthrough.py (new; tests RX_VK_SIM_TURF_ADAPTIVE=1 and =0, promotion/retirement, and RX_VK_SSBO_STRETCH/RX_VK_SSBO_WIDE guards): FAIL on main (753fb5af), PASS on this branch (3641cc34).
    • Targeted --strict suite (test_sim_turf*, test_switch_table, test_vk_braces, test_utf8_paths, test_doc_anchors): 9 passed, 0 failed, 0 skipped.
    • python -I -B tests/run_all.py --changed forge/main: 181 passed, 7 failed, 6 skipped — all 7 failures are pre-existing Windows-only main failures documented in #2304 (test_sampler_admission, test_pipeline_state_computes, test_crash_dialog, test_dev_packs, test_saveload_warm_cache, test_dev_ab, test_input_movie).

Still to test:

  • Dense simulated-turf settings in Hyrule Field (Turf density high enough to exceed 7/8 * stock): confirm seamless promotion to private buffer, zero flicker, and retirement back to game buffer after 600 quiet frames in Market (by hand).
  • NVIDIA and Intel GPUs: Market -> Hyrule Field -> Market walk, expecting no regressions and identical GPU bandwidth savings (@Beanstalk Windows NVIDIA, Linux RADV).

Measurements

Verdict: Clear, repeatable win across GPU-bound zones and pass timing: eliminates the 0.422 ms turf mirror-copy span (m dispatch -10.1%); at GPU-bound Market 100% render scale (1536x864) cuts GPU time -0.47 ms (-2.9%), steady VRAM -80 MB, and lifts Median/Mean FPS +1.0%; and at GPU-bound Hyrule Field 100% render scale (1382x864 at 16:10) cuts GPU time -0.50 ms (-2.5%) and lifts Median FPS +0.3% (+0.13 FPS) with non-overlapping 3-round ranges in both zones. Near-CPU-bound Market 67% render scale (1024x576) and overlapping secondary metrics show no measurable difference (within run-to-run variance).

Setup: Windows 11, AMD Ryzen AI 7 350 + Radeon 860M (Adrenalin 26.10.1), 1600x1000, handheld_profile=1, sharpness=80, vsync=0, amd_anti-lag_2=1, RX_VK_PRECOMPILE=1, symmetric pre-warmed shader/pipeline caches (>= 12.5 s settle): fountain-first Market_Child route (1536x864 at 100% render scale, 1024x576 at 67% render scale) and in-bounds HyruleField_Child grassy-field orbit (1382x864 at 100% render scale 16:10). Measured standalone directly against main @ 753fb5af; rebased cleanly onto main @ 0e32bc10 (3641cc34 — none of the 8 intervening commits touch vk_draw.cpp or simulated turf, and #2232's 4-core Auto threshold does not change behavior on this 8-core CPU, so the numbers hold unchanged). Multi-round values are median [min, max] across 3 interleaved rounds.

Where it makes a difference (GPU-bound Market & Hyrule Field at 100% render scale, and pass timing):

Metric Before: main @ 753fb5af After: this PR @ 3641cc34 Change
3de6d86ec7e6720e span (Market 67% render scale, 1024x576, PASS_TIMING=2) 0.422 ms < 0.093 ms (out of top 25) >= -0.329 ms (>= -78%)
Total m dispatch (Market 67% render scale, 1024x576, PASS_TIMING=2) 4.515 ms 4.060 ms -0.455 ms (-10.1%)
Market 100% render scale (1536x864) GPU time (3 rounds) 16.49 [16.48, 16.67] ms 16.02 [15.95, 16.35] ms -0.47 ms (-2.9%) — all 3 rounds faster
Market 100% render scale (1536x864) steady VRAM (3 rounds) 3245 [3213, 3277] MB 3165 [3133, 3197] MB -80 MB (~28 MB buffers + VMA block rounding) — all 3 rounds lower
Market 100% render scale (1536x864) Median FPS (3 rounds) 45.11 [44.92, 45.29] 45.56 [45.55, 46.02] +0.45 FPS (+1.0%) — all 3 rounds faster
Market 100% render scale (1536x864) Mean FPS (3 rounds) 44.79 [44.25, 44.98] 45.25 [45.13, 45.61] +0.46 FPS (+1.0%) — all 3 rounds faster
Hyrule Field 100% render scale (1382x864) GPU time (3 rounds) 19.88 [19.59, 21.24] ms 19.38 [19.31, 19.56] ms -0.50 ms (-2.5%) — all 3 rounds faster
Hyrule Field 100% render scale (1382x864) Median FPS (3 rounds) 38.70 [37.59, 38.70] 38.83 [38.73, 38.93] +0.13 FPS (+0.3%) — all 3 rounds faster
Hyrule Field 100% render scale (1382x864) Median frame ms (3 rounds) 25.84 [25.84, 26.61] ms 25.75 [25.69, 25.82] ms -0.09 ms (-0.3%) — all 3 rounds faster

Where it does NOT make a difference (within run-to-run variance):

Metric Before: main @ 753fb5af After: this PR @ 3641cc34 Change
Market 100% render scale (1536x864) 1% Low FPS (3 rounds) 32.89 [31.36, 33.52] 33.36 [33.22, 34.04] No measurable difference (within run-to-run variance)
Market 100% render scale (1536x864) >= 33.3 ms frames (3 rounds) 7 [3, 10] 4 [4, 6] No measurable difference (within run-to-run variance)
Market 67% render scale (1024x576) Median FPS (3 rounds, CPU-bound) 54.38 [53.59, 54.50] 54.87 [53.11, 55.01] No measurable difference (within run-to-run variance)
Market 67% render scale (1024x576) Mean FPS (3 rounds, CPU-bound) 53.68 [52.66, 54.00] 54.21 [52.06, 54.28] No measurable difference (within run-to-run variance)
Market 67% render scale (1024x576) 1% Low FPS (3 rounds, CPU-bound) 38.95 [36.86, 39.10] 38.55 [34.00, 39.41] No measurable difference (within run-to-run variance)
Market 67% render scale (1024x576) GPU time (3 rounds, CPU-bound) 12.82 [12.73, 12.99] ms 12.41 [12.39, 13.02] ms No measurable difference (within run-to-run variance)
Market 67% render scale (1024x576) steady VRAM (3 rounds) 3085 [3053, 3149] MB 3037 [2973, 3133] MB No measurable difference (within run-to-run variance)
Hyrule Field 100% render scale (1382x864) Mean FPS (3 rounds) 38.56 [37.02, 38.66] 38.64 [38.58, 38.80] No measurable difference (within run-to-run variance)
Hyrule Field 100% render scale (1382x864) 1% Low FPS (3 rounds) 29.03 [23.29, 29.37] 29.56 [28.11, 30.01] No measurable difference (within run-to-run variance)
Hyrule Field 100% render scale (1382x864) >= 33.3 ms frames (3 rounds) 16 [16, 45] 15 [12, 30] No measurable difference (within run-to-run variance)
Hyrule Field 100% render scale (1382x864) gpu_wait_ms (3 rounds) 4.04 [3.66, 5.71] ms 4.64 [3.91, 4.64] ms No measurable difference (within run-to-run variance)
Hyrule Field 100% render scale (1382x864) steady VRAM (3 rounds) 2858 [2858, 2986] MB 2810 [2810, 3098] MB No measurable difference (within run-to-run variance)
# Before (PASS_TIMING=2, Market 67% render scale, 1024x576):
[hos Presentation Thread] vk: simulated turf: prog 3de6d86ec7e6720e stage 5 c0+0x50 (blade list) at 0x117e4f0000: the private one
[hos Presentation Thread] vk:     m dispatch    4.515 ms  35.1%    120.7 spans     120.7 items     0.00 MB     37.4 us a span
[hos Presentation Thread] vk:   m   0.422 ms     1.0 x    421.7 us       1.0 items    0.00 MB  dispatch indirect prog 3de6d86ec7e6720e

# After (PASS_TIMING=2, Market 67% render scale, 1024x576 — 3de6d86ec7e6720e absent from top 25, lowest logged span is 0.093 ms):
[hos Presentation Thread] vk: simulated turf: prog 3de6d86ec7e6720e stage 5 c0+0x50 (blade list) at 0x117e4f0000: the game's own
[hos Presentation Thread] vk:     m dispatch    4.060 ms  32.6%    119.2 spans     119.2 items     0.00 MB     34.1 us a span

# Before (Market 100% render scale, 1536x864, round 2):
[hos Presentation Thread] vk: GPU time 16.5 ms a frame (the longest submission 6.3 ms); 3.6 textures made a frame: colour targets 1.9 (4.3 MB), depth 1.6 (3.5 MB), ASTC or BC 0.0 (0.0 MB), other 0.0 (0.0 MB)
[hos Presentation Thread] vk: VRAM: 3277 MB used of 12212 MB allowed (259 MB of it free in the blocks); textures 2584 MB (budget 4096 MB), 2297 textures

# After (Market 100% render scale, 1536x864, round 2):
[hos Presentation Thread] vk: GPU time 16.3 ms a frame (the longest submission 7.4 ms); 3.8 textures made a frame: colour targets 2.1 (3.8 MB), depth 1.4 (3.2 MB), ASTC or BC 0.4 (0.2 MB), other 0.0 (0.0 MB)
[hos Presentation Thread] vk: VRAM: 3133 MB used of 12212 MB allowed (235 MB of it free in the blocks); textures 2632 MB (budget 4096 MB), 2256 textures

# Before (Hyrule Field 100% render scale, 1382x864, round 1):
[hos Presentation Thread] vk: simulated turf: prog 3de6d86ec7e6720e stage 5 c0+0x50 (blade list) at 0x117e070000: the private one
[hos host] vk: simulated turf: frame 3611: blade lists 3598 found, 2 made, 0 retaken, 0 absent, 0 lost; pools 14382 found, 4 made, 0 retaken, 0 absent, 0 lost; peak demand blade 54018/143360, pool 42519/138240 records
[hos Presentation Thread] vk: GPU time 20.0 ms a frame (the longest submission 9.7 ms); 1.1 textures made a frame: colour targets 0.8 (1.3 MB), depth 0.3 (0.7 MB), ASTC or BC 0.0 (0.0 MB), other 0.0 (0.0 MB)

# After (Hyrule Field 100% render scale, 1382x864, round 1):
[hos Presentation Thread] vk: simulated turf: prog 3de6d86ec7e6720e stage 5 c0+0x50 (blade list) at 0x117e070000: the game's own
[hos host] vk: simulated turf: frame 3523: blade lists 3598 found, 2 made, 0 retaken, 0 absent, 0 lost; pools 14380 found, 4 made, 0 retaken, 0 absent, 0 lost; peak demand blade 53988/143360, pool 42402/138240 records
[hos Presentation Thread] vk: GPU time 18.0 ms a frame (the longest submission 8.8 ms); 0.7 textures made a frame: colour targets 0.5 (0.6 MB), depth 0.2 (0.4 MB), ASTC or BC 0.0 (0.0 MB), other 0.0 (0.0 MB)

Risks

  • Promotion/demotion transitions: Under dense turf settings where demand crosses 7/8 * stock, the list promotes from the game's buffer to a newly allocated private buffer on the next creator dispatch; after 600 quiet frames, it retires the private buffer (reaped after the GPU timeline passes it) and returns to the game's buffer. tests/test_sim_turf_stock_passthrough.py verifies the full lifecycle including retirement and destruction.
  • No #2174 regression: Because the producer writes directly into the game's own buffer on every frame at stock capacity, the game's buffer remains continuously marked written (never introducing a sudden first write-back when entering Hyrule Field).
  • Turn off / rollback: RX_VK_SIM_TURF_ADAPTIVE=0 immediately restores stock-sized private buffers for A/B comparison; a revert is also clean. No save/options/cache format changes. Players notice nothing in their files.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (tests/run_all.py --changed forge/main on Windows: 181 passed, 7 pre-existing Windows-only main failures named in #2304: test_sampler_admission, test_pipeline_state_computes, test_crash_dialog, test_dev_packs, test_saveload_warm_cache, test_dev_ab, test_input_movie; targeted --strict suite 9/9 passed).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def.
  • A check under tests/ that reads changed source is updated, not weakened (test_sim_turf_floor.py, test_sim_turf_capacity_policy.py, test_sim_turf_pools.py, and test_switch_table.py all pass).
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.
## Summary Longshot's simulated-turf system keeps a private GPU copy of the game's grass buffers so it can grow them when dense grass overflows the Switch 2's stock buffer size (`#2174`). Previously, it allocated those private buffers (~28 MB) immediately at stock size and copied **`~14.4 MB` of grass data back into the game's buffers every single frame** with a full-GPU barrier — even in areas with almost no grass (like cobblestone Market, `0–197` blades) or normal Hyrule Field (`~17,000` blades, well under the `143,360`-blade stock limit). This PR lets simulated turf write directly into the game's own buffers whenever demand fits within stock capacity, eliminating the per-frame `~14.4 MB` mirror copy, the full-GPU barrier, and the duplicate VRAM allocation **game-wide** (Hyrule Field, Market, Kokiri Forest, dungeons — every scene that uses simulated turf within stock capacity). If dense grass ever approaches the stock limit (`>= 7/8 * stock`), it seamlessly promotes to a larger private buffer just as before and retires it back to the game's buffer after 600 quiet frames. **Where this helps vs. where it doesn't:** - **What a player notices:** Not directly visible by eye (`+0.3%` to `+1.0%` FPS is too small to feel without an FPS counter). Its real value is quiet, zero-downside efficiency — stopping `~14.4 MB/frame` of wasted GPU memory bandwidth and freeing **`48–80 MB` of VRAM** everywhere in the game, which gives extra headroom on tight 6–8 GB GPUs and iGPU laptops/handhelds (Steam Deck, 780M/860M/890M) sitting near a frame-rate or VRAM edge. - **Helps:** **All GPUs** (AMD RDNA 3.5 tested; NVIDIA/Intel/RADV pending) in **GPU-bound scenes game-wide** at normal/stock turf density (including normal Hyrule Field with `~54,000` blades and Market at `100% render scale`). Eliminates the `0.422 ms` turf mirror-copy span (`< 0.093 ms`, total `m dispatch` `-10.1%`), cuts GPU frame time **`-0.47 ms` (`-2.9%`)** at Market `100% render scale` (`1536x864`) and **`-0.50 ms` (`-2.5%`)** at Hyrule Field `100% render scale` (`1382x864`), saves **`-80 MB` steady VRAM** in Market `100% render scale` (from avoiding the `~28 MB` private buffers plus VMA `64/32 MB` block granularity), and lifts Median FPS **`+1.0%`** in Market `100% render scale` and **`+0.3%`** in Hyrule Field `100% render scale` (all 3 rounds non-overlapping in both zones). - **No measurable impact:** **CPU-bound scenes** (such as Market `67% render scale`, `1024x576`, on this 8-CU iGPU, where GPU time sits around `12.4–12.8 ms` inside an `~18.4 ms` frame, so FPS/VRAM deltas fall within run-to-run variance) and **extreme dense-turf settings** that exceed `7/8 * stock` (which intentionally promote to a private buffer like `main`). **Technical details:** - Keep simulated-turf lists on the game's own buffer while `policy.target() <= stock` in adaptive mode (`gpu/vk/vk_draw.cpp`: `sim_turf_private_binding()` and `sim_turf_bound_result()`), leaving `sim_turf_bound()` empty so `mirrors` is empty (`0 MB/frame` copied). - Narrow `sim_turf_sample_demand()`'s post-copy barrier from `ALL_COMMANDS_BIT | MEMORY_READ_BIT` to `HOST_BIT | HOST_READ_BIT` when `mirrors.empty()` (only the 4-byte demand readback copies ran). - Keep `RX_VK_SIM_TURF_ADAPTIVE=0` as a runtime A/B and kill switch (`want_private = !sim_turf_adaptive() || g.policy.target() > stock`; `gpu/vk/switches.def` updated) and guard the stock-passthrough descriptor fallback against `RX_VK_SSBO_STRETCH=1` and `RX_VK_SSBO_WIDE` (`&& !Shader::IsSimTurfStorage(d)`). Read first: `sim_turf_private_binding()` and `sim_turf_sample_demand()` in `gpu/vk/vk_draw.cpp`. See #2174, #2093. ## Testing **How to test:** 1. **Game-free tests:** Run `python -I -B tests/test_sim_turf_stock_passthrough.py` (fails on `main`, passes here) plus `tests/test_sim_turf_floor.py`, `tests/test_sim_turf_capacity_policy.py`, `tests/test_sim_turf_pools.py`, and `tests/test_switch_table.py`. 2. **Confirm passthrough is active:** Run the game into Market or Hyrule Field and check `longshot_log.txt` for `vk: simulated turf: prog 3de6d86ec7e6720e` — it should log `: the game's own` instead of `: the private one`. 3. **Verify the GPU span drop:** Run with `RX_VK_PASS_TIMING=2` in Market; `dispatch indirect prog 3de6d86ec7e6720e` should drop from `~0.42 ms` out of the top-25 spans (`< 0.093 ms`) and `m dispatch` should drop by `~0.45 ms`. 4. **Measure FPS / GPU time / VRAM:** Use a **GPU-bound** scene (e.g., Market or Hyrule Field at `100% render scale` — avoid CPU-bound `67% render scale` (`1024x576`) where GPU savings are hidden by CPU frame time). Compare `main` vs. this PR (or toggle `RX_VK_SIM_TURF_ADAPTIVE=0` vs. `=1` on this build) across `>= 3` interleaved rounds with `>= 12.5 s` post-load settle. 5. **Visual & promotion check:** Walk `Market -> Hyrule Field -> Kokiri Forest` and confirm grass renders cleanly with `0` `VK_ERROR_DEVICE_LOST`. Optionally raise turf density past `7/8 * stock` in Hyrule Field to verify promotion to a private buffer and clean retirement after 600 quiet frames back in Market. **Tested:** Windows 11 (build 26200), AMD Ryzen AI 7 350 + AMD Radeon 860M (8 CUs, RDNA 3.5 iGPU, Adrenalin 26.10.1), `1600x1000`, `handheld_profile=1`, `sharpness=80`, `vsync=0`, `amd_anti-lag_2=1`, `RX_VK_PRECOMPILE=1`, `>= 12.5 s` post-load settle: - `Market_Child` fountain-first route (`67% render scale` `1024x576` 3 interleaved rounds, `100% render scale` `1536x864` 3 interleaved rounds) + `RX_VK_PASS_TIMING=2` (`67% render scale`, `1024x576`): `vk: simulated turf: prog 3de6d86ec7e6720e` logged `: the game's own`; span dropped from `0.422 ms` to `< 0.093 ms` (absent from top 25 spans; total `m dispatch` `4.515 -> 4.060 ms`, `-10.1%`). - `HyruleField_Child` in-bounds grassy-field orbit (`castle-gate`, `100% render scale`, `1382x864` at `16:10`, 3 interleaved rounds): all simulated turf bindings logged `: the game's own` (peak `~54,000 / 143,360` blades), `0` `VK_ERROR_DEVICE_LOST`, `0` exit/transition frames (`min >= 17.67 ms`), and GPU time + Median FPS beat `main` across all 3 rounds. - 3-zone tour (`Market -> Hyrule Field -> Kokiri Forest`, `67% render scale`, `1024x576`): `0` `VK_ERROR_DEVICE_LOST`, `0` write-back timeouts, turf rendered cleanly in Hyrule Field. - Stationary `RX_VK_SHOT_FX=1` (`sharpness=80`) visual inspection: scene lighting, geometry, and textures match `main` cleanly with zero artifacts. - Game-free tests (on current `main @ 0e32bc10` with `dev.py env` `llvm-mingw` + `RX_CPM`): - `tests/test_sim_turf_stock_passthrough.py` (new; tests `RX_VK_SIM_TURF_ADAPTIVE=1` and `=0`, promotion/retirement, and `RX_VK_SSBO_STRETCH`/`RX_VK_SSBO_WIDE` guards): **FAIL** on `main` (`753fb5af`), **PASS** on this branch (`3641cc34`). - Targeted `--strict` suite (`test_sim_turf*`, `test_switch_table`, `test_vk_braces`, `test_utf8_paths`, `test_doc_anchors`): **9 passed, 0 failed, 0 skipped**. - `python -I -B tests/run_all.py --changed forge/main`: **181 passed, 7 failed, 6 skipped** — all 7 failures are pre-existing Windows-only `main` failures documented in `#2304` (`test_sampler_admission`, `test_pipeline_state_computes`, `test_crash_dialog`, `test_dev_packs`, `test_saveload_warm_cache`, `test_dev_ab`, `test_input_movie`). **Still to test:** - Dense simulated-turf settings in Hyrule Field (`Turf density` high enough to exceed `7/8 * stock`): confirm seamless promotion to private buffer, zero flicker, and retirement back to game buffer after 600 quiet frames in Market (by hand). - NVIDIA and Intel GPUs: Market -> Hyrule Field -> Market walk, expecting no regressions and identical GPU bandwidth savings (@Beanstalk Windows NVIDIA, Linux RADV). ## Measurements **Verdict:** Clear, repeatable win across GPU-bound zones and pass timing: eliminates the `0.422 ms` turf mirror-copy span (`m dispatch` **`-10.1%`**); at GPU-bound Market `100% render scale` (`1536x864`) cuts GPU time **`-0.47 ms` (`-2.9%`)**, steady VRAM **`-80 MB`**, and lifts Median/Mean FPS **`+1.0%`**; and at GPU-bound Hyrule Field `100% render scale` (`1382x864` at `16:10`) cuts GPU time **`-0.50 ms` (`-2.5%`)** and lifts Median FPS **`+0.3%`** (`+0.13 FPS`) with non-overlapping 3-round ranges in both zones. Near-CPU-bound Market `67% render scale` (`1024x576`) and overlapping secondary metrics show **no measurable difference (within run-to-run variance)**. Setup: Windows 11, AMD Ryzen AI 7 350 + Radeon 860M (Adrenalin 26.10.1), `1600x1000`, `handheld_profile=1`, `sharpness=80`, `vsync=0`, `amd_anti-lag_2=1`, `RX_VK_PRECOMPILE=1`, symmetric pre-warmed shader/pipeline caches (`>= 12.5 s` settle): fountain-first `Market_Child` route (`1536x864` at `100% render scale`, `1024x576` at `67% render scale`) and in-bounds `HyruleField_Child` grassy-field orbit (`1382x864` at `100% render scale` `16:10`). Measured standalone directly against `main @ 753fb5af`; rebased cleanly onto `main @ 0e32bc10` (`3641cc34` — none of the 8 intervening commits touch `vk_draw.cpp` or simulated turf, and `#2232`'s 4-core Auto threshold does not change behavior on this 8-core CPU, so the numbers hold unchanged). Multi-round values are `median [min, max]` across 3 interleaved rounds. **Where it makes a difference (GPU-bound Market & Hyrule Field at `100% render scale`, and pass timing):** | Metric | Before: `main @ 753fb5af` | After: this PR @ `3641cc34` | Change | |---|---|---|---| | **`3de6d86ec7e6720e` span (Market `67% render scale`, `1024x576`, `PASS_TIMING=2`)** | `0.422 ms` | **`< 0.093 ms` (out of top 25)** | **`>= -0.329 ms` (`>= -78%`)** | | **Total `m dispatch` (Market `67% render scale`, `1024x576`, `PASS_TIMING=2`)** | `4.515 ms` | **`4.060 ms`** | **`-0.455 ms` (`-10.1%`)** | | **Market `100% render scale` (`1536x864`) GPU time (3 rounds)** | `16.49 [16.48, 16.67] ms` | **`16.02 [15.95, 16.35] ms`** | **`-0.47 ms` (`-2.9%`) — all 3 rounds faster** | | **Market `100% render scale` (`1536x864`) steady VRAM (3 rounds)** | `3245 [3213, 3277] MB` | **`3165 [3133, 3197] MB`** | **`-80 MB` (~28 MB buffers + VMA block rounding) — all 3 rounds lower** | | **Market `100% render scale` (`1536x864`) Median FPS (3 rounds)** | `45.11 [44.92, 45.29]` | **`45.56 [45.55, 46.02]`** | **`+0.45 FPS` (`+1.0%`) — all 3 rounds faster** | | **Market `100% render scale` (`1536x864`) Mean FPS (3 rounds)** | `44.79 [44.25, 44.98]` | **`45.25 [45.13, 45.61]`** | **`+0.46 FPS` (`+1.0%`) — all 3 rounds faster** | | **Hyrule Field `100% render scale` (`1382x864`) GPU time (3 rounds)** | `19.88 [19.59, 21.24] ms` | **`19.38 [19.31, 19.56] ms`** | **`-0.50 ms` (`-2.5%`) — all 3 rounds faster** | | **Hyrule Field `100% render scale` (`1382x864`) Median FPS (3 rounds)** | `38.70 [37.59, 38.70]` | **`38.83 [38.73, 38.93]`** | **`+0.13 FPS` (`+0.3%`) — all 3 rounds faster** | | **Hyrule Field `100% render scale` (`1382x864`) Median frame ms (3 rounds)** | `25.84 [25.84, 26.61] ms` | **`25.75 [25.69, 25.82] ms`** | **`-0.09 ms` (`-0.3%`) — all 3 rounds faster** | **Where it does NOT make a difference (within run-to-run variance):** | Metric | Before: `main @ 753fb5af` | After: this PR @ `3641cc34` | Change | |---|---|---|---| | Market `100% render scale` (`1536x864`) 1% Low FPS (3 rounds) | `32.89 [31.36, 33.52]` | `33.36 [33.22, 34.04]` | No measurable difference (within run-to-run variance) | | Market `100% render scale` (`1536x864`) `>= 33.3 ms` frames (3 rounds) | `7 [3, 10]` | `4 [4, 6]` | No measurable difference (within run-to-run variance) | | Market `67% render scale` (`1024x576`) Median FPS (3 rounds, CPU-bound) | `54.38 [53.59, 54.50]` | `54.87 [53.11, 55.01]` | No measurable difference (within run-to-run variance) | | Market `67% render scale` (`1024x576`) Mean FPS (3 rounds, CPU-bound) | `53.68 [52.66, 54.00]` | `54.21 [52.06, 54.28]` | No measurable difference (within run-to-run variance) | | Market `67% render scale` (`1024x576`) 1% Low FPS (3 rounds, CPU-bound) | `38.95 [36.86, 39.10]` | `38.55 [34.00, 39.41]` | No measurable difference (within run-to-run variance) | | Market `67% render scale` (`1024x576`) GPU time (3 rounds, CPU-bound) | `12.82 [12.73, 12.99] ms` | `12.41 [12.39, 13.02] ms` | No measurable difference (within run-to-run variance) | | Market `67% render scale` (`1024x576`) steady VRAM (3 rounds) | `3085 [3053, 3149] MB` | `3037 [2973, 3133] MB` | No measurable difference (within run-to-run variance) | | Hyrule Field `100% render scale` (`1382x864`) Mean FPS (3 rounds) | `38.56 [37.02, 38.66]` | `38.64 [38.58, 38.80]` | No measurable difference (within run-to-run variance) | | Hyrule Field `100% render scale` (`1382x864`) 1% Low FPS (3 rounds) | `29.03 [23.29, 29.37]` | `29.56 [28.11, 30.01]` | No measurable difference (within run-to-run variance) | | Hyrule Field `100% render scale` (`1382x864`) `>= 33.3 ms` frames (3 rounds) | `16 [16, 45]` | `15 [12, 30]` | No measurable difference (within run-to-run variance) | | Hyrule Field `100% render scale` (`1382x864`) `gpu_wait_ms` (3 rounds) | `4.04 [3.66, 5.71] ms` | `4.64 [3.91, 4.64] ms` | No measurable difference (within run-to-run variance) | | Hyrule Field `100% render scale` (`1382x864`) steady VRAM (3 rounds) | `2858 [2858, 2986] MB` | `2810 [2810, 3098] MB` | No measurable difference (within run-to-run variance) | ```text # Before (PASS_TIMING=2, Market 67% render scale, 1024x576): [hos Presentation Thread] vk: simulated turf: prog 3de6d86ec7e6720e stage 5 c0+0x50 (blade list) at 0x117e4f0000: the private one [hos Presentation Thread] vk: m dispatch 4.515 ms 35.1% 120.7 spans 120.7 items 0.00 MB 37.4 us a span [hos Presentation Thread] vk: m 0.422 ms 1.0 x 421.7 us 1.0 items 0.00 MB dispatch indirect prog 3de6d86ec7e6720e # After (PASS_TIMING=2, Market 67% render scale, 1024x576 — 3de6d86ec7e6720e absent from top 25, lowest logged span is 0.093 ms): [hos Presentation Thread] vk: simulated turf: prog 3de6d86ec7e6720e stage 5 c0+0x50 (blade list) at 0x117e4f0000: the game's own [hos Presentation Thread] vk: m dispatch 4.060 ms 32.6% 119.2 spans 119.2 items 0.00 MB 34.1 us a span # Before (Market 100% render scale, 1536x864, round 2): [hos Presentation Thread] vk: GPU time 16.5 ms a frame (the longest submission 6.3 ms); 3.6 textures made a frame: colour targets 1.9 (4.3 MB), depth 1.6 (3.5 MB), ASTC or BC 0.0 (0.0 MB), other 0.0 (0.0 MB) [hos Presentation Thread] vk: VRAM: 3277 MB used of 12212 MB allowed (259 MB of it free in the blocks); textures 2584 MB (budget 4096 MB), 2297 textures # After (Market 100% render scale, 1536x864, round 2): [hos Presentation Thread] vk: GPU time 16.3 ms a frame (the longest submission 7.4 ms); 3.8 textures made a frame: colour targets 2.1 (3.8 MB), depth 1.4 (3.2 MB), ASTC or BC 0.4 (0.2 MB), other 0.0 (0.0 MB) [hos Presentation Thread] vk: VRAM: 3133 MB used of 12212 MB allowed (235 MB of it free in the blocks); textures 2632 MB (budget 4096 MB), 2256 textures # Before (Hyrule Field 100% render scale, 1382x864, round 1): [hos Presentation Thread] vk: simulated turf: prog 3de6d86ec7e6720e stage 5 c0+0x50 (blade list) at 0x117e070000: the private one [hos host] vk: simulated turf: frame 3611: blade lists 3598 found, 2 made, 0 retaken, 0 absent, 0 lost; pools 14382 found, 4 made, 0 retaken, 0 absent, 0 lost; peak demand blade 54018/143360, pool 42519/138240 records [hos Presentation Thread] vk: GPU time 20.0 ms a frame (the longest submission 9.7 ms); 1.1 textures made a frame: colour targets 0.8 (1.3 MB), depth 0.3 (0.7 MB), ASTC or BC 0.0 (0.0 MB), other 0.0 (0.0 MB) # After (Hyrule Field 100% render scale, 1382x864, round 1): [hos Presentation Thread] vk: simulated turf: prog 3de6d86ec7e6720e stage 5 c0+0x50 (blade list) at 0x117e070000: the game's own [hos host] vk: simulated turf: frame 3523: blade lists 3598 found, 2 made, 0 retaken, 0 absent, 0 lost; pools 14380 found, 4 made, 0 retaken, 0 absent, 0 lost; peak demand blade 53988/143360, pool 42402/138240 records [hos Presentation Thread] vk: GPU time 18.0 ms a frame (the longest submission 8.8 ms); 0.7 textures made a frame: colour targets 0.5 (0.6 MB), depth 0.2 (0.4 MB), ASTC or BC 0.0 (0.0 MB), other 0.0 (0.0 MB) ``` ## Risks - **Promotion/demotion transitions:** Under dense turf settings where demand crosses `7/8 * stock`, the list promotes from the game's buffer to a newly allocated private buffer on the next creator dispatch; after 600 quiet frames, it retires the private buffer (reaped after the GPU timeline passes it) and returns to the game's buffer. `tests/test_sim_turf_stock_passthrough.py` verifies the full lifecycle including retirement and destruction. - **No `#2174` regression:** Because the producer writes directly into the game's own buffer on every frame at stock capacity, the game's buffer remains continuously marked written (never introducing a sudden first write-back when entering Hyrule Field). - **Turn off / rollback:** `RX_VK_SIM_TURF_ADAPTIVE=0` immediately restores stock-sized private buffers for A/B comparison; a revert is also clean. No save/options/cache format changes. Players notice nothing in their files. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (`tests/run_all.py --changed forge/main` on Windows: 181 passed, 7 pre-existing Windows-only `main` failures named in `#2304`: `test_sampler_admission`, `test_pipeline_state_computes`, `test_crash_dialog`, `test_dev_packs`, `test_saveload_warm_cache`, `test_dev_ab`, `test_input_movie`; targeted `--strict` suite 9/9 passed). - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def`. - [x] A check under `tests/` that reads changed source is updated, not weakened (`test_sim_turf_floor.py`, `test_sim_turf_capacity_policy.py`, `test_sim_turf_pools.py`, and `test_switch_table.py` all pass). - [x] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold.
perf(vk): cut Market 1536x864 GPU time 2.9% (-80 MB VRAM, +1.0% FPS) across GPUs by keeping stock simulated turf on game buffers
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 3s
beanstalk/approval waiting for a BigBean's 👍 on the request
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
2e8721320e
When a simulated-turf list is at stock capacity (143,360 blades / 138,240 pools), avoid allocating a duplicate private VkBuffer (~28 MB VRAM across all lists) and let both producers and readers bind the game's own buffer directly.  This eliminates the ~14.4 MB/frame GPU-to-GPU mirror copy inside sim_turf_sample_demand() and narrows its post-copy barrier from ALL_COMMANDS_BIT | MEMORY_READ_BIT to HOST_BIT | HOST_READ_BIT when only the 4-byte demand readback runs. High-demand areas (>= 7/8 stock) still promote to a private buffer and retire back to stock passthrough after 600 quiet frames.  Assisted-by: Antigravity
Author
Contributor

Tested in game: Windows 11, AMD Radeon 860M (Adrenalin 26.10.1): Market (1536x864 and 1024x576), Hyrule Field (1382x864), and 3-zone tour (Market -> Hyrule Field -> Kokiri Forest). Confirmed 3de6d86ec7e6720e uses the game buffer, span dropped from 0.422 ms to <0.093 ms, GPU time -0.47 ms (-2.9%) in Market and -0.50 ms (-2.5%) in Hyrule Field, -80 MB VRAM, 0 device_lost, clean visual parity.

Tested in game: Windows 11, AMD Radeon 860M (Adrenalin 26.10.1): Market (1536x864 and 1024x576), Hyrule Field (1382x864), and 3-zone tour (Market -> Hyrule Field -> Kokiri Forest). Confirmed 3de6d86ec7e6720e uses the game buffer, span dropped from 0.422 ms to <0.093 ms, GPU time -0.47 ms (-2.9%) in Market and -0.50 ms (-2.5%) in Hyrule Field, -80 MB VRAM, 0 device_lost, clean visual parity.
Member

Possibly related, for context:

  • PR #2288 WIP: fix(vk): simulated-turf lists stay within the device's workgroups for one draw or dispatch — Open simulated-turf Vulkan buffer-capacity work overlaps renderer code
Possibly related, for context: - PR #2288 WIP: fix(vk): simulated-turf lists stay within the device's workgroups for one draw or dispatch — Open simulated-turf Vulkan buffer-capacity work overlaps renderer code
Jer9 changed title from WIP: perf(vk): cut Market 1536x864 GPU time 2.9% (-80 MB VRAM, +1.0% FPS) across GPUs by keeping stock simulated turf on game buffers to perf(vk): cut Market 1536x864 GPU time 2.9% (-80 MB VRAM, +1.0% FPS) across GPUs by keeping stock simulated turf on game buffers 2026-11-23 04:23:51 +00:00
Member

@Jer9 only members of BigBeans can start the farm.

One of them can approve this request by reacting 👍 to it or to this comment. This request was for 2e87213, and the PR has changed since (3641cc3), so a 👍 no longer approves it. Comment @Beanstalk again to ask for the new commit.

@Jer9 only members of `BigBeans` can start the farm. ~~One of them can approve this request by reacting 👍 to it or to this comment.~~ This request was for `2e87213`, and the PR has changed since (`3641cc3`), so a 👍 no longer approves it. Comment `@Beanstalk` again to ask for the new commit.
Jer9 force-pushed perf/vk-sim-turf-stock-passthrough from 2e8721320e
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 3s
beanstalk/approval waiting for a BigBean's 👍 on the request
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
to 3641cc3488
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 9s
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval waiting for a BigBean's 👍 on the request
2026-11-23 04:35:12 +00:00
Compare
Member

@Jer9 only members of BigBeans can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.

@Jer9 only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.
Author
Contributor

@Beanstalk Please test on Windows NVIDIA and Linux RADV (head 3641cc34): walk Market -> Hyrule Field (normal/stock turf density) at 100% render scale. Confirm vk: simulated turf: prog 3de6d86ec7e6720e logs : the game's own in longshot_log.txt, and compare GPU time, VRAM, and FPS vs main.

@Beanstalk Please test on Windows NVIDIA and Linux RADV (head `3641cc34`): walk Market -> Hyrule Field (normal/stock turf density) at 100% render scale. Confirm `vk: simulated turf: prog 3de6d86ec7e6720e` logs `: the game's own` in `longshot_log.txt`, and compare GPU time, VRAM, and FPS vs `main`.
Member

@Jer9 only members of BigBeans can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.

@Jer9 only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.
@ -571,2 +577,3 @@
const uint32_t before = g.policy.capacity(), target = g.policy.target();
if (sim_turf_resize(g, pool, salign))
if (!want_private) {
sim_turf_retire(g);
Contributor

i saw the test mocks high turf demand and then 600 quiet frames. did you also try max turf in hyrule field and go back to market in game? im curious if it flickers or hitches when it switches back.

i saw the test mocks high turf demand and then 600 quiet frames. did you also try max turf in hyrule field and go back to market in game? im curious if it flickers or hitches when it switches back.
Author
Contributor

Haven't tried max turf in-game yet — all my live runs so far were at default turf density (peaking around ~54,000 / 143,360 blades in Hyrule Field), so I listed dense turf promotion/demotion under Still to test and only exercised the grow -> 600-quiet-frame shrink path in tests/test_sim_turf_stock_passthrough.py.

On paper it shouldn't flicker or hitch when switching back:

  • Flicker: sim_turf_retire(g) only runs on the creator dispatch right before the producer shader writes that frame's grass list, so the creator and every subsequent reader in that frame bind the game's buffer together (and while the private buffer was active, sim_turf_sample_demand() was already mirroring the stock window back into the game's buffer each frame). Meanwhile, the old private buffer stays alive in sim_turf_retired until vk_timeline_completed() passes vk_retirement_value(), so any earlier frame still in flight on the GPU finishes cleanly.
  • Hitching: Switching back to stock doesn't allocate anything (unlike promoting up, which does a single create_device_buffer like main), and destroy_buffer() happens asynchronously on a later reap once the GPU is done with it.

If you do try max turf in Hyrule Field and head back to Market, let me know if you spot any flicker or hitching on the switch!

Haven't tried max turf in-game yet — all my live runs so far were at default turf density (peaking around `~54,000 / 143,360` blades in Hyrule Field), so I listed dense turf promotion/demotion under **Still to test** and only exercised the grow -> 600-quiet-frame shrink path in `tests/test_sim_turf_stock_passthrough.py`. On paper it shouldn't flicker or hitch when switching back: - **Flicker:** `sim_turf_retire(g)` only runs on the **creator** dispatch right before the producer shader writes that frame's grass list, so the creator and every subsequent reader in that frame bind the game's buffer together (and while the private buffer was active, `sim_turf_sample_demand()` was already mirroring the stock window back into the game's buffer each frame). Meanwhile, the old private buffer stays alive in `sim_turf_retired` until `vk_timeline_completed()` passes `vk_retirement_value()`, so any earlier frame still in flight on the GPU finishes cleanly. - **Hitching:** Switching back to stock doesn't allocate anything (unlike promoting up, which does a single `create_device_buffer` like `main`), and `destroy_buffer()` happens asynchronously on a later reap once the GPU is done with it. If you do try max turf in Hyrule Field and head back to Market, let me know if you spot any flicker or hitching on the switch!
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 9s
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval waiting for a BigBean's 👍 on the request
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
Some workflows are waiting to be reviewed.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'perf/vk-sim-turf-stock-passthrough:Jer9-perf/vk-sim-turf-stock-passthrough'
git switch 'Jer9-perf/vk-sim-turf-stock-passthrough'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2328
No description provided.