fix(vk): simulated-turf lists stay within the device's workgroups for one draw or dispatch #2288

Merged
HumanBean merged 3 commits from pepe999/Longshot:fix/sim-turf-mesh-limit into main 2026-11-23 15:51:28 +00:00
Contributor

Summary

At very wide simulated-turf ranges, turf patches flicker all over on AMD cards that draw with native mesh shaders, also near the player and standing still. See #2251, which has the steps on main (Hyrule Field, a fade endpoint towards 195, density 100 %, 24 blades at least).

The game's programs turn a simulated-turf list's record count into the workgroups of one indirect command: one for every 32 records of a pool (its mesh draw), one for every 64 of a blade list (the pool producer's dispatch). The only bound on that count is the length of the list's private buffer, and the buffer's length was bounded by the storage buffer range alone. On AMD a pool past 2,097,120 records asks for more than the 65,535 groups of maxMeshWorkGroupCount[0], an invalid draw (the issue measured 70,195).

Now a list's most records also follow the limit of what reads it: the native mesh draw's for a pool (maxMeshWorkGroupCount[0], and the total count), the compute dispatch's for a blade list and for a pool drawn through the compute fallback. A device with room (NVIDIA's mesh draws, RADV's compute dispatch) keeps the size it had.

What it does not do: past the limit the overflow is still dropped in the order the game's atomics give it, so some churn can remain there. Dropping the farthest first (the near-to-far buckets noted in #2241) is a change of its own.

Read first: sim_turf_max_records in gpu/vk/vk_draw.cpp; the limit is read in gpu/vk/vk_main.cpp (max_mesh_groups).

See #2251.

Testing

Tested: Linux, RX 6700 XT (RADV, Mesa 26.2.7): Hyrule Field, child, standing, ten runs (five of main, five of this PR), no GPU error in any log and every run closed cleanly. These ran on RADV's default compute path, whose dispatch limit is 4,294,967,295 there, and with the default turf settings (peak demand about 800 of 138,240 pool records): they show nothing else broke, not the limit at work. The limit itself is covered by the game-free test only: tests/test_sim_turf_group_limit.py fails on main (queried(true, 65535, 4194304) == 65535: the limit is never asked for) and passes here. Six broken versions of the fix each fail it: the limit dropped, the fallback ignored, the query's assignment gone, its structure out of the chain, the total count left out, the query made with the extension off. g++ only; no clang on this PC.

The whole suite (tests/run_all.py, not --strict) at 19bfda96 and at main 753fb5af: 882 passed, 14 failed, 62 skipped here; 881 passed, the same 14 failed, 62 skipped on main. The 14, none new here: nx2/test_mesh_first_types, test_appimage_player_build, test_appimage_source_headers, test_audio_source, test_builtin_compute_unoptimized, test_dev_packs, test_image_view_retry, test_link_skip, test_longshot_launch, test_mise_build, test_mods_list, test_options_path, test_pipeline_state_computes, test_thinlto_tls. 44 of the skips are tools this PC lacks (clang, clang++, spirv-val, glslang, dav1d). The renderer was built whole and linked, its symbols checked, at 19bfda96.

Still to test:

  • Windows, AMD RX 7000/9000 drawing with native mesh shaders: Hyrule Field at the settings of #2251, standing still, main against this PR, expecting the patches' flicker gone or only at the far edge, no device lost, and no pool resized past 2,097,120 records in the log (by hand: the farm can't set the turf rows or judge flicker).
  • Windows, AMD RX 7000/9000 and NVIDIA: the farm's offered run, Hyrule Field with the default turf, main against this PR, expecting no change (@Beanstalk, needs a BigBean).

Measurements

Verdict: a fix: the oversized draw's size is bounded in the test; no fps difference seen at the default settings.

Setup: Linux 7.3.4, RX 6700 XT, RADV Mesa 26.2.7; Hyrule Field, child (open, far view), window 1280x720, output 2560x1440, resolution 67 %, frame generation and V-Sync off, uncapped (HOS_FPS_MAX=1000); the frame trace, 60 s each after a warm-up, interleaved pairs (dev.py ab). Measured at 215bb798 against its merge base; this head is the same change rebased.

Before: main @ b9bd74a2 After: this PR @ 215bb798
test_sim_turf_group_limit.py fails: more than 65,535 groups passes: 65,535 groups
fps, the first A/B (each run) 71.7 / 123.0 76.7 / 122.7
fps, the second A/B (each run) 75.3 / 122.6 / 122.3 122.5 / 122.9 / 120.7
1% low fps, the second A/B 37.7 / 102.4 / 101.6 97.8 / 102.6 / 98.4

The first run of main in each A/B, and the first of this PR in the first, were far slower (72-77 fps) than every other (121-123); the cause isn't known, and no conclusion is drawn from them. dev.py ab wrote no section for the second A/B (exit 3): the turf menu rows read "Load an area" at one moment of B2 and their values in the others; the options files were the same.

A1: 4520 frames in 60 s, 75.3 fps, median 12.16 ms, p99 26.55 ms, 1% low 37.7 fps, 2 cold frames
B1: 7348 frames in 60 s, 122.5 fps, median 8.07 ms, p99 10.23 ms, 1% low 97.8 fps, 0 cold frames
A2: 7356 frames in 60 s, 122.6 fps, median 8.09 ms, p99 9.77 ms, 1% low 102.4 fps, 0 cold frames
B2: 7372 frames in 60 s, 122.9 fps, median 8.07 ms, p99 9.75 ms, 1% low 102.6 fps, 0 cold frames
A3: 7336 frames in 60 s, 122.3 fps, median 8.10 ms, p99 9.84 ms, 1% low 101.6 fps, 0 cold frames
B3: 7244 frames in 60 s, 120.7 fps, median 8.19 ms, p99 10.17 ms, 1% low 98.4 fps, 1 cold frames
vk: simulated turf: frame 41038: ... peak demand blade 799/143360, pool 788/138240 records

Risks

A pool that needs more than the device's limit is now clipped at it, where the oversized draw was submitted before. Nothing changes at the game's settings (4,320 groups a pool). No switch of its own: RX_VK_SIM_TURF_POOLS=0 goes back to the game's lists, and a revert is enough. Saves, options and caches are untouched; players notice nothing after updating.

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. (It ran, but this PC's default path never reaches the limit: waiting for a run by hand on native mesh at the reported settings.)
  • mise run test passes (any failure that also fails on main is named). (Run without --strict: spirv-val, glslang and clang are missing here, and those checks skip; see Testing.)
  • 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 fix: a game-free test that fails on main and passes here.
  • 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.

🤖 Generated with Claude Code

## Summary At very wide simulated-turf ranges, turf patches flicker all over on AMD cards that draw with native mesh shaders, also near the player and standing still. See #2251, which has the steps on `main` (Hyrule Field, a fade endpoint towards 195, density 100 %, 24 blades at least). The game's programs turn a simulated-turf list's record count into the workgroups of one indirect command: one for every 32 records of a pool (its mesh draw), one for every 64 of a blade list (the pool producer's dispatch). The only bound on that count is the length of the list's private buffer, and the buffer's length was bounded by the storage buffer range alone. On AMD a pool past 2,097,120 records asks for more than the 65,535 groups of `maxMeshWorkGroupCount[0]`, an invalid draw (the issue measured 70,195). Now a list's most records also follow the limit of what reads it: the native mesh draw's for a pool (`maxMeshWorkGroupCount[0]`, and the total count), the compute dispatch's for a blade list and for a pool drawn through the compute fallback. A device with room (NVIDIA's mesh draws, RADV's compute dispatch) keeps the size it had. What it does not do: past the limit the overflow is still dropped in the order the game's atomics give it, so some churn can remain there. Dropping the farthest first (the near-to-far buckets noted in #2241) is a change of its own. Read first: `sim_turf_max_records` in `gpu/vk/vk_draw.cpp`; the limit is read in `gpu/vk/vk_main.cpp` (`max_mesh_groups`). See #2251. ## Testing **Tested:** Linux, RX 6700 XT (RADV, Mesa 26.2.7): Hyrule Field, child, standing, ten runs (five of `main`, five of this PR), no GPU error in any log and every run closed cleanly. These ran on RADV's default **compute** path, whose dispatch limit is 4,294,967,295 there, and with the default turf settings (peak demand about 800 of 138,240 pool records): **they show nothing else broke, not the limit at work.** The limit itself is covered by the game-free test only: `tests/test_sim_turf_group_limit.py` fails on `main` (`queried(true, 65535, 4194304) == 65535`: the limit is never asked for) and passes here. Six broken versions of the fix each fail it: the limit dropped, the fallback ignored, the query's assignment gone, its structure out of the chain, the total count left out, the query made with the extension off. g++ only; no clang on this PC. The whole suite (`tests/run_all.py`, not `--strict`) at 19bfda96 and at `main` 753fb5af: 882 passed, 14 failed, 62 skipped here; 881 passed, the same 14 failed, 62 skipped on `main`. The 14, none new here: nx2/test_mesh_first_types, test_appimage_player_build, test_appimage_source_headers, test_audio_source, test_builtin_compute_unoptimized, test_dev_packs, test_image_view_retry, test_link_skip, test_longshot_launch, test_mise_build, test_mods_list, test_options_path, test_pipeline_state_computes, test_thinlto_tls. 44 of the skips are tools this PC lacks (clang, clang++, spirv-val, glslang, dav1d). The renderer was built whole and linked, its symbols checked, at 19bfda96. **Still to test:** - Windows, AMD RX 7000/9000 drawing with native mesh shaders: Hyrule Field at the settings of #2251, standing still, `main` against this PR, expecting the patches' flicker gone or only at the far edge, no device lost, and no pool resized past 2,097,120 records in the log (by hand: the farm can't set the turf rows or judge flicker). - Windows, AMD RX 7000/9000 and NVIDIA: the farm's offered run, Hyrule Field with the default turf, `main` against this PR, expecting no change (@Beanstalk, needs a BigBean). ## Measurements **Verdict:** a fix: the oversized draw's size is bounded in the test; no fps difference seen at the default settings. Setup: Linux 7.3.4, RX 6700 XT, RADV Mesa 26.2.7; Hyrule Field, child (open, far view), window 1280x720, output 2560x1440, resolution 67 %, frame generation and V-Sync off, uncapped (`HOS_FPS_MAX=1000`); the frame trace, 60 s each after a warm-up, interleaved pairs (`dev.py ab`). Measured at 215bb798 against its merge base; this head is the same change rebased. | | Before: main @ b9bd74a2 | After: this PR @ 215bb798 | |---|---|---| | `test_sim_turf_group_limit.py` | fails: more than 65,535 groups | passes: 65,535 groups | | fps, the first A/B (each run) | 71.7 / 123.0 | 76.7 / 122.7 | | fps, the second A/B (each run) | 75.3 / 122.6 / 122.3 | 122.5 / 122.9 / 120.7 | | 1% low fps, the second A/B | 37.7 / 102.4 / 101.6 | 97.8 / 102.6 / 98.4 | The first run of `main` in each A/B, and the first of this PR in the first, were far slower (72-77 fps) than every other (121-123); the cause isn't known, and no conclusion is drawn from them. `dev.py ab` wrote no section for the second A/B (exit 3): the turf menu rows read "Load an area" at one moment of B2 and their values in the others; the options files were the same. ``` A1: 4520 frames in 60 s, 75.3 fps, median 12.16 ms, p99 26.55 ms, 1% low 37.7 fps, 2 cold frames B1: 7348 frames in 60 s, 122.5 fps, median 8.07 ms, p99 10.23 ms, 1% low 97.8 fps, 0 cold frames A2: 7356 frames in 60 s, 122.6 fps, median 8.09 ms, p99 9.77 ms, 1% low 102.4 fps, 0 cold frames B2: 7372 frames in 60 s, 122.9 fps, median 8.07 ms, p99 9.75 ms, 1% low 102.6 fps, 0 cold frames A3: 7336 frames in 60 s, 122.3 fps, median 8.10 ms, p99 9.84 ms, 1% low 101.6 fps, 0 cold frames B3: 7244 frames in 60 s, 120.7 fps, median 8.19 ms, p99 10.17 ms, 1% low 98.4 fps, 1 cold frames vk: simulated turf: frame 41038: ... peak demand blade 799/143360, pool 788/138240 records ``` ## Risks A pool that needs more than the device's limit is now clipped at it, where the oversized draw was submitted before. Nothing changes at the game's settings (4,320 groups a pool). No switch of its own: `RX_VK_SIM_TURF_POOLS=0` goes back to the game's lists, and a revert is enough. Saves, options and caches are untouched; players notice nothing after updating. ## Checklist ### Ready for review - [x] 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. (It ran, but this PC's default path never reaches the limit: waiting for a run by hand on native mesh at the reported settings.) - [ ] `mise run test` passes (any failure that also fails on `main` is named). (Run without `--strict`: spirv-val, glslang and clang are missing here, and those checks skip; see Testing.) - [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 fix: a game-free test that fails on `main` and passes here. - [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. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Fails on main: the list's length comes from the storage buffer range alone,
so a pool can ask one indirect mesh draw for more workgroups than the
device's maxMeshWorkGroupCount[0] (issue 2251).

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(vk): simulated-turf lists stay within the device's workgroups for one draw or dispatch
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 4s
beanstalk/approval can't be tested as asked: see the farm's comment
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
19bfda9641
A list's reader runs a workgroup for every 32 pool records (64 of a blade
list) in one indirect command whose count the game's program takes from the
list's length. The length was bounded by the storage buffer range alone: on
AMD a pool past 2,097,120 records asked for more than the 65,535 groups of
maxMeshWorkGroupCount[0], an invalid draw, and the turf flickered all over
(issue 2251). The list's most records now also follow the limit of what
reads it: the native mesh draw's for a pool, the compute dispatch's for a
blade list and for a pool drawn through the compute fallback.

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Contributor

Tested in game: Linux, RX 6700 XT (RADV, Mesa 26.2.7), Hyrule Field, child, default turf settings: ten runs (five of main, five of this change), no GPU error in any log, all closed cleanly. It ran on RADV's default compute path, where this limit never applies, and demand was about 800 of 138,240 records: it shows nothing else broke, not the limit at work. Native mesh was not run here (RADV's native path can hang the GPU).

