shader: VICTORY_SHADER_LOOP_LIMIT to find what makes world frames slow #46
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!46
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/46/head"
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?
@9hvn9yt2vk-netizen on GitHub · 2026-11-23 23:45 UTC · original
9hvn9yt2vk-netizen:shader-loop-limit→main· +74 −9 · 4 files · 1 commits · merged 2026-11-24 00:42 UTCTranslated loops stop after 2^20 iterations per lane so that a loop over not yet mirrored data (zeros) cannot run four billion times. A pass where every lane reaches that limit still takes seconds, though: 2^20 iterations times a 4K screen's 8 million pixels is about 10^13 loop bodies. The world's frames now take 1.5-3 s, and loops spinning to the limit on data that reads as zeros are one candidate.
A diagnostics build now reads VICTORY_SHADER_LOOP_LIMIT (decimal or 0x hex, at least 1). If a low value such as 4096 makes world frames much faster, loops hitting the limit are what makes them slow. If not, they are ruled out. The limit is part of the translation, so the shader cache keys on it, and a run that overrides it logs a warning. Release builds always use 2^20.
@kleinerleuge-eng on GitHub · 2026-11-23 23:57 UTC · original
Tested on NVIDIA: RTX 5070 Ti, driver 621.01, Windows 11. Diag build of
15b0091(this PR on97c78d1),VICTORY_SHADER_LOOP_LIMIT=4096 VICTORY_D3D12_DRED=1, no input.Result: with a limit of 4096, loops are ruled out for this card's world hang, and world frames are not faster.
VICTORY_SHADER_LOOP_LIMIT: translated loops stop sooneris logged, so the limit was active. All shaders were translated again (new cache key).preparing(copies).slow host submission ms=4820 lists=32, then0x887A0006(DEVICE_HUNG), and DRED reports no page fault. On97c78d1without this PR the hang came about 20 s after the menus. Here it came later, likely because every shader had to be translated again.a list stopped at command 138 of 155 (op 42), commands 107..155 between its barriers. The listed commands are again only the mesh dispatches withmesh 6b57e37fe499c6e7 / pixel 573d1857e903fab5,mesh 1921f28ef78e3a4b / pixel 80b3065a4477c8c4,mesh 0f73a9ae763e96e2 / pixel ce1481325c93bb70. The earlier run stopped at command 148 of 175 in the same pattern.Side note: four of the six hung submissions on this card since
8c26061took 4.82–4.83 s (4828, 4832, 4833, 4820 ms; the other two took 5990 and 6578 ms). That looks like the TDR's own timing, so the work there never finishes, rather than slowly completing. Since bounded loops don't change it, something in those mesh passes that a loop limit can't bound (for example a group barrier in divergent flow, or a wave-size assumption in a mesh shader running at 32 lanes on NVIDIA) seems more likely. That is a guess. I have not checked those shaders.AI-assisted (Claude Code); no game files attached.
@DaviTostes on GitHub · 2026-11-23 23:59 UTC · original
Tested
15b0091stacked on #39 on Arch Linux x86_64, rustc 1.98.1: pass.mainalone does not build on Linux (E0425 invictory-gpu), so the check uses #39 as the base; the merge is clean.cargo test --workspace: 155 passed, 0 failed, 3 ignored — the loop-limit switch does not change any test result.AI-assisted (DeepSeek V4.1 Flash coding agent).
@HenriqueSBueno on GitHub · 2026-11-24 00:29 UTC · original · edited 2026-11-24 00:45 UTC
Tested with
VICTORY_SHADER_LOOP_LIMIT=4096on NVIDIA. Windows 11, RTX 3080 (driver 616.92), retail title.mainat97c78d1+ #45 + #89 + #54 + this PR, diagnostics build, with a fresh translation under the new limit.slow host submission ms=11564 lists=30, all compute pipelines, thendevice removed (0x887A0004).So on this GPU, loops running to the limit don't explain the hang or the slow frames, at least not with a limit of 4096. I can run DRED (
VICTORY_D3D12_DRED=1) on the next one if it helps narrow the submission down.AI-assisted (Claude Code)