fix(vk): scale actor turf quota by patch pitch area (#2955) #3025

Merged
HumanBean merged 1 commit from cfw34683/Longshot:fix/2955-market-turf-density into main 2026-12-02 21:39:42 +00:00
Contributor

Summary

Fixes #2955.

In turf_population.comp, sim_turf_actor_blades (quota) is applied per patch, while footprint_bin normalizes each patch radius against that atlas's own (min_patch_radius + max_patch_radius) / 2 midpoint. Because HyruleField_Child uses a 0.250-unit patch pitch (8x8 tiles) while Market_Child uses a 0.125-unit patch pitch (4x4 tiles), Market_Child packs (0.25 / 0.125)^2 = 4x as many patches per unit area at the same per-patch quota, expanding the actor turf pools to ~9M records (411+ MB/pool) and causing severe GPU-bound FPS drops on the Temple of Time road.

This adds sim_turf_population::pitch_scaled_quota(density, pitch, valid_pitch) in gpu/vk/sim_turf_population.h and uses it in turf_populate (gpu/vk/vk_draw.cpp) to scale per-patch quota by (pitch / 0.25)^2 when pitch < 0.25 (keeping at least 1 blade when enabled, 0 when density <= 0, and leaving pitch >= 0.25 / invalid pitch unscaled).

Testing

  • Unit tests (clang++ / llvm-mingw, Windows 11):
    • python -I -B tests/test_turf_budget.py --cxx clang++ - PASS (includes new pitch_scaled_quota assertions)
    • python -I -B tests/test_sim_turf_floor.py - PASS
    • python -I -B tests/test_sim_turf_group_limit.py - PASS
    • python -I -B tests/test_sim_turf_capacity_policy.py --cxx clang++ - PASS
    • python -I -B tests/test_sim_turf_pools.py --cxx clang++ - PASS
  • In-game verification (Market_Child, market-entrance save walking the Temple of Time road, Max turf preset 150 / 100 / 43, Windows 11, NVIDIA GeForce RTX 3070 Ti):
    • Before: peak pool size 8,978,432 records (411.0 MB/pool), GPU frame time up to 18.6 ms (longest submission 14.3 ms), FPS dropped to ~26-45 FPS.
    • After: peak pool size 2,490,368 records (114.0 MB/pool), GPU frame time 8.3 - 12.4 ms (longest submission 4.3 - 8.3 ms), holding ~60 FPS (59.7 - 60.2 fps in logs, brief 57 FPS dip).

Checklist

  • One topic, on current main, Conventional Commit title.
  • Tested in-game on Windows 11 + RTX 3070 Ti and via targeted tests/test_*sim_turf*.py / tests/test_turf_budget.py.
  • Assisted-by: Antigravity recorded in commit.
## Summary Fixes #2955. In `turf_population.comp`, `sim_turf_actor_blades` (`quota`) is applied per patch, while `footprint_bin` normalizes each patch radius against that atlas's own `(min_patch_radius + max_patch_radius) / 2` midpoint. Because `HyruleField_Child` uses a `0.250`-unit patch pitch (8x8 tiles) while `Market_Child` uses a `0.125`-unit patch pitch (4x4 tiles), `Market_Child` packs `(0.25 / 0.125)^2 = 4x` as many patches per unit area at the same per-patch quota, expanding the actor turf pools to ~9M records (411+ MB/pool) and causing severe GPU-bound FPS drops on the Temple of Time road. This adds `sim_turf_population::pitch_scaled_quota(density, pitch, valid_pitch)` in `gpu/vk/sim_turf_population.h` and uses it in `turf_populate` (`gpu/vk/vk_draw.cpp`) to scale per-patch `quota` by `(pitch / 0.25)^2` when `pitch < 0.25` (keeping at least 1 blade when enabled, 0 when `density <= 0`, and leaving `pitch >= 0.25` / invalid pitch unscaled). ## Testing - Unit tests (`clang++` / `llvm-mingw`, Windows 11): - `python -I -B tests/test_turf_budget.py --cxx clang++` - PASS (includes new `pitch_scaled_quota` assertions) - `python -I -B tests/test_sim_turf_floor.py` - PASS - `python -I -B tests/test_sim_turf_group_limit.py` - PASS - `python -I -B tests/test_sim_turf_capacity_policy.py --cxx clang++` - PASS - `python -I -B tests/test_sim_turf_pools.py --cxx clang++` - PASS - In-game verification (`Market_Child`, `market-entrance` save walking the Temple of Time road, `Max` turf preset `150 / 100 / 43`, Windows 11, NVIDIA GeForce RTX 3070 Ti): - **Before:** peak pool size `8,978,432` records (411.0 MB/pool), GPU frame time up to `18.6 ms` (`longest submission 14.3 ms`), FPS dropped to ~26-45 FPS. - **After:** peak pool size `2,490,368` records (114.0 MB/pool), GPU frame time `8.3 - 12.4 ms` (`longest submission 4.3 - 8.3 ms`), holding ~60 FPS (`59.7 - 60.2 fps` in logs, brief 57 FPS dip). ## Checklist - [x] One topic, on current `main`, Conventional Commit title. - [x] Tested in-game on Windows 11 + RTX 3070 Ti and via targeted `tests/test_*sim_turf*.py` / `tests/test_turf_budget.py`. - [x] `Assisted-by: Antigravity` recorded in commit.
fix(vk): scale actor turf quota by patch pitch area (#2955)
Some checks failed
PR description / Title and description (pull_request_target) Failing after 6s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
b0f470d5b3
Fixes #2955.

Assisted-by: Antigravity
Member

Possibly related, for context:

  • issue #2251 Game: oversized simulated-turf mesh draw exceeds device workgroup limit — Related turf pool/workload limit, but a separate oversized-draw flicker failure.
  • PR #2288 fix(vk): simulated-turf lists stay within the device's workgroups for one draw or dispatch — Merged device-workgroup cap in the simulated-turf pool pipeline; adjacent safeguard.
Possibly related, for context: - issue #2251 Game: oversized simulated-turf mesh draw exceeds device workgroup limit — Related turf pool/workload limit, but a separate oversized-draw flicker failure. - PR #2288 fix(vk): simulated-turf lists stay within the device's workgroups for one draw or dispatch — Merged device-workgroup cap in the simulated-turf pool pipeline; adjacent safeguard.
cfw34683 force-pushed fix/2955-market-turf-density from b0f470d5b3
Some checks failed
PR description / Title and description (pull_request_target) Failing after 6s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
to 61bab746e2
Some checks failed
CI / What the change needs (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Failing after 6s
2026-12-02 20:33:56 +00:00
Compare
Owner
@review
BeanBot left a comment

Recommendation: Approve. The new test does not cover the renderer wiring, so the original bug can return while the test still passes. The quota scaling also leaves the shader’s minimum blade count unscaled for small footprints. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.

The change lowers actor-turf quotas for fine-pitch atlases, reducing the reported pool size and GPU workload on the Temple of Time road. It also changes visible turf density and leaves small-footprint patches at a higher world-space density than intended.

Should fix (1): not blocking, but worth doing before merging.

  • L3: The PR omits the template’s Still to test, Measurements, and Risks sections and the applicable checklist boxes. When: A reviewer cannot tell from the description which hardware runs remain, the exact comparison setup, or the expected visual change and rollback. Do: Complete the repository template with the outstanding runs, measurement setup and results, visible-density risk, rollback, and applicable checklist entries.

Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)

  • L1: The reported performance comparison does not provide repeated runs or frame-time distributions. When: The stated peak pool sizes and FPS ranges indicate a promising improvement, but do not show whether the gain persists across repeated runs or whether frame pacing and 1% lows improve. Do: Run at least two interleaved warm runs per commit on the same route and settings, reporting average FPS, 1% lows, median and p99 frame time, and pool memory for the target area and a representative heavy area.
  • L2: The changed population and visible density have only been reported on Windows with an NVIDIA GPU. When: Players using the actor-turf renderer on AMD, Linux, or Steam Deck receive the same altered population, but the supplied results do not show its appearance or operation on those Tier 1 systems. Do: Run the affected fine-pitch area on AMD and Linux, including Steam Deck, and compare same-position screenshots and gameplay against the base; record the results.

@fix can do L3.

Questions (1) (not confirmed from the code; they don't hold the recommendation)

  • tests/test_turf_budget.py:147: Is there a current failing renderer behavior caused by the missing wiring test?

Checks: Failing on this head, which is behind its base, where it passes: PR description / Title and description (pull_request_target). @rebase (or @fix) brings it up to date and runs it again; not held against it. Still running: 10 checks.

More: does it help, other systems, switches, what was read

Does it help: Unproven. The PR reports a peak reduction from 8,978,432 to 2,490,368 records per pool and an improvement from roughly 26–45 FPS to around 60 FPS on Windows 11 with an RTX 3070 Ti. It does not identify repeated interleaved runs, frame-time distributions, or 1% lows, so the size and consistency of the gain remain unverified.

Other systems: The actor-turf path changes on every GPU and OS when the atlas pitch is below 0.25; the game’s original turf renderer is unaffected. The supplied run covers Windows and NVIDIA only, and does not establish the visual result or behavior on AMD, Linux, or Steam Deck.

Switches: None added, changed, or removed.

Reviewed: 61bab746e2 against b40214d2bb: Read AGENTS.md, CONTRIBUTING.md, the PR template, standards, the full diff and commit, sim_turf_population.h, test_turf_budget.py, the population shader, the turf menu, and the changed function and its caller in vk_draw.cpp. Re-read each changed diff. Skimmed related call sites and test integration; did not read all 14,748 lines of vk_draw.cpp. docs/review-checklist.md and ../Tooling/AGENTS.md are absent. No recorded runs, translations, or generated files were changed.; nothing run (a code review).

Checked and fine:

  • The changed helper receives a finite, positive pitch from the renderer and a bounded density from the packed settings.
  • The commit records the required AI-assistance trailer.
  • No game-derived output, generated shader, API change, or third-party change appears in the diff.

Testing: Read-only review; no code, scripts, builds, or tests were run. CI is still running.

Overlaps and merge order: Not checked; network access is unavailable.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The new test does not cover the renderer wiring, so the original bug can return while the test still passes. The quota scaling also leaves the shader’s minimum blade count unscaled for small footprints. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge. The change lowers actor-turf quotas for fine-pitch atlases, reducing the reported pool size and GPU workload on the Temple of Time road. It also changes visible turf density and leaves small-footprint patches at a higher world-space density than intended. **Should fix (1)**: not blocking, but worth doing before merging. - **L3**: The PR omits the template’s Still to test, Measurements, and Risks sections and the applicable checklist boxes. *When:* A reviewer cannot tell from the description which hardware runs remain, the exact comparison setup, or the expected visual change and rollback. **Do:** Complete the repository template with the outstanding runs, measurement setup and results, visible-density risk, rollback, and applicable checklist entries. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L1**: The reported performance comparison does not provide repeated runs or frame-time distributions. *When:* The stated peak pool sizes and FPS ranges indicate a promising improvement, but do not show whether the gain persists across repeated runs or whether frame pacing and 1% lows improve. **Do:** Run at least two interleaved warm runs per commit on the same route and settings, reporting average FPS, 1% lows, median and p99 frame time, and pool memory for the target area and a representative heavy area. - **L2**: The changed population and visible density have only been reported on Windows with an NVIDIA GPU. *When:* Players using the actor-turf renderer on AMD, Linux, or Steam Deck receive the same altered population, but the supplied results do not show its appearance or operation on those Tier 1 systems. **Do:** Run the affected fine-pitch area on AMD and Linux, including Steam Deck, and compare same-position screenshots and gameplay against the base; record the results. `@fix` can do L3. **Questions (1)** (not confirmed from the code; they don't hold the recommendation) - `tests/test_turf_budget.py:147`: Is there a current failing renderer behavior caused by the missing wiring test? **Checks:** Failing on this head, which is behind its base, where it passes: `PR description / Title and description (pull_request_target)`. `@rebase` (or `@fix`) brings it up to date and runs it again; not held against it. Still running: 10 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven. The PR reports a peak reduction from 8,978,432 to 2,490,368 records per pool and an improvement from roughly 26–45 FPS to around 60 FPS on Windows 11 with an RTX 3070 Ti. It does not identify repeated interleaved runs, frame-time distributions, or 1% lows, so the size and consistency of the gain remain unverified. **Other systems:** The actor-turf path changes on every GPU and OS when the atlas pitch is below 0.25; the game’s original turf renderer is unaffected. The supplied run covers Windows and NVIDIA only, and does not establish the visual result or behavior on AMD, Linux, or Steam Deck. **Switches:** None added, changed, or removed. **Reviewed:** 61bab746e23a against b40214d2bb8d: Read AGENTS.md, CONTRIBUTING.md, the PR template, standards, the full diff and commit, sim_turf_population.h, test_turf_budget.py, the population shader, the turf menu, and the changed function and its caller in vk_draw.cpp. Re-read each changed diff. Skimmed related call sites and test integration; did not read all 14,748 lines of vk_draw.cpp. docs/review-checklist.md and ../Tooling/AGENTS.md are absent. No recorded runs, translations, or generated files were changed.; nothing run (a code review). **Checked and fine:** - The changed helper receives a finite, positive pitch from the renderer and a bounded density from the packed settings. - The commit records the required AI-assistance trailer. - No game-derived output, generated shader, API change, or third-party change appears in the diff. **Testing:** Read-only review; no code, scripts, builds, or tests were run. CI is still running. **Overlaps and merge order:** Not checked; network access is unavailable. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
HumanBean deleted branch fix/2955-market-turf-density 2026-12-02 21:39:42 +00:00
Some checks failed
CI / What the change needs (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Failing after 6s
Some workflows are waiting to be reviewed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 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!3025
No description provided.