Tested in game: Linux, RX 6700 XT (RADV, Mesa 26.2.7), Hyrule Field, child, default turf settings: ten runs (five of main, five of this change), no GPU error in any log, all closed cleanly. It ran on RADV's default compute path, where this limit never applies, and demand was about 800 of 138,240 records: it shows nothing else broke, not the limit at work. Native mesh was not run here (RADV's native path can hang the GPU).
Author
Contributor

@Beanstalk two runs of this PR against main: (1) Windows, an AMD RX 7000 or 9000 drawing with native mesh shaders (an RX 6000 takes the compute fallback by default), Hyrule Field by day, standing still with a broad view of the turf, first the default turf settings, then the Simulated turf page at fade endpoint 195 (or as near as the row allows), density 100 %, 24 blades at least: expecting no device lost and no VkResult error on either, and on this PR no 'vk: simulated turf: pool ... resized' line past 2097120 records; (2) Windows, any NVIDIA RTX, Hyrule Field with the default turf settings: expecting the same fps and the same 'vk: simulated turf' lines as main. Whether the turf patches still flicker is for a person to judge by eye.

@Beanstalk two runs of this PR against main: (1) Windows, an AMD RX 7000 or 9000 drawing with native mesh shaders (an RX 6000 takes the compute fallback by default), Hyrule Field by day, standing still with a broad view of the turf, first the default turf settings, then the Simulated turf page at fade endpoint 195 (or as near as the row allows), density 100 %, 24 blades at least: expecting no device lost and no VkResult error on either, and on this PR no 'vk: simulated turf: pool ... resized' line past 2097120 records; (2) Windows, any NVIDIA RTX, Hyrule Field with the default turf settings: expecting the same fps and the same 'vk: simulated turf' lines as main. Whether the turf patches still flicker is for a person to judge by eye.
Member

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

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

