Port opt-in GPU byte-masked patch uploads (VICTORY_MASKED_PATCH) #269
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
needs-logs
old-names
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/TaynanGT--Vice-Tay!269
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-269"
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?
@Vladimir-Human on GitHub · 2026-11-27 13:05 UTC · original
Vladimir-Human:perf/masked-patch-uploads→main· +47008 −4130 · 187 files · 552 commits · closed without mergingSummary
Ports opt-in
VICTORY_MASKED_PATCH(off by default; adapted fromfxceless/victory-forkcommits3221ac4,0e006f0, and50c79c3) intovictory-gpu.With
VICTORY_MASKED_PATCHunset or0(default), baseline behavior is unchanged: theMASKED_PATCHcompute pipeline is not compiled,card_patches()is a no-op, and pages exceeding the per-submission run cap settle flights as before. When opted in viaVICTORY_MASKED_PATCH=1(oraltfor 20s alternating comparison, orVICTORY_ABunderdiagnostics), pages exceedingruns_leftemit folded 12-byte(offset, mask, value)dword patches applied via aMASKED_PATCHcompute pass sharingCARD_COMPARE's root signature instead of stalling the queue.Key Changes
crates/victory-gpu/src/shadow.rs:PatchWord,Patch,Card::{patch, has_patch}, opt-inmasked_patch_mode()(0off by default,1on,alt20s alternating, plusVICTORY_ABunderdiagnostics),PATCH_READY,masked_patch_now(),patch_words(), chronologicalfolded()dword merging, exact-piecepiece_spans(), andcard_patches(sent_as).PageMerge::{Dirty, Patched}into parallelmerge_under_writes/merge_page_under_writes, restoring unspentleftbudget and emitting exact byte-masked words when a page exceeds the cap (withat + n <= u32::MAX - 3bounds safety).dirty -> patch -> sent), updates lock-freecard_merge_relayandland_cardfast paths (publishinghas_sentbefore clearinghas_patch), and includes pending masked-patch ranges incard_dirty_now.crates/victory-gpu/src/host/masked_patch.rs&crates/victory-gpu/src/host.rs:MASKED_PATCH(cs_5_1) sharingCARD_COMPARE's root signature only when opted in, and pools patch upload buffers (PATCH_POOL_MOST = 4).MASKED_PATCHinHost::card_beforebeforecard.dirty(send::Own/upq/ direct copies) so newer dirty ranges always win over earlier patch words—including sub-dword byte overlaps within the same 32-bit dword—while preserving untouched sibling bytes written by in-flight shaders, with exact D3D12 state transitions (upcheck/dirty/before) andCARD_COMPAREpiece rehashing overranges.iter().chain(patched).pages,dwords,dispatches,submissions) alongside the wait/settle breakdown when enabled.crates/victory-gpu/src/indirect.rs&crates/victory-gpu/src/host/masked_patch.rstests:masked_patch_defaults_off_and_parses_opt_in_modes, baseline settle vs opt-in patch check inmerge_under_writes_patches_past_run_cap_without_settling).hw_masked_patch_byte_mask_and_dirty_ordering,warp_masked_patch_byte_mask_and_dirty_ordering, andhw_host_card_before_applies_masked_patch_and_dirty_in_orderrunning realHost::card_beforein isolatedVICTORY_MASKED_PATCH=1subprocesses on HW and WARP withID3D12InfoQueue0-error assertions) covering all 3 within-dword overlap cases ([patch0, dirty1, dirty2, dirty3],[patch0, dirty1, dirty2, flight 0xEE],[dirty0, dirty1, patch2, patch3]), aligned 4-byteSCATTERdirty override, overlapping patches, andCARD_COMPARErehash + mutation detection.Verification (
rustc 1.98.1&1.100.0,VICTORY_D3D12_DEBUG=1,--test-threads=1)cargo clippy -p victory-gpu --all-targets --locked -- -D warnings(default &--features diagnostics): 0 warningscargo run -p xtask --locked -- policy --staged(4 files ok),xtask policy(314 files ok),cargo test -p xtask --locked(11/11 passed)victory-gpuPR A suite (masked_patch,piece_spans_preserve_exact_rehash_piece_set,lock_free_card_,merge_under_writes_patches_past_run_cap_without_settling,warp_card_compare_stores_the_hash_it_made_when_told): 11/11 HW default, 11/11 HWdiagnostics, 11/11 WARPdiagnostics(0 skips, 0 D3D12 debug errors).Credit: adapted from
fxceless/victory-fork(3221ac4,0e006f0,50c79c3).@TaynanGT on GitHub · 2026-11-27 13:09 UTC · original
@Vladimir-Human Keep masked patches opt-in for the first comparison. A newer dirty copy must still win over an earlier patch, including a byte overlap within one dword. That ordering test and a same-route wait measurement will tell us more than enabling it by default.
Port GPU byte-masked patch uploads (VICTORY_MASKED_PATCH)to Port opt-in GPU byte-masked patch uploads (VICTORY_MASKED_PATCH)5d31b8e485tocfddee33a7@Vladimir-Human on GitHub · 2026-11-27 13:47 UTC · original
@TaynanGT Updated in
cfddee33to address both points:Opt-in by default (
VICTORY_MASKED_PATCH=0/ unset):shadow::masked_patch_mode()now defaults to0(off). When unset or0,Host::make_card_workskips compiling theMASKED_PATCHPSO (PATCH_READYstaysfalse),card_patches()returns immediately, andmerge_under_writessettles flights as baseline.VICTORY_MASKED_PATCH=1,VICTORY_MASKED_PATCH=alt(20s alternating), orVICTORY_AB(underdiagnostics) opts in and logs per-frame masked-patch counts (pages,dwords,dispatches,submissions) alongside the existing wait/settle breakdown for same-route comparisons.shadow::copied_and_take_tests::masked_patch_defaults_off_and_parses_opt_in_modesand updatedmerge_under_writes_patches_past_run_cap_without_settlingto verify both default-off baseline settling and opt-in masked patching.D3D12 HW + WARP sub-dword overlap ordering tests (
VICTORY_D3D12_DEBUG=1):Host::card_beforeordersMASKED_PATCH-> transition barrier ->card.dirty(send::OwnCopyBufferRegion/SCATTER,upq, or direct copy) ->CARD_COMPARErehash, withself.dataupdated synchronously when each patch or dirty run is recorded.indirect::tests::{hw,warp}_masked_patch_byte_mask_and_dirty_ordering(dwords128..140) andhost::masked_patch::tests::hw_host_card_before_applies_masked_patch_and_dirty_in_order(dwords16..28, running the realHost::card_beforepath in isolatedVICTORY_MASKED_PATCH=1subprocesses on HW and, underdiagnostics, WARP withID3D12InfoQueue0-error assertions):0..=1+ newer dirty copy on bytes1..=3->[patch0, dirty1, dirty2, dirty3]0..=1+ newer dirty copy on bytes1..=2+ untouched flight byte3(0xEE) ->[patch0, dirty1, dirty2, 0xEE]1..=3+ newer dirty copy on bytes0..=1->[dirty0, dirty1, patch2, patch3]SCATTERdirty override over an earlier masked patch.Re-verified locally (
VICTORY_D3D12_DEBUG=1,--test-threads=1):clippy --all-targets --locked -- -D warnings(default &diagnostics) 0 warnings,xtask policy(314 files ok) &xtasktests 11/11, and the PR test suite 11/11 HW default, 11/11 HWdiagnostics, and 11/11 WARPdiagnostics(0 D3D12 debug errors).@TaynanGT on GitHub · 2026-11-27 13:51 UTC · original
@Vladimir-Human The default-off path and the overlapping-byte checks are the controls we needed. Keep the later dirty write winning and the untouched byte stable in the full path. The matched run can now compare settle time and the masked-patch counters separately.
@TaynanGT on GitHub · 2026-11-30 17:13 UTC · original
mainhas moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the currentmainand open a new PR; I'll review it there.Pull request closed