Repository navigation
Shader: the loop limit switch works in every build - #1263
pablogonz12 wants to merge 4 commits into
Conversation
VICTORY_SHADER_LOOP_LIMIT was read only with the diagnostics feature, so a release build could not run the experiment another VIctory fork reports as a ~6x GPU time win. It is now honoured in every build, with the default (2^20) unchanged, values from 2^31 clamped to i32::MAX (the emitted counter is an i32 compared unsigned, so a bigger constant would act as no limit), and the same parse rules. The shader cache already hashes the limit into its key, so translations made with different limits never mix; the warning says so. The 256/1024 advice and the risk of 32 are in xcl-bin/notes/loop.md.
|
Reviewed on Windows 11 / Rust 1.98.1, The headline claim is proven in a release build, not just by reading the diff. I appended a throwaway probe to The clamp to Interaction with our #1094 branch, so it is on record: this PR edits the doc comment of One doc nit. The README row now says "32 is a diagnostic value, 256-1024 a safer probe" — useful, and it also warns that a real loop longer than |
catminou4
left a comment
There was a problem hiding this comment.
VICTORY_SHADER_LOOP_LIMIT now honored in every build (was diagnostics-only), with the right clamp: the emitted counter is i32 and compared unsigned, so values >= 2^31 would alias to huge/negative and defeat the limit — clamped to i32::MAX. Also accepts 0X prefix, rejects 0/negative/overflow, README and shader_cache comment updated to match. Complements #452 (which changed the default limit behavior); not a duplicate. Local verification: macOS arm64, rustc 1.98.1, PR head merged into main ffe310e, cargo test -p victory-shader --locked. Shader execution tests (valu_tests/host) are #[cfg(all(test, windows))], so macOS covers lowering/decode/unit tests only. 96 passed, 0 failed (parse tests run on macOS).
|
Automated triage for the maintainers. Needs work: needs the maintainer's decision. Thanks for The open question is unchanged. Generated by Claude Code |
|
Fixed in b7005f4: the doc comment and the test comment now say the compare is unsigned ( |
|
Done: the doc comment now says the clamp is only a cap ( AI-assisted. |
What
loop_limit()now readsVICTORY_SHADER_LOOP_LIMITin every build, not only withdiagnostics: same parse rules (decimal or0xhex, at least 1, unreadable or 0 means the default), same default (2^20), and values abovei32::MAXclamp to it (only a cap: the emitted constant takes anyu32and the compare is unsigned).shader_cachealready hashes the limit into its key, so translations made with different limits never mix, and the warning says so.No behaviour change by default.
Why
The limit is the switch to test whether spin-wait loops are what makes a frame slow (the ~6x GPU-time report from another fork), and a release build is the build one runs the game with. #452 changes what the default budget means; this only makes the override reachable, so it should stay useful whichever default lands.
Worth documenting: 32 is unsafe (a real loop of 33 iterations, or a long decal pass, gets cut and the picture breaks in ways that look like a title bug), 256 is cautious, 1024 is the value the report used. That is the advice I would put next to the variable.
How tested
cargo test -p victory-shader --lib(Linux): 96 passed, 0 failed, 1 ignored, including the new parse tests (decimal, hex, 0, junk, over the clamp).cargo xwin clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings, with and without--all-features: clean.Not tested
Written with an AI assistant.