Possibly related, for context:

  • issue #1621 Game: Dense grass patches flicker or disappear while modding grass fade — Earlier report of high-density simulated-turf flicker on RX 7900 XT
Possibly related, for context: - issue #1621 Game: Dense grass patches flicker or disappear while modding grass fade — Earlier report of high-density simulated-turf flicker on RX 7900 XT
Author
Contributor

The rebased head 19bfda96 was built whole and linked, its symbols checked; the description says so now.

The rebased head 19bfda96 was built whole and linked, its symbols checked; the description says so now.
Owner
@review
BeanBot left a comment

Recommendation: Approve. The capacity calculation is covered, but the test bypasses the device-property initialization that makes the fix work on native mesh shaders. The affected path also still needs an in-game comparison at the reported settings. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.

The change limits adaptive turf-list capacities to the workgroup count accepted by their draw or dispatch. It should prevent oversized indirect commands, at the cost of dropping records once the device limit is reached; the visible result at that limit remains unverified.

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

  • L1 tests/test_sim_turf_group_limit.py:70: The test supplies the mesh limit directly and never exercises its query or assignment in create_device. (more on the line) Do: Add a game-free check that exercises the property-chain query and assignment, including both the X and total limits, and fails when that initialization is removed.

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

  • L2 gpu/vk/vk_draw.cpp:497: The affected native mesh path has not been tested at the reported turf settings. (more on the line) Do: Compare main and this head in Hyrule Field on Windows AMD native mesh at the reported settings, inspect the turf by eye and check the logs for errors and the installed capacity.

