feat(shader/lower): honor constant-trip loop bounds past per-stage caps #266
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: launcher
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
run report
security: hold
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs gpu test
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/Androtim--MiniVI!266
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/266/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?
@Androtim on GitHub · 2026-11-30 22:13 UTC · original
Androtim:feat/iter259-shader-constant-trip-loop-cap→main· +400 −6 · 3 files · 2 commits · closed without mergingSummary
crates/victory-shader/src/emit/lower/trips.rs(supporting up/down counting, swapped and signed compares,s_cmp_*/s_cmpk_*,s_add/s_sub/s_addk_i32,s_mov_b32/s_movk_i32up toTRIP_CEILING= 65,536 iterations).crates/victory-shader/src/emit/lower.rs(viafind_tripsandloop_cap) from the per-stage loop iteration cap so fixed 256/512-sample pixel shaders (such as BRDF integration LUTs) complete all iterations instead of truncating at 128, while keeping the stage cap intact for data-driven or huge loops.crates/victory-shader/src/emit/lower_tests.rscovering 512-iteration constant loops, countdown/swapped/signed loops, dynamic bounds, overwritten counters, and bounds aboveTRIP_CEILING.Verification
xtask policy: passed (316 files ok)cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader lower -- --test-threads=1: passed (23 passed, 0 failed, 1 ignored)cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings: passed (0 warnings)cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --features diagnostics --all-targets -- -D warnings: passed (0 warnings)@Androtim on GitHub · 2026-11-30 23:03 UTC · original · edited 2026-12-01 06:04 UTC
Automated triage for the maintainers (not an approval).
Verdict:
needs-gpu-test· CI (check):passingReview Summary
Logic and unit-test coverage look solid, and CI is passing. Because this changes DXIL loop-cap lowering in
victory-shader(where higher caps previously correlated with GPU TDRs in opening-cutscene draws), it warrants a local real-GPU smoke test before merging.What was verified
crates/victory-shader/src/emit/lower.rs:Lower::find_tripsruns aftercountersand RPO tables are populated and only inspects single-latch loops (if let [latch] = back[..]).Lower::loop_capraises the default per-stage cap (128pixel,256vertex/mesh,4096compute) toown.max(stage_cap)for statically bounded loops while preserving explicitVICTORY_SHADER_LOOP_LIMIToverrides (named => named).niterations, the back edge is takenn - 1times, socount_iteration'snextreaches at mostn - 1 < n(pred::IULT/pred::IUGE), allowing allniterations to complete cleanly.crates/victory-shader/src/emit/lower/trips.rs:constant_tripstrictly requires a scalars_cbranch_scc0/s_cbranch_scc1latch, a single SGPR phi (c < VCC) defined at headerh, matching constant start values across all reachable entry edges, and a pure constant-offset add/sub chain (s_add_*,s_sub_*,s_addk_i32) back to that phi without crossing inner phis.s_cmpk_*(sign-extended_i32vs zero-extended_u32),s_cmp_*(including swapped operands viaswapped), inline integer constants (128..=208), and wrapping 32-bit simulation bounded byTRIP_CEILING(65_536).crates/victory-shader/src/emit/lower_tests.rs:TRIP_CEILING, countdown loops, swapped compares, signed vs unsigned compares, and in-body counter resets.Minor non-blocking note
s_addk_i32support intrips::offsetis not directly exercised by the new unit tests (onlys_add_i32/s_sub_i32are), though the implementation is straightforward.Next step
Run a local real-GPU smoke test (especially fixed-sample pixel shaders such as BRDF LUTs and the opening cutscene draws) to confirm no TDR regressions before merging.
Generated with Antigravity CLI (
agy).@Androtim on GitHub · 2026-12-01 05:01 UTC · original
Merged
origin/main(d79b9432) intofeat/iter259-shader-constant-trip-loop-capto bringhost.rswithinxtask policyand re-trigger CI past the unrelateddescriptor::host::tests::views_off_their_elements_get_a_copy_of_their_bytesrunner failure (zero code changes needed totrips.rs/lower.rs).Local Verification
cargo +1.98.1-x86_64-pc-windows-gnu xtask policy(316 files ok)cargo +1.98.1-x86_64-pc-windows-gnu test --locked -p victory-shader --lib constant_trip(2 passed; 0 failed, both default parallel and--test-threads=1)cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --locked -- -D warnings(default and--features diagnosticsclean)@Androtim on GitHub · 2026-12-01 05:20 UTC · original
Maintainer triage (strict merge gate): keeping
triage: needs gpu test.CI is passing on
bfa945bb. Because this changes shader loop-bound lowering (victory-shader), please include a paired plain--releaseA/B against updatedmain(confirmingmedian fps,preparing ms,copyback ms,final_waiting,untranslatedshaders, and0crashes) plus a--features diagnosticsvisual PNG check before merge.@Androtim on GitHub · 2026-12-01 16:14 UTC · original
Closing to keep the queue focused on [USER PRIORITY] core engine throughput, copyback, dynamic 4K VRAM reclaim, and stability (#276). No paired plain --release A/B or confirmed visual defect currently depends on this; we can revisit cleanly if a specific constant-trip shader truncation issue is observed.
Pull request closed