Repository navigation
perf(shader): leave translated loops after 2^14 passes, not 2^20 - #123
Merged
Merged
Conversation
A loop whose bound the host has not mirrored yet runs to the limit in every lane that reaches it, and a dispatch lasts as long as its slowest lane. On an Apple M5 GPU one lane's run to 2^20 takes 60 to 195 ms, and to 2^14 takes 1 to 3 ms. Upstream measured one world compute program (00167d58cc5a78d7, up to six runs to the limit per dispatch) at about 90% of a world frame's GPU time on an RTX 2080 Ti (Marvisak/VIctory#1819, the same change). VICTORY_SHADER_LOOP_LIMIT still overrides the limit in diagnostics builds, and the shader cache keys on it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Owner
|
Thank you, GDemay. I ran the victory-shader and victory-gpu suites under CrossOver Wine with D3DMetal on an M4 with this limit, since CI has no GPU: 254 and 174 passed, nothing failing. Merged. jjlange and LakshanSivakumar, this one targets the 'on the GPU' share directly; the first run retranslates shaders because the cache keys on the limit, so please compare the second run. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A translated loop whose bound is not mirrored yet runs to
LOOP_LIMITin every lane that reaches it, and a dispatch lasts as long as its slowest lane. This lowers the limit from 2^20 to 2^14: one constant, the same change as upstream Marvisak/VIctory#1819 (open there).Why it should cut
on the GPUin the world:00167d58cc5a78d7is about 90% of a world frame's GPU time at 2^20. GPU time per frame: 5.3–9 s at 2^20, 0.58 s at 2^14. It has two inner loops in three outer passes, so up to six runs to the limit per dispatch.Trade-off: a genuine loop of more than 16,384 passes per lane and entry is now cut short (the existing
shortcut:).VICTORY_SHADER_LOOP_LIMITstill overrides the limit in diagnostics builds.To measure without this branch: current main, diagnostics build,
VICTORY_SHADER_LOOP_LIMIT=16384; compareon the GPUand the picture. The shader cache keys on the limit, so the first run translates the shaders again.Tested:
cargo test -p victory-shadernative, 151 passed. Windows-target clippy-D warningsis clean with and without all features; no new rustfmt diffs;cargo xtask policyok. My Wine has no D3D12 device, so the GPU shader tests run only in this PR's CI. Not run in the game.🤖 Generated with Claude Code