@fix can do L1.

Checks: Still running: 9 checks.

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

Does it help: Unproven in the affected game scenario. The author's game-free test reports a cap of 65,535 groups, but its device limit is supplied by the harness; the Linux RX 6700 XT runs used the compute path and reached only about 800 of 138,240 pool records. The reported frame-rate runs were at default settings and do not exercise the fix.

Other systems: The calculation also applies to blade-list dispatches and compute-fallback pool draws; the reported RADV runs covered the fallback at default demand, not its limit. Native AMD mesh and Windows NVIDIA runs are still outstanding. Saves, options, shaders and the renderer API are unchanged.

Switches: None added, changed or removed.

Reviewed: 19bfda9641 against 753fb5af68: Read the changed test in full, the complete diff and commit messages, repository rules and PR template, and the relevant device initialization, turf binding, capacity policy, shader and draw paths. Skimmed the test runner and related references; the large renderer files were not read in full. docs/review-checklist.md and the adjacent Tooling AGENTS.md were absent.; nothing run (a code review).

Checked and fine:

  • The mesh property query takes the smaller of the X and total workgroup limits, and its pNext link is cleared before float controls are stored.
  • The capacity arithmetic uses 64-bit intermediates and rounds the storage-bound capacity down to whole groups.
  • Both commits have AI-assistance trailers; no game-derived files, generated files or third-party files are added.
  • The test runner supplies its selected C++ compiler to the new test.

