GPU: batch hoisted mode-7 indirect argument clamps into 64-lane SIMD dispatches (22x faster) #120
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/Belobug--VIctory-Belobug-AMD!120
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-120"
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?
@ESAT586 on GitHub · 2026-11-25 14:53 UTC · original
ESAT586:belobug/batch-hoisted-clamps→main· +1275 −9 · 2 files · 2 commits · openSummary
Batches default
VICTORY_HOIST_CLAMPS=7hoisted indirect argument clamps into a single 64-lane SIMD compute shader (BATCH_SOURCE) flushed inHostList::clamp_end(), preserving exact sequential draw-orderBUDGETcharging (so objects never flicker from frame to frame) while eliminating thousands of per-drawDispatch(1, 1, 1)calls and globalUAV(None)barriers.Why
VICTORY_HOIST_CLAMPS=7currently solves the non-deterministic budget cutoff flickering seen inmode 1by recording oneSetComputeRootSignature+SetPipelineState+Dispatch(1, 1, 1)+ globalUAV(None)barrier per hoisted indirect draw (~9,000 dispatches and ~9,000 full pipeline UAV barriers per frame).What Changed
crates/victory-gpu/src/indirect.rs:BATCH_SOURCE(cs_5_1) accepting a persistent mapped upload buffer of packed 32-byte job descriptors (kind,stride,records,args_offset,has_count,count_offset,dst_offset).records == 1) in one wave and tiles multi-record jobs (records > 1) in 64-lane waves, with lane 0 accumulatingBUDGET = 1 << 27strictly in draw order (leftsaturation matchesSOURCEbit-for-bit).src -> dstscratch copy semantics:count_bufawareness (eff_count = min(records, count_buf.Load(count_offset)), inactive slots untouched and uncharged), full trailing custom stride word preservation (off >= 8/12), and zero mutations tosrc_argsorcount_buf.ClampBatch/JobUpload/flush_before()coalescing adjacent jobs sharing(src_gpu, dst_gpu)and compatiblecount_gpu(allowing uncountedcount = Nonejobs to merge into adjacent counted runs), emitting oneDispatch(1, 1, 1)per run and one scopedUAV(Some(budget_resource))barrier between runs.VICTORY_HOIST_FILEtransitions betweenmode 7and non-7 diagnostic modes safely by flushing prior queued jobs and serializingbudgetacross batch <-> unbatched boundaries.HostList::reset()upload reuse, livemode 7 -> mode 1 -> mode 7interleaving, plus an ignored 9,000-draw release benchmark.crates/victory-gpu/src/host.rs:clamp_batch: Mutex<crate::indirect::ClampBatch>toHostList, reset inHostList::reset(), flushed at the start ofHostList::clamp_end()right before transitioning scratch chunks toINDIRECT_ARGUMENT, plusbudget_resource().Benchmark (RTX 3060 Ti,
--release)Collapses 9,000
mode 7dispatches + 9,000 globalUAV(None)barriers across two 256 KiBclamp_roomchunks into 2 dispatches + 1 scoped budget UAV barrier, saving ~41 ms/frame with identical draw-order budget determinism.Verification
cargo test -p victory-gpu --locked -- indirect::tests-> 9 passed, 0 failed.VICTORY_D3D12_DEBUG=1 RUST_LOG=warn,--features diagnostics --test-threads=1):indirect::tests-> 9 passed, 0 failed, 0 D3D12 warnings/errors.VICTORY_D3D12_WARP=1,--features diagnostics --test-threads=1):indirect::tests-> 9 passed, 0 failed (fullvictory-gpusuite: 117/118 passed; only pre-existing #102watch::tests::written_pages_are_reported_to_every_askerfailed).--all-targets&--all-features): 0 warnings incrates/victory-gpu/src/indirect.rsand modified lines ofcrates/victory-gpu/src/host.rs.cargo xtask policy --staged->asset policy: 2 files ok.(Related upstream PR on
Marvisak/VIctory: Marvisak/VIctory#2472)@jmal423 on GitHub · 2026-11-25 16:30 UTC · original
Tested this PR on Windows 11 / AMD Radeon RX 9070 XT (Series X target):
With this PR applied, the GPU hangs shortly after entering the prison cell (
DXGI_ERROR_DEVICE_HUNG,0x887A0006), both withVICTORY_ASYNC_SUBMIT=1and without it. Reverting this PR eliminates theDEVICE_HUNGimmediately.@ESAT586 on GitHub · 2026-11-25 16:58 UTC · original
Thanks for testing on RX 9070 XT and isolating this to the PR, @jmal423!
Disassembling
BATCH_SOURCEwithfxc /T cs_5_1 /Fcexposed three FXC non-short-circuiting bugs that caused hardware GPUVM page faults (DXGI_ERROR_DEVICE_HUNG) on AMD:jobsRoot-SRV load:has_job ? jobs.Load4((j + lane) * 32) : 0compiled to unconditionalld_rawonT0(jobs) before masking. Since D3D12 root SRVs have no hardware bounds check, inactive tail lanes (j + lane >= end) read up to 2,016 bytes past the end of the upload buffer whenever a list approached a 4 KiB / 64 KiB page boundary.count_bufRoot-SRV load whenhas_count == 0:(j1.x == 0) || (count_buf.Load(j1.y) >= 1u)compiled to an unconditionalld_rawat offset0ofT2(count_buf, which fell back tosrc_base). On sparseCreateReservedResourceShadowbuffers where Tile 0 (0..64 KiB) is unmapped and onlysrc_offsetis backed, every uncounted draw faulted on offset0.costs[64]:while (run < 64 && costs[run] == 1)compiled told_structured g0[64]past the 64-elementgroupshared uint costs[64]array whenever 64 consecutive single-record draws filled a wave.Fixed in the latest commit
||/&&around all root-SRV and LDS loads with explicit[branch]/[loop]+breakguards (verified infxc /FcDXBC disassembly: everyld_rawandld_structuredis now strictly insideif_nz/ afterbreakc_nz, and noudivcan divide by zero).upload_gpu(always resident, non-sparse) toT2when a run has no count buffer, used full UAV barriers between distinct buffer runs (preventing 128-byte cache-line hazards across adjacent 16-byte slices in aclamp_roomchunk), and mirrored job payloads in host RAM so mid-list buffer growth never reads back from write-combined upload/ReBAR memory.batched_bound_before_guards_page_boundary_and_sparse_unmapped_tile_zerocovering exact 64 KiB job-buffer boundaries (2047/2048jobs) and uncounted draws from aCreateReservedResourcesparse buffer with Tile 0 unmapped — verified 10/10 on RTX 3060 Ti, 10/10 with D3D12 Debug Layer + GPU-Based Validation (VICTORY_D3D12_DEBUG=1 VICTORY_D3D12_GBV=1, 0 warnings/errors), and 10/10 on WARP.Could you re-test on your RX 9070 XT when you get a chance?
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.