BCPack: retain a partial rANS refill at a fragment boundary #2649
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!2649
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2649"
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?
@chaseb64 on GitHub · 2026-11-25 17:30 UTC · original
chaseb64:formats/bcpack-fragment-carry→main· +24 −10 · 1 files · 1 commits · openSummary
A valid unflushed fragment can supply the first byte of a two-byte refill and leave the lane below its normalization threshold. Preserve that partial state and let the lane take its drain step before requesting the next fragment header. NEW-101 coordination claim
Evidence
Six independently generated streams, one for each supported layout, returned success with incorrect lane records on main. A ten-byte single-lane witness isolates the arithmetic. The regression in this patch staggers the fragment boundary across two lanes and checks records
[31, 31, 30, 30]. Removing only the drain step makes it fail even when the state is retained. The clocked and fast Rust paths in bcpack-rs independently decode the same contiguous inputs. Reference decoder · Microsoft RTLOn the standalone candidate the native Windows formats suite passed 39 tests and the focused DirectStorage suite passed 14. Workspace tests, both Clippy configurations and asset policy passed. The full 53-stream corpus matches when this fix and the separate lane-completion fix are both present. Standalone Windows run · Baseline Windows run
The native Windows guest also reproduced this defect through a normal two-block BC1 memory request. Upstream returned HRESULT 0x8007000d. On the combined candidate, the guest received
00800000aaaaaaaa00780000aaaaaaaaand its destination guards stayed intact. Both revisions passed all twelve two-block raw/zlib controls across the six supported formats. Paired native guest runThe standalone change applies cleanly to current
mainat13f91caee25f2fdf2c062be5f7a27f058e51cbca. The formats crate and pinned Rust toolchain match the validated baseline.Merge Danger
Reversible. This changes state retention and input scheduling at a partial refill. It applies across all supported formats. The synthetic fixtures establish decoder behavior at this boundary. They do not measure its frequency in title data.
AI-assisted using OpenAI Codex. GPT-6.2 Astra (Ultra and High) developed and independently reviewed the change and its timing-sensitive regression. GPT-6.2 Sol (High) and GPT-6 Luna (Medium) contributed validation.
@kotekompotek on GitHub · 2026-11-25 17:48 UTC · original
Reviewed against #2648 — complementary, not overlapping: this fixes
Lane::stepso a refill byte that still leavesx < LOWgoes through one drain step before the lane ends its fragment (the 'unflushed fragment splits a refill' case in the test), while #2648 fixes the outer schedule loop for lanes whose payload is already exhausted. The state math in the test is checkable:0x100 → refill 0xff → 0x100ff < LOW → refill 0xfe → 0x100fffe. CI green.@oni-swr on GitHub · 2026-11-25 17:58 UTC · original
Independent verification of head
422797364e2326c89c0ba1df6d247ea5bcd123b4(merge-base940d32f6, one commit) merged ontoorigin/main13f91caee25f2fdf2c062be5f7a27f058e51cbca.-j 4, CPU-only.bcpack.rsLane::step(keep a partially refilled state at a fragment boundary instead of dropping it) plus 1 test. Merges cleanly.cargo clippy --locked -p victory-formats --all-targets: no warnings.cargo test --locked -p victory-formats: 39 passed, 0 failed, 5 ignored (origin/main: 38/0/5).lanes(), this touchesLane::step; #2648's removal of the helper's filler bytes does not break this PR's test).Lane::stepreverted to the base logic,unflushed_fragments_can_split_a_refillfails (the other 9bcpacktests pass).Independent verification by Claude Code (Claude Sonnet 5.5), an AI. No game files, dumps or shader names were used. Each PR head was merged (no conflicts) onto
origin/mainand run with--locked; clippy used--all-targets.@fuzeofficlal on GitHub · 2026-11-25 18:16 UTC · original
Tested
42279736merged ontomain(13f91ca), both standalone and combined with #2648 (d70171b6, auto-merges cleanly without conflicts):cargo test -p victory-formats --lib bcpack— 10 passed, 0 failed, 2 ignoredcargo test -p victory-formats --lib bcpack— 12 passed, 0 failed, 2 ignoredcargo clippy -p victory-formats --all-targets -- -D warnings: clean (0 warnings)Verified
refillretention across fragment drain andself.resethandling on fragment end — looks clean.@Marvisak on GitHub · 2026-11-25 22:18 UTC · original
Automated triage for the maintainers.
Merge candidate. In
Lane::step(crates/victory-formats/src/bcpack.rs), a refill byte that leaves the state belowLOW(2^24) at the end of a fragment now gets one drain step, and the partial state is carried into the next fragment instead of being dropped. I traced the test's numbers (0x100, then 0xff gives 0x100ff, belowLOW; after the boundary 0xfe gives 0x0100fffe, which decodes 30), and checked that the lane asks for no bytes during the drain step and still clears the state whenresetis set. The evidence is the public Microsoft rANS RTL and an independent reference decoder, both linked in the description, plus a synthetic regression test. It merges cleanly; CIcheck: passing.For the maintainer: this reverses a statement in
main's own comment ("a byte read in this step does not reach the carried state"), so it is worth comparing with the cited RTL lines. The companion fix #2648 (lane completion) is needed for the full corpus to match, according to the author, and now needs a rebase.Generated by Claude Code
@lcg007xd-c on GitHub · 2026-11-25 21:17 UTC · original · approved these changes
Verified on Linux (Rust 1.99.0)
Branch: current
main(13f91ca) + this PR (merges cleanly).cargo test --locked -p victory-formats: 39 passed, 5 ignored.Lane::steprestored to main (therefillbinding, the extra drain condition and theself.x = .. xcarry reverted) and the test kept,unflushed_fragments_can_split_a_refillfails. So the test pins the fix.main+ #2648 + #2649, no conflicts): 41 passed.cargo clippy --locked --target x86_64-pc-windows-msvc -p victory-formats --all-targets -- -D warnings: clean, same as main.Checked against the RTL
mdu_minirans.vat 2f6827d matches both parts of the change:DSTATE_PROCESSING,rans_state_p1 <= new_rans_state_p1(line 1177), andnew_rans_state_p1israns_state_with_input(line 931). So the byte taken on the final payload step does reach the state carried into the next fragment. The removed main comment ("a byte read in this step does not reach the carried state") was wrong.MDU_RANS_LOWER_LIMIT, the RTL goes toDSTATE_DRAINING(line 1191) and only returns toDSTATE_HDR0from there (lines 1204-1210). That is the one-clock drain added by therefill.is_some() && x < LOWbranch.I found no defect. One suggestion: the new
self.x = if self.reset { 0 } else { x }(bcpack.rs:376) also changes a case the description doesn't mention. The last payload byte lands the state on exactlyLOW(2^24), andleft == 0. Main kept the pre-refill state there. This PR carriesLOW, which is what the RTL does (== MDU_RANS_LOWER_LIMIT->DSTATE_HDR0, lines 1185-1189). The round-trip tests do reach that path (a temporarypanic!there fires inevery_layout_round_trips_through_the_lanes,bc7_mode6_blockandmalformed_input_is_an_error). But they don't pin it: keeping main's pre-refill state for just that case still passes all bcpack tests, on this branch alone and with #2648. A test with a non-reset fragment that ends at exactlyLOWand is followed by another fragment would pin it.Also note that this PR and #2648 both conflict textually with #2735, which rewrites
Lane::step.Not verified
reference_chunksagainst title data (needsVICTORY_BCPACK_TABLES/VICTORY_BCPACK_CASES, which I don't have).Reviewed with Claude Code.
@futurepro62 on GitHub · 2026-11-26 11:22 UTC · original
NVIDIA full-suite run, to go with the reports above by fuzeofficlal, lcg007xd-c, oni-swr, since none of them names a GPU run. Tested exact head
4227973(on its base940d32f).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 697 passed, 0 failed, 10 ignored.unflushed_fragments_can_split_a_refill.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
@fuzeofficlal on GitHub · 2026-11-26 11:53 UTC · original · approved these changes
Reviewed
42279736and verified locally (cleangit merge-treeagainstmain63bcca43and cleanly composable with #2648): retainingrefillacross the fragment boundary inLane::step(crates/victory-formats/src/bcpack.rs:344-377) and taking a single drain step whenrefill.is_some() && x < LOWensures the partial state is preserved while keeping the next header request timed accurately, as verified byunflushed_fragments_can_split_a_refill.rustfmt --edition 2024 --check,xtask policy,cargo clippy -p victory-formats --all-targets -- -D warnings(default and--all-features), andcargo test -p victory-formats --locked(39 passed, 0 failed, 5 ignored) all pass.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.