victory-gpu: drop an indirect call before its clamp, not after (1 400-1 750 a frame) #1634
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1635"
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?
Imported from Marvisak/VIctory. Originally posted by pes7 on 2026-11-24T20:12:04Z.
1 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.
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T21:21:36Z.
Review: APPROVED
Tested
6dcf40aon Windows 11, RTX 5070, MSVC: builds,cargo test --workspace --no-fail-fast638 passed, 0 failed (on our fork main). I didn't measure the frame-time effect.host_pipeline(self.pipeline)to beSome:prepare,prepare_for, and the dispatch arm. So checking it before the refresh and clamp drops exactly the calls that were dropped before, and nothing more.indirect::bound, so the buffer is never moved toINDIRECT_ARGUMENTand the compute root signature isn't replaced. Skipping theindirect::donetransition and thehost_pipeline/host_rootsreset on that path is therefore correct.note_drop, as the old not-ran path did for a missing pipeline.Merged into our fork's main.
AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T22:19:54Z.
Review: COMMENTED
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.
Indirect call dropped before its claim when… (small 1.3K diff in draw.rs, no tests added). Worth a Windows hardware check that the dropped call path is the intended one.
Imported from Marvisak/VIctory. Originally posted by pes7 on 2026-11-24T22:41:00Z.
@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.