gpu: opt-in async submit pipeline, thin peephole, and parallel recording #4856
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!4856
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4855"
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?
@lyufeng000 on GitHub · 2026-12-01 11:43 UTC · original
lyufeng000:pr/submit-pipeline→main· +4667 −130 · 8 files · 1 commits · closed without mergingMotivation
On an RTX 4090 + Ryzen 9 9950X at 4K DLSS Quality (steady state on upstream
e1251c31), actual GPU frame time is 27.7–29.0 ms, yet the main submission thread spends ~24.9 ms/frame synchronously preparing, recording, and submitting underHost::submitted. Because CPU preparation, D3D12 command-list recording for card copies, and queue submission share the same coarse submission lock, the GPU frequently starves for ~7.0 ms/frame (~80% GPU utilization) waiting for the next batch of command lists.This PR ports an independent, strictly opt-in asynchronous submission pipeline onto upstream
e1251c31with four composable stages—all disabled by default—so maintainers can merge with zero default-path risk and A/B benchmark each stage individually or together.Architecture
1. Stage 0: Zero-Allocation Thin-Stream Peephole Folding (
VICTORY_THIN_PEEPHOLE=1)crates/victory-gpu/src/list/thin.rs(PeepholeWindow,translate_peephole).list::thinreplay:PIPELINE,ROOT,TOPOLOGY,STENCIL_REF,BLEND_FACTOR,SAMPLE_MASK,VIEWPORTS,SCISSORS,INDEX_BUFFER,TARGETS,HEAPS,SHADING_RATE), resetting committed history onRESETandCLEAR_STATE.TARGETSflushes any pending coalesced copy first to preserve copy-vs-target ordering.(kind, slot)or vertex-buffer range overwrites before a flush boundary.BARRIER/BARRIER_GROUPS(w[0] == 0) while strictly preserving upstream's bit-63 narrowBARRIER_GROUPSskip marker (w[0] == 1 << 63->state.synced()), and merges adjacentCOPY_BUFFER/COPY_MEMORYcalls under four gates (same kind/buffers, contiguous offsets,dst != srcnon-aliasing includingbuffer_baseoverlap check, and capped byte budget).EXTERNAL,UPLOAD,CLOSE) flush all pending state in original order before replay, and abandoned recordings stop immediately before emitting actions.2. Stage 2/3 Decoupled Submission (
VICTORY_SUBMIT_STAGE_SPLIT=1)crates/victory-gpu/src/host/pipeline.rs(Host::submit_pipelined,QueueOrder,AirScoreboard,PipelineStageBus,stage3_worker) with minimal hooks inhost.rsandqueue/behind.rs.card_beforerecording: Stage 2 runs CPU preparation under a dedicatedparallel_rec::prep_lock()without holdingHost::submitted, while Stage 3 (victory-stage3) performs deferredcard_record_parallelcommand-list recording outside bothHost::submittedandprep_lock(offloading ~1.9–2.5 ms/frame off Stage 2), drains heap sync waits, issuesExecuteCommandLists+Signal, registers flights intoLINE, and retires lists concurrently with Batch N+1's Stage 2 preparation.QueueOrder { assigned, queued }:assignedto tagshadow::card_dirty(sent_as)without holdingQUEUE_ORDERacross recording.queued = queued.max(sent_as)strictly afterExecuteCommandListsandSignal.victory-relayobserves onlyqueued, guaranteeing it never treats an unsubmitted Stage 2 batch as already queued.AirScoreboardzero-gap handoff:card_steps::Taken::copied_ranges(), and bottom-of-pipe writes for batches sitting inPipelineStageBusbetween Stage 2 and Stage 3.Late::RunintoLINE(callingline.joined(...)soVICTORY_LAZY_NARROW=1stays exact), releasesLINE, and then callsair_retire(token).late_blocked,late_met_known,late_met_by,land_before_remap, and Stage 2airassembly) snapshotAirScoreboardfirst, then lockLINE—eliminating observation gaps without ever nestingAIR_SCOREBOARDandLINE.PipelineStageBus(capacity 8):late_signal(Stage3Item::Signalretainingcrate::fence::FenceRef) directly into the FIFO when Stage 3 is active.VICTORY_SUBMIT_SPLIT(split_send()automatically yields whenstage_split_on()is active).3. Parallel
card_beforeRecording (VICTORY_PARALLEL_REC=1)crates/victory-gpu/src/host/parallel_rec.rs(EpochSlotRing,D3d12AllocatorPool,ParallelRecPool,Host::card_before_parallel).(ID3D12CommandAllocator, ID3D12GraphicsCommandList)slots only whenretired_fence <= completed_fenceand explicitly rejectscompleted_fence == u64::MAX(device lost).>= 64hashed shadows or>= 128compared ranges); steady-state batches (~13 hashed shadows, ~18 compares) record inline in a single command list with zero worker wakeups.e1251c31card_record: preservessend::Own(+own.copied()synchronization forVICTORY_SEND_BESIDE=1),upcheck,upq(only when!defer_sync, safely skipped in Stage 2 outsideHost::submitted), private CPU mirrorsnapshot_private_rangesfallback, pre-computedlazy::hold_backstrictly ahead oflazy::select/lazy::sweep,VICTORY_LAND_CAPTURE=1(bind_capture+ mode 6),VICTORY_CARD_BATCH=1(CARD_COMPARE_BATCH+ pre-allocated disjointtake_card_jobsranges),scoped_uav_barriers,barstat::rb, andcardmeter.4. Full-Segment R/W State-Closure Coalescing (
VICTORY_COALESCE_CUTS=1)crates/victory-gpu/src/host/parallel_rec.rs(coalesce_execute_cuts) with lightweight tracking onHostList(has_unbounded_uav, set onUse::Buildsindraw.rs) andDeferred(copy_source_shadows/copy_dest_shadows, populated inhost/place.rs).MAX_COALESCED_PARTS = 2adjacent non-conflictingpartsinto fewerExecuteCommandListscalls only when scanning every list inG \cup Psatisfies:deferred.writes),Step::Placed,Step::Run, unbounded UAV shaders (Use::Builds),card_stepsprefix segments (own.is_some()), and unscopedpicked.writtenranges.Opt-In Switches (All Default OFF)
All switches use
crate::asked_for!("1"enables; unset /"0"disables). Noapps/victory/src/play.rsdefaults are changed.VICTORY_THIN_PEEPHOLE0(off)list/thin.rs)thinstream replayVICTORY_SUBMIT_STAGE_SPLIT0(off)host/pipeline.rs)prep_lock) from Stage 3 GPU submit (Host::submitted) viaQueueOrder,AirScoreboard, and bounded FIFOvictory-stage3VICTORY_PARALLEL_REC0(off)card_before(host/parallel_rec.rs)card_beforesync/hash/check listsVICTORY_COALESCE_CUTS0(off)host/parallel_rec.rs)ExecuteCommandListspartsWhen all four switches are unset,
list::thin::translate,Host::send_late,Host::submit,Host::card_before, andcutsexecute upstreame1251c31's exact original paths without spawning any extra threads.Ordering, Streamline & Safety Invariants
run.take_upscale(),run.deferred().framegen_camera(whenstreamline::fsr::ml_active()),streamline::submitted(id, camera),run.take_hudless(), andstreamline::hudless_submitted(id)execute strictly inside Stage 3'sHost::submittedwindow—never in Stage 2 and never across aPresent.pipeline::flush_stage3()runs beforeshow_planesinqueue/behind.rs(Job::Present), at the entry ofHost::present_placed(coveringVICTORY_ASYNC_SUBMIT=0as well), inLane::drain(), insettle_now(), and inHost::submit/Host::execute_unwaited.slot0StandaloneCOMMONDecay Boundary:send::Ownrecords copies/scatters intopre_lists[0](has_own_slot0 == true),submit_pre_lists(partition_pre_lists) executespre_lists[0]in its own standaloneExecuteCommandListscall (withbefore_sendforVICTORY_RESIDENT_LATER=1) before any parallel hash lists orruns, guaranteeing unhashed buffers decay back toCOMMON.Lane::state < prep_lock < PipelineStageBus (not_full / flush) < Host::submitted < QUEUE_ORDER < CARD_WORK < LINE, withAIR_SCOREBOARDandPipelineStageBus::stateas strict leaf locks.victory-stage3callscrate::queue::no_drain_here()at startup, never acquiresprep_lock, wraps its loop incatch_unwind->fail(...), and executescard_steps::put_off,beside::send_fills,land(), andbury()(uav_pool::drain_retired_uavs) cleanly.host.rsSize Gate:crates/victory-gpu/src/host/pipeline.rsandcrates/victory-gpu/src/host/parallel_rec.rs;host.rsgrows by only ~4.7 KiB (~951.5 KiB total, well under the 1 MiB policy limit).Verification & Unit Tests
Added Unit Tests (14 new tests, all passing under default and
--features diagnostics)crates/victory-gpu/src/list/thin.rs):peep_class_a_folds_and_suppresses_zero_diff_until_reset_or_clear_statepeep_class_b_dead_write_elimination_respects_slots_and_rangespeep_class_c_skips_empty_barriers_preserves_narrow_skip_and_enforces_copy_four_gatespeep_hard_boundaries_flush_pending_and_abandoned_stops_before_actioncrates/victory-gpu/src/host/parallel_rec.rs):epoch_slot_ring_reclaims_only_completed_fences_and_rejects_lost_deviceparallel_rec_pool_executes_all_items_across_reusescoalesce_never_crosses_hard_cuts_or_capcoalesce_closure_checks_middle_lists_place_source_and_rw_hazardscard_before_fanout_thresholds_keep_steady_state_inline_and_fan_out_burstscrates/victory-gpu/src/host/pipeline.rs):queue_order_two_stage_keeps_assigned_ahead_of_queued_monotonicallyair_scoreboard_tracks_overlapping_in_flight_writes_and_retiresair_scoreboard_line_handoff_has_no_observation_gapstage_bus_preserves_fifo_order_interleaves_signals_and_flushesslot0_partition_isolates_send_own_when_activeGate Results (against base
e1251c31,rustc 1.98.1)cargo clippy --workspace --all-targets --locked&--all-features: 0 warnings in all modified/added files. (Pre-existing warnings on upstreame1251c31untouched:victory-shader/src/emit/lower.rs:114,victory-gpu/src/shadow.rs:7197,victory-gpu/src/copystat.rs:1470,victory-gpu/src/host.rs:5106,victory-hle/src/modules/xmem.rs:1933.)cargo xtask policy: 0 violations in all modified/added files. (Pre-existing upstreame1251c31notice in untouchedcrates/victory-shader/src/native.rs.)cargo test: All 14 new PR unit tests pass under both default and--features diagnostics; all touched/dependent crates (victory,victory-core,victory-formats,victory-game,victory-hle,victory-loader,victory-pe,victory-pipeline, 6/7 inxtask, and1144tests invictory-gpu) pass. (Pre-existing upstreame1251c31failures untouched:xtask::policy::tests::repository_passes_policyoncrates/victory-shader/src/native.rs,list::thin::tests::bindings_record_no_work,shader_cache::tests::every_switch_of_the_translator_is_in_the_key,victory-shader::emit::bitcode::opt::tests::hw_tests::split_lds_wave32_read_after_read_barrier_coalescing_and_parity, and RTX 4090 fast-GPU round-0 timing oncard_steps::tests::shared_scratch_eliminates_flight_settle_end_to_end.)cargo build --release --locked -p victory: builds cleanly.A/B Benchmark Results (RTX 4090 + 9950X, 4K DLSS Quality + FG 2x)
Measured on the same 4K DLSS Quality + FG 2x configuration with
VICTORY_PLACED_COPIED=0, comparing the matched upstreame1251c31baseline against Full PR 3 Pipeline (VICTORY_THIN_PEEPHOLE=1 VICTORY_SUBMIT_STAGE_SPLIT=1 VICTORY_PARALLEL_REC=1 VICTORY_COALESCE_CUTS=1) over a 19m10s continuous gameplay run (victory-nvidia-play-20261201-105326-39804.log, 0 errors / 0 panics / 0 device-lost):preparing/card(ms)4k–5.5k)e1251c31,PC=0)>100ms: 2/707>100ms: 0/7525.5k–7k)e1251c31,PC=0)>50ms: 32.7%>50ms: 5.4%7k–8.5k)e1251c31,PC=0)8.5k+drawsOptional isolated per-switch A/B runs (if maintainers want a single-stage breakdown on identical static camera saves):
VICTORY_THIN_PEEPHOLE=1VICTORY_SUBMIT_STAGE_SPLIT=1VICTORY_PARALLEL_REC=1 VICTORY_COALESCE_CUTS=1@Aniseto on GitHub · 2026-12-01 11:50 UTC · original
Ran the three modules holding the 14 new tests and the full
victory-gpulibrary suite atbc15e0a5on an NVIDIA Blackwell desktop part with 16 GB of VRAM, with a control onmain5fabb46ein a separate target directory. All four switches of this PR are opt-in and were left unset.Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.98.1 (48a229cea 2026-09-01), MSVC 14.44.35207, debug build, detached worktree at the exact PR head, own
CARGO_TARGET_DIR, no local patches.The single failure is
host::packed_present_tests::packed_float_single_planes_are_presented, athost.rs:17827here andhost.rs:17713onmain; it fails on this host with and without this head, so it is not introduced by the PR. The PR is based one1251c31, while currentmainis5fabb46e, so the raw pass counts are not directly comparable. No A/B gameplay was done, so the opt-in pipeline's effect on frame time or GPU starvation was not measured here.Not tested: a title run with any of
VICTORY_THIN_PEEPHOLE=1,VICTORY_SUBMIT_STAGE_SPLIT=1,VICTORY_PARALLEL_REC=1orVICTORY_COALESCE_CUTS=1, the 19-minute RTX 4090 A/B of the description, clippy, the full workspace suite, Wine, AMD adapters, game data.AI-assisted (OpenCode), model: MiMo-V2.6-Flash Free - checked out both commits in detached worktrees, built them, ran the tests, wrote this report; neither worktree was modified; no game data was used.
@tikD1337 on GitHub · 2026-12-01 12:18 UTC · original
Tested all four opt-in stages from this PR in paired
--releaseA/B runs onorigin/main(5fabb46e+ PR headbc15e0a5), providing the isolated per-switch breakdown on a smaller core-count CPU:Rig & setup: Ryzen 5 7600 (6C/12T) + RTX 4070 Ti SUPER 16 GB (Driver
621.1.0, ReBAR ON) + 32 GB RAM + Windows 1126300, warm shader cache,VICTORY_SUBMIT_SPLIT=1,VICTORY_DLSS=1(Quality),VICTORY_PORT_CONSTANTS=1(upstream default; also tested=0), Series S console mode, 105 s steady 3D in-world runs at the same location (~5.5k–6.5ksteady draws/frame).list::thin::tests::peep_4/4 PASS,host::parallel_rec::tests5/5 PASS,host::pipeline::tests5/5 PASS.Isolated & Combined Stage A/B Results
>=200lists)card(GPU)submit_prepww/steps/refr5.5k–6.5k(FPS/hprep/hcp)PC=1,n=46)n=9)5fabb46eVICTORY_THIN_PEEPHOLE=1) (n=59)n=11)VICTORY_SUBMIT_STAGE_SPLIT=1) (n=64)n=12)THIN_PEEPHOLE=1+SUBMIT_STAGE_SPLIT=1(n=67)n=12)PC=1) (n=65)n=11)PARALLEL_REC+COALESCE_CUTSregresses on 6C/12T vs Stage 0PORT_CONSTANTS=0) (n=64)n=12)~72 MB/fvs~37 MB/f), starving GPUKey Takeaways
VICTORY_THIN_PEEPHOLE=1alone is a massive win (0 extra threads): on Ryzen 5 7600 + RTX 4070 Ti SUPER it lifted steady 3D FPS from23.24 -> 27.00 FPS(+16.2%), cuttingsubmit_prepby-6.7 ms(35.6 -> 28.9 ms), 5shost_prepby-7.4 ms(32.6 -> 25.2 ms), and even GPUcardtime by-4.6 ms(38.8 -> 34.2 ms) — with 0 crashes or errors across all 6 runs. Worth considering splitting Stage 0 out or keeping it independently mergeable!VICTORY_SUBMIT_STAGE_SPLIT=1improves over Base alone (23.24 -> 24.87 FPS) and tracks Stage 0 solo when paired withTHIN_PEEPHOLE=1(27.35vs27.40 FPSon matched5.5k–6.5kdraws, slightly higherprep30.5vs28.9 ms).VICTORY_PARALLEL_REC=1+VICTORY_COALESCE_CUTS=1hurt on 6C/12T: adding them on top ofTHIN_PEEPHOLE + SUBMIT_STAGE_SPLITadded+5.0 mstosubmit_prep(30.5 -> 35.5 ms) and dropped FPS back to24.75 FPS(unlike 16C/32T9950Xwhere extra worker cores are free).clippyfailure on this PR run is only fromorigin/main's recently mergedhost/menu.rsandhost/panel.rs, not from PR#4855files.@tikD1337 on GitHub · 2026-12-01 12:33 UTC · original
Quick follow-up on the
PORT_CONSTANTS=0observation above:In
pr4855-full-noport, settingVICTORY_PORT_CONSTANTS=0dropped GPUcardtime to20.6 ms, but CPUpreparingclimbed to38.8 ms(~72 MB/fcopies) and starved the GPU.Testing a combined
--releasebuild on5fabb46ewithVICTORY_THIN_PEEPHOLE=1stacked together with@POMXARK's01 GUARD_SHARDED=1+03 LOW_L0_DMA=1+04 DESC_MIRROR_CAP=1, SOFT_BATCH=1and#4527(VICTORY_WC_BAR=3) underVICTORY_PORT_CONSTANTS=0resolves that CPU copy overhead cleanly (Ryzen 5 7600 + RTX 4070 Ti SUPER, 105 s steady 3D runs, 0 crashes):>=200lists)card(GPU)submit_prep5.5k–6.5k~10.9kheavy windowTHIN_PEEPHOLE=1solo (PC=1)THIN_PEEPHOLE=1+LOW_L0_DMAstack (PC=0)SUBMIT_STAGE_SPLIT=1(PC=0)VICTORY_THIN_PEEPHOLE=1composes super cleanly withLOW_L0_DMA=1(L0_DMA 7.4 MB/f,WW_low 4.74 ms,card_cp 0.7 ms), holding21.7 FPSeven on~10.9k-draw windows and leaving~9.1 msGPU idle headroom for faster CPUs!@lyufeng000 on GitHub · 2026-12-01 12:47 UTC · original
Hi @tikD1337,
Thank you so much for the thorough A/B benchmarks, the follow-up test with
LOW_L0_DMA, and the great suggestion!I've split Stage 0 (
VICTORY_THIN_PEEPHOLE=1) out into a standalone PR (#4886) touching onlycrates/victory-gpu/src/list/thin.rs, so it can be reviewed and merged independently.@trustno1-coder on GitHub · 2026-12-01 18:30 UTC · original
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
Pull request closed