victory-gpu: drop an indirect call before its clamp, not after (1 400-1 750 a frame) #1635
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!1635
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1635/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?
@pes7 on GitHub · 2026-11-24 20:12 UTC · original
pes7:perf/indirect-skip-clamp→main· +13 −0 · 1 files · 1 commits · merged 2026-11-25 00:18 UTC1 400-1 750 indirect calls a frame are dropped because their pipeline is not built yet, and each one has already copied its arguments and dispatched the argument clamp before finding that out. Moving the check ahead of the clamp takes a copy and a GPU dispatch out of every one of them.
State::execute_indirectrefreshes the argument buffer from title memory and callsindirect::bound, which dispatches a compute shader that clamps the records - then callsprepare, which fails when the pipeline is not there, and drops the call. The drop counts are the ones in the reports: 1 400-1 750 indirect executions a frame on an RTX 5070 Ti (#400), 1 294 a frame on an RX 7800 XT (#255), 64/frame "prepare failed (compute false, mesh false)" plus 282 compute pipelines refused in #748 - all of it while the world builds its pipelines, which is exactly when the frame is slow.What changes
host_pipeline(self.pipeline)is asked first. It is the same lookuppreparedoes a few lines later and returnsNonefor a pipeline the worker threads have not made yet; withNonethe call cannot run, so it is dropped before the refresh and before the clamp. No behaviour change for a call that can run: same refresh, same clamp, same execution.This is the order the file already uses for skipped pipelines, with the comment "Skip before the argument clamp can mutate the indirect buffer" - the same argument, extended from the skipped case to the much more common not-built-yet one.
What it saves
Per dropped call, on the CPU and on the GPU:
Shadow::refreshoverstride * maxbytes,copy_mapped);recordsthreads and the UAV barrier around it (indirect::bound/indirect::done), which also serialises the list on the GPU.At 1 400-1 750 calls a frame that is 1 400-1 750 dispatch-and-barrier pairs removed from every frame while the world loads, and the copies that go with them.
Not measured in the title
I cannot run the title, so I cannot show the frame time before and after - the count of dropped calls is from the reporters above, and the code order is verifiable:
args.refreshandindirect::boundboth run beforeprepare, unconditionally. What I can say is that the work removed is real, per call, and that the counters already distinguishno host pipelinefromprepare failed, so the firstcopystat/frame line after this lands shows it: the "dropped without a host pipeline" reasons should keep their counts while the clamp dispatches behind them stop.Correctness
Dropping a call earlier is safe: nothing reads the clamp's result for a call that does not execute, the clamp is per call (records at
arguments,stride * maxbytes), and a later call that does run clamps its own range first.cargo test --workspace --locked, both clippy configurations with-D warnings,cargo xtask policy.No game data used.
@pes7 on GitHub · 2026-11-24 22:41 UTC · original
@catminou4 - on the Windows hardware check: @mercuryVM already ran one at
6dcf40aon Windows 11 / RTX 5070 / MSVC (build,cargo test --workspace --no-fail-fast638 passed, 0 failed, merged into their fork's main) and walked the same three paths you would check -prepare,prepare_forand the dispatch arm all gate onhost_pipeline(self.pipeline)beingSome, so the early return drops exactly the calls that were dropped a few lines later, and it comes beforeindirect::bound, so the buffer never gets itsINDIRECT_ARGUMENTstate and the root signature is never replaced.What the change does and does not touch, for a source-only read:
not-ranpath used; only its position moved, so the set of dropped calls cannot change - it is the sameOptiontest on the same handle;return falseis what the existingis_skippedearly return above already returns, so the caller sees the same thing;note_drop, so the 1 400-1 750 a frame in #400 stay visible after this lands, which is how the claim can be confirmed in the title rather than by reading.There is no test in
draw.rsfor the indirect path at all today - the module's tests cover root views, textures and heaps, and the indirect path needs aStatepointed at a title pipeline handle plus argument records in shadow memory, which is a harness of its own. If you would rather have a synthetic test than the hardware run above, say so and I will write one against the existingcompile_cshelpers in that module; I did not add it because it would be more code than the change it covers.