Refuse VICTORY_INDIRECT_CLAMP=0: it kills the run, and hoisting is the answer to the cost #169
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!169
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-169"
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?
@HailLucifer666 on GitHub · 2026-11-24 22:06 UTC · original
HailLucifer666:perf/indirect-clamp-bypass→main· +90 −1 · 1 files · 1 commits · openWhat changed, and why the title changed
This PR no longer adds a bypass. It refuses one.
The bypass was meant to answer a real, measured cost:
dkdknight's Nsight capture on an RTX 5080 shows about 5,000 one-record indirect mesh draws per frame, GR active ~75%, SMs ~28%, SM issue ~4% — the machine is waiting on per-record work, and the per-record clamp pass is part of that work.He then set
VICTORY_INDIRECT_CLAMP=0and both runs died with0xc0000005writing0x0, within seconds, twice out of two. The title's argument buffer holds records whose bounds the pass is what enforces. Removing the check does not make it faster; it makes the process stop.So
0now means "I read the complaint, and no":clamp_settingreturns(clamp on, say so); the clamp is on for every value.clamp_is_onis consulted where the clamp is first made, so even a run that never reaches the pass is told.With no path left that could honour it, the dead half is deleted rather than left unreachable: the
if !clampedbranch, the twoif clampedteardowns, andwait_direct, which existed only to barrier an unclamped execute.What answers the cost
Hoisting the clamps out of the per-record path —
VICTORY_HOIST_CLAMPS, Phase I (perf/hoist-indirect-clamps, switch landed, default off). That keeps the bounds check and stops paying for it once per record. When hoisting is the default and survives hardware, deleting the per-record pass becomes a conversation with evidence behind it. This is not that conversation.Evidence
clamp_settingreturnsparse_clamp_enabled(asked)again → the new test fails withleft: (false, true), right: (true, true)→ restored byte-identical (indirect.rssha256ade38ee886e354e5).cargo test -p victory-gpu --lib: 161 passed, 1 failed —warp_budget_saturates_without_wraparound_and_preserves_draw_fields, the known flake (#847/#849), untouched by this commit.cargo clippy -p victory-gpu --lib -D warnings: only the two pre-existing #841 errors (placed_filler_twins,sort_unstable_by_key) remain.Not covered
Native D3D12 — no GPU here. The refusal is proven by its decision and its message, not by a frame. Anyone who genuinely wants the old behaviour keeps it by running an older build, which is the honest place for a switch that crashes.
⚠️ This is a behaviour change:
VICTORY_INDIRECT_CLAMP=0no longer does anything except print a warning. If that was in a launch script, it can come out.@dkdknight on GitHub · 2026-11-25 00:31 UTC · original
Tested this on GTA VI (Series X build), RTX 5080, Windows 11, with
VICTORY_RELAY=2 VICTORY_LATE_WAIT=3. Build: this PR merged onto our integration branch (#71, #81, #77, #38, #80, #63 on top ofmain).With
VICTORY_INDIRECT_CLAMP=0the title crashes while the story loads, 2 launches out of 2:The title's own crash reporter then starts (blocked upload to backtrace.io). That is a deliberate null write: the game's own fatal path, not a fault in VIctory. Both runs died about 90 s after launch, during the load into the world, before any gameplay frame. The same binary with the clamp left on (the default) loads and plays normally.
So on GTA VI at least, some indirect arguments the title produces need the clamp, presumably group counts the clamp zeroes or bounds. Running
ExecuteIndirectstraight from the title buffer is not safe there. I'd keep the default as it is in this PR (clamp on) and document that0crashes GTA VI.One caveat for honesty: the same crash site showed up once before, on a first launch of a build with the BVH builder (#36), which then loaded fine on relaunch. Here it reproduced on the relaunch too, with a warm shader cache, which is why I attribute it to the switch.
Context, in case it helps anyone working on GPU time: on this card the frame is front-end bound (Nsight Systems GPU metrics during gameplay: GR active ~75%, SMs active ~28%, SM issue ~4%), with ~5,000 one-record indirect mesh draws per frame, each with its clamp pass. So the cost of the clamp +
ExecuteIndirectpairs is worth attacking, but by a route that keeps the bounds check.(Tested and written with the help of an AI assistant, Claude Code; numbers above are from our own runs.)
@HailLucifer666 on GitHub · 2026-11-25 09:44 UTC · original
Thanks — this is the most useful telemetry on this PR, and I am taking both findings as they are.
The flag is diagnostic only.
VICTORY_INDIRECT_CLAMP=0is not a supported setting. Your two launches show the title writing a null through arguments the clamp would have zeroed or bounded, so runningExecuteIndirectstraight from the title's argument buffer is unsafe there — and the clamp is exactly what stops it. The default stays on; I have noted the crash in the description so nobody reads0as a tuning knob. Expect a crash during the load into the world with it off.The bottleneck is the one this PR was aimed at, but bypassing is the wrong route. ~5,000 one-record indirect mesh draws a frame with GR active ~75%, SMs ~28% and SM issue ~4% says the frame is front-end bound on the compute↔graphics switches, not on the clamp's arithmetic. Removing the switches by removing the clamp also removes the safety, which is not a trade worth making.
The next step is to batch the clamp itself: one clamp dispatch, or a few windowed ones, covering a whole run of consecutive indirect records instead of one pass per record — every bounds check kept, and the
0xFFFF_FFFFzeroing for unfilled tail slots kept without charging their budget. That is where the ~5,000 switches go without giving up the clamp. It goes up as its own PR; I will tag you for a run if you are willing.Also noted that the same crash site appeared once on an earlier build and did not reproduce on relaunch — thank you for saying so rather than leaving it as clean attribution. It does not change the conclusion for the flag.
@HailLucifer666 on GitHub · 2026-11-25 11:12 UTC · original
Rebased onto
f85101b6. It conflicted because #220 landed the indirect draw windows in the same region ofexecute_indirect— the resolution keeps both: your window block (including itsVICTORY_INDIRECT_WINDOW_CHECKcheck on the held path) is now theclampedarm, andVICTORY_INDIRECT_CLAMP=0is the bypass arm around it, so the bypass composes with the window instead of replacing it.Two things worth knowing before merge:
perf/indirect-window-batching) matters — both editexecute_indirect. Landing this first is the order that works; #862 will be rebased on top of it./keeprobes on this rebase: forcingparse_clamp_enabledto always return true failsparse_clamp_enabled_defaults_on_and_respects_explicit_disableat"0" must disable indirect clamp; dropping the alignment checks fromvalidate_layoutfails its test. Both red for the right reason, both restored byte-identical.Gate on
eb568071:cargo test -p victory-gpu --locked→ 161 passed, 0 failed, 4 ignored;indirect::with--test-threads=1→ 14 passed, 2 ignored andwarp_budget_saturates_without_wraparound_and_preserves_draw_fieldsred, which is the known budget race #849 fixes (it fails 5 runs in 6); both clippy passes red only onmain's own three lints;xtask4 passed.@HailLucifer666 on GitHub · 2026-11-25 14:33 UTC · original
Rebased onto current
main(0b0074e0) — clean, no conflicts — so this is nowdraw.rsandindirect.rsagainst today's tree rather than seven commits behind it.Re-verified after the rebase, since a probe on an old tree proves nothing about the new one:
clamp_settingreturningparse_clamp_enabled(asked)again failsleft: (false, true), right: (true, true); restored byte-identical (indirect.rssha256c5707c8b7898490a). Suite: 173 passed, 0 failed, 5 ignored.kee preflight --base main: FAIL 0, all six CHECK rows answered with evidence.Two corrections to what this PR body says above:
main's — checked by running clippy onvictory-fork/mainalone:placed_filler_twins,sort_unstable_by_key, andmanual_is_multiple_of(shadow.rs:2675). None is introduced here and none is fixed here; riding an unrelated clippy fix inside this PR is how a diff stops being readable.main's index-exact warp-budget assertion, so until #970 lands its suite can fail for a reason that has nothing to do with this change. #970 makes that test accept both legal orders; then this one rebases and its evidence is its own.65556753f3tod41db98d8c@HailLucifer666 on GitHub · 2026-11-26 14:01 UTC · original
Rebased onto
maina20809de; head is nowd41db98d(no conflicts — the bypass composition with the landed window block still applies cleanly). Verified:victory-gpu indirect:: --test-threads=120 passed, 0 failed, 2 ignored;clippy -D warningson victory-gpu clean. The default stays clamped, as the title says;0is refused.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.