Testing: Read-only review; no commands from the project, builds or tests were run. CI is still running.

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


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

**Recommendation: Approve.** The capacity calculation is covered, but the test bypasses the device-property initialization that makes the fix work on native mesh shaders. The affected path also still needs an in-game comparison at the reported settings. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge. The change limits adaptive turf-list capacities to the workgroup count accepted by their draw or dispatch. It should prevent oversized indirect commands, at the cost of dropping records once the device limit is reached; the visible result at that limit remains unverified. **Should fix (1)**: not blocking, but worth doing before merging. - **L1** `tests/test_sim_turf_group_limit.py:70`: The test supplies the mesh limit directly and never exercises its query or assignment in create_device. (more on the line) **Do:** Add a game-free check that exercises the property-chain query and assignment, including both the X and total limits, and fails when that initialization is removed. **Testing before merging (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L2** `gpu/vk/vk_draw.cpp:497`: The affected native mesh path has not been tested at the reported turf settings. (more on the line) **Do:** Compare main and this head in Hyrule Field on Windows AMD native mesh at the reported settings, inspect the turf by eye and check the logs for errors and the installed capacity. `@fix` can do L1. **Checks:** Still running: 9 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven in the affected game scenario. The author's game-free test reports a cap of 65,535 groups, but its device limit is supplied by the harness; the Linux RX 6700 XT runs used the compute path and reached only about 800 of 138,240 pool records. The reported frame-rate runs were at default settings and do not exercise the fix. **Other systems:** The calculation also applies to blade-list dispatches and compute-fallback pool draws; the reported RADV runs covered the fallback at default demand, not its limit. Native AMD mesh and Windows NVIDIA runs are still outstanding. Saves, options, shaders and the renderer API are unchanged. **Switches:** None added, changed or removed. **Reviewed:** 19bfda964106 against 753fb5af6860: Read the changed test in full, the complete diff and commit messages, repository rules and PR template, and the relevant device initialization, turf binding, capacity policy, shader and draw paths. Skimmed the test runner and related references; the large renderer files were not read in full. docs/review-checklist.md and the adjacent Tooling AGENTS.md were absent.; nothing run (a code review). **Checked and fine:** - The mesh property query takes the smaller of the X and total workgroup limits, and its pNext link is cleared before float controls are stored. - The capacity arithmetic uses 64-bit intermediates and rounds the storage-bound capacity down to whole groups. - Both commits have AI-assistance trailers; no game-derived files, generated files or third-party files are added. - The test runner supplies its selected C++ compiler to the new test. **Testing:** Read-only review; no commands from the project, builds or tests were run. CI is still running. **Overlaps and merge order:** Not checked; network access is closed. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
@ -495,0 +494,4 @@
// (a list's reader runs a workgroup for every `group` records, in one indirect command the game's program writes from the
// list's length: a pool's mesh draw (its compute fallback's dispatch), a blade list's dispatch. Past what the device takes in
// one the command is invalid: AMD's 65535 groups are 2,097,120 pool records, and a longer pool's turf flickered all over)
const uint64_t groups = pool && !dev.uses_mesh_fallback(false) ? dev.max_mesh_groups : dev.props.limits.maxComputeWorkGroupCount[0];
Member

L2 (should fix): The affected native mesh path has not been tested at the reported turf settings.

When: At a fade endpoint near 195 with high density on Windows AMD native mesh, the calculation caps the list, but the existing runs neither reach that cap nor show whether the reported flicker and invalid draw are gone.

Do: Compare main and this head in Hyrule Field on Windows AMD native mesh at the reported settings, inspect the turf by eye and check the logs for errors and the installed capacity.

**L2** (should fix): The affected native mesh path has not been tested at the reported turf settings. *When:* At a fade endpoint near 195 with high density on Windows AMD native mesh, the calculation caps the list, but the existing runs neither reach that cap nor show whether the reported flicker and invalid draw are gone. **Do:** Compare main and this head in Hyrule Field on Windows AMD native mesh at the reported settings, inspect the turf by eye and check the logs for errors and the installed capacity.
@ -0,0 +67,4 @@
int main() {
// AMD: 65535 groups a mesh draw. The reported scene's demand asked for 70,195
dev.max_mesh_groups = 65535;
Member

L1 (should fix): The test supplies the mesh limit directly and never exercises its query or assignment in create_device.

When: If the new assignment to dev.max_mesh_groups in vk_main.cpp is removed, the test still passes, while the real device retains UINT32_MAX and an AMD native mesh draw can again exceed 65,535 groups.

Do: Add a game-free check that exercises the property-chain query and assignment, including both the X and total limits, and fails when that initialization is removed.

**L1** (should fix): The test supplies the mesh limit directly and never exercises its query or assignment in create_device. *When:* If the new assignment to dev.max_mesh_groups in vk_main.cpp is removed, the test still passes, while the real device retains UINT32_MAX and an AMD native mesh draw can again exceed 65,535 groups. **Do:** Add a game-free check that exercises the property-chain query and assignment, including both the X and total limits, and fails when that initialization is removed.
Member

Beanstalk test farm

Commit fddd0aa · approved by nobody yet · dashboard

A member of BigBeans can review this commit and comment @Beanstalk to test it.

<!-- beanstalk:sticky --> ### Beanstalk test farm Commit `fddd0aa` · approved by nobody yet · [dashboard](https://beanstalk.magicbean.dev/prs/2288) A member of `BigBeans` can review this commit and comment `@Beanstalk` to test it.
Author
Contributor

L1 of the review: the check now cuts create_device's property query out of vk_main.cpp and runs it (the x and the total limit, and only with the extension on); it fails on main and on each of six broken versions of the fix. It is a commit of its own on top (fddd0aa2), the fix unchanged.

L2 and the farm: the farm can't set the turf rows, so the reported settings need a person with an RX 7000/9000 on Windows (@erlo68's RX 7900 XT is the reporter's). Its default-turf alternative is welcome as a smoke run; a BigBean has to ask for it. This PC can't do it: RADV's default is the compute path.

L1 of the review: the check now cuts create_device's property query out of vk_main.cpp and runs it (the x and the total limit, and only with the extension on); it fails on main and on each of six broken versions of the fix. It is a commit of its own on top (fddd0aa2), the fix unchanged. L2 and the farm: the farm can't set the turf rows, so the reported settings need a person with an RX 7000/9000 on Windows (@erlo68's RX 7900 XT is the reporter's). Its default-turf alternative is welcome as a smoke run; a BigBean has to ask for it. This PC can't do it: RADV's default is the compute path.
test(vk): the simulated-turf check runs the query of the mesh draw's limit too
Some checks failed
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
beanstalk/approval not approved yet
PR description / Description follows the template (pull_request_target) Failing after 13s
fddd0aa2ce
The check was given the limit; create_device's query of it is now cut out
and run as well, so a limit nobody asks for, or asks for with the extension
off, or the total count left out, fails here.

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor

Tested the current head fddd0aa2 on Windows 11 with an RX 7900 XT (native mesh shaders, driver field 0x8001a0), against the exact PR base 753fb5af.

tests/run_all.py sim_turf_group_limit --strict passes with the Visual Studio Clang toolchain.

For the in-game check I entered adult Hyrule Field from adult Market (the town-gate view has substantially more turf than the debug teleport), then held the camera still at 3440x1440 with fade 100 -> 195, density 100, minimum blades 24 and far power 0.5.

The baseline reached 2,795,114 requested main-pool records and grew that pool to 3,493,920. That demand corresponds to 87,348 mesh workgroups, above this device's reported 65,535 X/total mesh-group limit. With this PR, a comparable run reached 2,801,363 requested records but both main pools stopped at exactly 2,097,120 records (65,535 * 32). There were no device-loss, validation-error or crash messages.

I captured 360 images beginning immediately after applying the stress range and another 240 after settling on each side. The capture requests landed every 3 presents at the median. An adjacent-image terrain-cell check found no frames with simultaneous reversals in 10 or more cells on either baseline or PR in these runs, so I did not reproduce the old large-dropout visual signature at this particular stationary view. This still confirms that the PR enforces the valid one-draw prefix during a genuinely over-limit workload without introducing an obvious regression.

One caveat: this is intentionally device-dependent, not an AMD-specific constant. Other GPUs/drivers can report different maxMeshWorkGroupCount[0] / maxMeshWorkGroupTotalCount values (and the compute fallback has its own maxComputeWorkGroupCount[0]), so their resulting caps can differ. Also, this patch caps the list but does not order admitted records near-to-far; reservations still arrive in concurrent atomic order. When demand exceeds the cap, the invalid oversized command is avoided, but residual patch churn/flicker is still possible and this test should not be read as proving all visual flicker is gone.

Tested the current head `fddd0aa2` on Windows 11 with an RX 7900 XT (native mesh shaders, driver field `0x8001a0`), against the exact PR base `753fb5af`. `tests/run_all.py sim_turf_group_limit --strict` passes with the Visual Studio Clang toolchain. For the in-game check I entered adult Hyrule Field from adult Market (the town-gate view has substantially more turf than the debug teleport), then held the camera still at 3440x1440 with fade 100 -> 195, density 100, minimum blades 24 and far power 0.5. The baseline reached 2,795,114 requested main-pool records and grew that pool to 3,493,920. That demand corresponds to 87,348 mesh workgroups, above this device's reported 65,535 X/total mesh-group limit. With this PR, a comparable run reached 2,801,363 requested records but both main pools stopped at exactly 2,097,120 records (`65,535 * 32`). There were no device-loss, validation-error or crash messages. I captured 360 images beginning immediately after applying the stress range and another 240 after settling on each side. The capture requests landed every 3 presents at the median. An adjacent-image terrain-cell check found no frames with simultaneous reversals in 10 or more cells on either baseline or PR in these runs, so I did not reproduce the old large-dropout visual signature at this particular stationary view. This still confirms that the PR enforces the valid one-draw prefix during a genuinely over-limit workload without introducing an obvious regression. One caveat: this is intentionally device-dependent, not an AMD-specific constant. Other GPUs/drivers can report different `maxMeshWorkGroupCount[0]` / `maxMeshWorkGroupTotalCount` values (and the compute fallback has its own `maxComputeWorkGroupCount[0]`), so their resulting caps can differ. Also, this patch caps the list but does not order admitted records near-to-far; reservations still arrive in concurrent atomic order. When demand exceeds the cap, the invalid oversized command is avoided, but residual patch churn/flicker is still possible and this test should not be read as proving all visual flicker is gone.
Owner
@review
BeanBot left a comment

Recommendation: Approve. The test now exercises the device property query, and the reported Windows native-mesh run confirms the pool is capped at the device limit under an over-limit workload. The run did not reproduce the original flicker, so its visual resolution remains unproven. Recommend approval; not approved on the forge.

Limits simulated-turf lists to the workgroup count their draw or dispatch can accept, avoiding an invalid oversized command at extreme ranges. Excess records are still dropped in atomic order, so some patch churn may remain.

Since the last review (on 19bfda9641)
Resolved: L1 (The test supplies the mesh limit directly and never exercises its query or assignment in c…); L2 (The affected native mesh path has not been tested at the reported turf settings.)

Checks: Still running: 9 checks.

Also noticed (3; not asked for, not blocking)
  • The reported native-mesh run confirms the valid cap but does not establish that the original flicker is gone.
  • The requested NVIDIA default-turf smoke run remains unreported.
  • Several CI checks are still running.
More: does it help, other systems, switches, what was read

Does it help: Yes for the invalid-command limit: on an RX 7900 XT, the baseline requested 87,348 mesh groups against a 65,535 limit, while this head capped both pools at 2,097,120 records. The tester did not reproduce the original visual dropout on either version, so the flicker fix itself is unproven.

Other systems: The limit also applies to compute fallback and blade-list dispatches; the game-free test covers their selection. Linux RADV default-compute runs showed no GPU errors; NVIDIA and other affected hardware have not been reported tested.

Switches: None added, changed or removed. The existing RX_VK_SIM_TURF_POOLS=0 disables renderer-owned pools.

Reviewed: fddd0aa2ce against 753fb5af68: Read the complete diff, commit list, test file as shown in the diff, repository AGENTS.md, CONTRIBUTING.md and pull request template; inspected the changed portions of the renderer files through the diff, not those files in full.; nothing run (a code review).

Checked and fine:

  • The test checks the smaller of the mesh X and total limits and exercises the compute fallback limit.
  • The reported native-mesh run found no device-loss, validation-error or crash messages.

Testing: No commands or tests were run for this review. The author reports the game-free test passing with Visual Studio Clang on the current head, and the native-mesh game run is described in the tester's comment.

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


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

**Recommendation: Approve.** The test now exercises the device property query, and the reported Windows native-mesh run confirms the pool is capped at the device limit under an over-limit workload. The run did not reproduce the original flicker, so its visual resolution remains unproven. Recommend approval; not approved on the forge. Limits simulated-turf lists to the workgroup count their draw or dispatch can accept, avoiding an invalid oversized command at extreme ranges. Excess records are still dropped in atomic order, so some patch churn may remain. **Since the last review** (on 19bfda964106) Resolved: L1 (The test supplies the mesh limit directly and never exercises its query or assignment in c…); L2 (The affected native mesh path has not been tested at the reported turf settings.) **Checks:** Still running: 9 checks. <details> <summary>Also noticed (3; not asked for, not blocking)</summary> - The reported native-mesh run confirms the valid cap but does not establish that the original flicker is gone. - The requested NVIDIA default-turf smoke run remains unreported. - Several CI checks are still running. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes for the invalid-command limit: on an RX 7900 XT, the baseline requested 87,348 mesh groups against a 65,535 limit, while this head capped both pools at 2,097,120 records. The tester did not reproduce the original visual dropout on either version, so the flicker fix itself is unproven. **Other systems:** The limit also applies to compute fallback and blade-list dispatches; the game-free test covers their selection. Linux RADV default-compute runs showed no GPU errors; NVIDIA and other affected hardware have not been reported tested. **Switches:** None added, changed or removed. The existing RX_VK_SIM_TURF_POOLS=0 disables renderer-owned pools. **Reviewed:** fddd0aa2ce38 against 753fb5af6860: Read the complete diff, commit list, test file as shown in the diff, repository AGENTS.md, CONTRIBUTING.md and pull request template; inspected the changed portions of the renderer files through the diff, not those files in full.; nothing run (a code review). **Checked and fine:** - The test checks the smaller of the mesh X and total limits and exercises the compute fallback limit. - The reported native-mesh run found no device-loss, validation-error or crash messages. **Testing:** No commands or tests were run for this review. The author reports the game-free test passing with Visual Studio Clang on the current head, and the native-mesh game run is described in the tester's comment. **Overlaps and merge order:** Not checked; network access is closed. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
Contributor

@BeanBot
The native-mesh run establishes the backend guarantee: submitted draws/dispatches stay within the device limit and excess reservations are discarded safely. The discard still follows atomic reservation order, so the set of surviving turf patches change frame-to-frame, still leading to constant flickering on seemingly random patches, even after savely discarding overflow. We’re testing a separate near-to-far ordering follow-up intended to make overflow discard the farthest patches first, and we’ll report its moving-camera visual result separately.

@BeanBot The native-mesh run establishes the backend guarantee: submitted draws/dispatches stay within the device limit and excess reservations are discarded safely. The discard still follows atomic reservation order, so the set of surviving turf patches change frame-to-frame, still leading to constant flickering on seemingly random patches, even after savely discarding overflow. We’re testing a separate near-to-far ordering follow-up intended to make overflow discard the farthest patches first, and we’ll report its moving-camera visual result separately.
HumanBean changed title from WIP: fix(vk): simulated-turf lists stay within the device's workgroups for one draw or dispatch to fix(vk): simulated-turf lists stay within the device's workgroups for one draw or dispatch 2026-11-23 15:51:21 +00:00
HumanBean deleted branch fix/sim-turf-mesh-limit 2026-11-23 15:51:29 +00:00
Some checks failed
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
beanstalk/approval not approved yet
PR description / Description follows the template (pull_request_target) Failing after 13s
Some workflows are waiting to be reviewed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
5 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!2288
No description provided.