fix(vk): the mesh draw log counters stop counting once they stop logging #2522
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2522
Loading…
Reference in a new issue
No description provided.
Delete branch "neotoxic/Longshot:fix-mesh-log-counters"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Two "log the first N" counters run on every mesh draw, and both were incremented on every draw, not only while under
their limit (
if (logged++ < 6)):mesh_program_locked(gpu/vk/vk_shader.cpp): 6 lines of the draw's stages, throughlog_program_stages, whichreads every stage back from guest memory, hashes it and parses it, under
shader_mu;NOP_DRAW_MESH(gpu/vk/vk_replay.cpp): 8 lines of the draw's arguments.After 2^31 mesh draws the signed
intoverflows: undefined behaviour, and in practice it wraps negative, so both logon every mesh draw for the next 2^31,
mesh_program_locked's with its stage read-back and parse. At the game's fewhundred mesh draws a frame that is a long session (tens of hours at 60 fps), a game left running. Each counter now
counts only while it logs (
if (logged < 6 && ++logged)): the same 6 and 8 lines, then nothing.How to see it on
main: not in a play session (it takes 2^31 draws); the test below shows both counters stillcounting after their limit.
I found it in a static read of the renderer's per-draw paths; a sweep of the other 157
x++ < Ncounters ingpu/and
host/found no other one evaluated on every draw (the rest sit in error branches, behind debug switches, or runonce per object or frame).
Testing
Tested: Windows 11 Pro 26300, RTX 5080 (NVIDIA), Ryzen 9 7950X: built as a pack over main's base (
dev.py pack,dev.py rt) and played from thekokiri-startrepo save into Kokiri Forest (5774 draws on arrival, 590-690 after),walking: the log has the 8
vk: mesh draw kindlines and the 6 mesh draw stage lines, as onmain, then none; the gameclosed cleanly (
stop: close work done).tests/test_mesh_log_counters.py(new, two commits: the test, then the fix)fails on
main@be663a08("counter after 1000 mesh draws: 1000, not 6" and "1000, not 8") and passes here, withllvm-mingw's clang++ and with MinGW g++.
run_all.py --strict(all of it): 688 passed, 111 failed, 45 skipped; 110 fail the same onmainon this Windows PC(Linux-only and POSIX checks), and
test_recording_admission.py'sparallelcase crashed once under the 32-way run(0xC0000374) and passes run again alone, as it passed in the same run on
main: it reads none of the changed files.Still to test: None.
Measurements
Verdict: the bug is gone (both counters stop at their limits); nothing to measure in fps: the lines logged are the same.
Setup: Windows 11 Pro 26300, RTX 5080, NVIDIA driver of this PC; the check run on main and here; Kokiri Forest from the kokiri-start repo save, the log lines counted.
be663a0895af4413test_mesh_log_counters.pyRisks
None expected: the same lines are logged, and the counters stay at their limits instead of growing. A revert is enough.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.dev.py pack; Linux: CI's build)Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
Tested in game: Windows 11 Pro 26300, RTX 5080, Ryzen 9 7950X: a pack over main's base, played from the kokiri-start repo save into Kokiri Forest (5774 draws on arrival, 590-690 walking): the 8 'vk: mesh draw kind' lines and 6 mesh draw stage lines as on main, then none; closed cleanly.
The description: the bug, the test failing on main and passing here, the in-game run.
Measurements: the verdict and setup lines.
Testing: the whole suite, not only the changed checks.
WIP: fix(vk): the mesh draw log counters stop counting once they stop loggingto fix(vk): the mesh draw log counters stop counting once they stop logging@review
Recommendation: Approve. The code is ready: only testing is left. The counters now stop at their limits, removing the signed overflow without changing the intended log output. The reported Windows run supports the fix, but the remaining Tier 1 platforms and pending CI checks need results before merge. Recommend approval; not approved on the forge.
The change prevents mesh draw logging from resuming after a very long session. It adds a focused game-free regression test and makes no other intended player-facing change.
Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
Checks: Still running: 9 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes. The reported test leaves the counters at 1000 on the base and at 6 and 8 on this head; the reported Windows game run logged the same initial 6 and 8 lines as main. This is a correctness fix, not a claimed performance gain.
Other systems: Both counters execute in renderer paths shared across platforms. The shader counter is protected by shader_mu; replay is serialized by replay_mu. The reported game run covers NVIDIA on Windows; Linux, AMD and Steam Deck runs were not reported.
Switches: None.
Reviewed:
95af44131eagainstbe663a08a3: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the standards and fix-with-test rules, the diff, both commit messages, the new test, and the changed code with its immediate callers and locking context. Skimmed the replay and shader files outside that context and the test runner and source-cutting helper; the two large changed 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:
Testing: No commands from the pull request were run during review. The author reports a Windows game run and regression-test runs with llvm-mingw clang++ and MinGW g++; the supplied CI status still has checks running.
Overlaps and merge order: Not established from the offline checkout.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.