BCPack: stop completed lanes from taking another lane’s bytes #2648
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!2648
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2648"
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-stream-audit→main· +48 −8 · 1 files · 1 commits · openSummary
A lane can deliver its final symbol before its peers. Starting another fragment on that lane can consume a peer’s pending header or payload. Let the lane finish consuming its declared payload, including optional trailing renormalization bytes, then leave future bytes for the other lanes. NEW-100 coordination claim
Evidence
On main at
940d32f, a valid one-block BC1 stream failed with “the stream ends early or is corrupt”. At byte 52 the reference feeds lane 8 while main feeds lane 0. The corrected public decoder emits00 00 00 00 aa aa aa aa. A separate source-generated BC4 regression exercises the entire decode path, and a two-lane case detects dropping a declared payload byte after the final symbol. The reference was Ahmet Dedeler’s bcpack-rs, checked against the output-count behavior in Microsoft’s single-lane RTL. bcpack-rs · Microsoft RTLOn the original pre-rebase revision (
d70171b604cfb4a3c0a0019c4d3bf254ec81f34e), the standalone candidate repaired all 16 early errors in a 53-stream corpus while six separate unflushed-refill cases still returned incorrect records; on native Windows the formats suite passed 40 tests, the focused DirectStorage suite passed 14, and workspace tests, both Clippy configurations and asset policy passed. Baseline Windows run · Standalone Windows runOn the pre-rebase combined revision (
42a4e75b55de7f84e0eca2c113f87a314d678082), the native #2057 guest title also delivered the expected one-block BC1 texture (upstream returned HRESULT 0x8007000d on that same request; the other ten campaign checks passed on both), and the 5,031-stream entropy campaign passed (5031 streams; 37130 blocks; 841536 symbols; 247758 fragments; 0 subject errors; 0 record mismatches). Paired native runRebase onto
main(63bcca43c6a00a758510398fa43096ce7e4f7df0)Rebased cleanly onto
main(63bcca43c6a00a758510398fa43096ce7e4f7df0) atfbf875e0730d3e8e9bd5dcf8054bac2e84e1227a, preserving upstream#2036(bc1_endpoint_prediction_and_quadrant_order) and the original validated commitd70171b604cfb4a3c0a0019c4d3bf254ec81f34e(whose historical native Windows runs45579091079,45582050258,45583602232, and45665538370apply to the pre-rebase revision and were not re-run on native Windows after rebasing). Betweend70171band63bcca4,rust-toolchain.tomlandCargo.lockare unchanged, and the only changes incrates/victory-formatsare#2036(bcpack.rs) and#1205(xma/tables.rs).New Linux verification on rebased commit
fbf875e(OrbStackrustc 1.98.1):cargo test --locked -p victory-formats: 48 passed, 0 failed, 5 ignored (both debug and--release;bcpack::tests12 passed, 0 failed, 2 ignored;bcpack_throughputpassed).continueguard inlanes()): 8 passed, 4 failed (a_last_symbol_can_precede_its_final_payload_bytes,finished_lanes_leave_the_remaining_payload_for_their_peers,bc7_mode6_block,every_layout_round_trips_through_the_lanes), 2 ignored.cargo clippy -p victory-formats --all-targets --locked -- -D warnings: clean across default and--all-featureson both Linux native and--target x86_64-pc-windows-msvc.cargo test --locked -p xtask(6 passed) andcargo xtask policy(asset policy: 191 files ok): passed.4227973): auto-merges cleanly and passescargo test --locked -p victory-formats(49 passed, 0 failed, 5 ignored) and Clippy (-D warnings).Merge Danger
Reversible. This changes byte ownership at the end of a stream for every supported BC format. Both regressions are portable and use source-generated data. PR #703 has a separate streaming scheduler and would need the equivalent behavior if adopted. Retail incidence and rendering impact are unmeasured. PR #703
AI-assisted using OpenAI Codex and Google Antigravity in T3 Code. For the original revision (
d70171b), OpenAI Codex GPT-6.2 Astra (Ultra and High) implemented and independently reviewed the scheduler correction, and GPT-6.2 Sol (High) and GPT-6 Luna (Medium) contributed format, runtime, performance and cross-platform validation. For the rebase onto63bcca4(fbf875e), Google Antigravity (gemini-4-neon, requestedthought_level: high;gemini-4-hydrogen, requestedthought_level: highandmedium) coordinated, implemented the minimal rebase, and executed Linux/OrbStack validation, while OpenAI Codex (gpt-6.2-astra, verifiedexecutedModel: gpt-6.2-astra, requestedreasoningEffort: high) independently reviewed the rebased resolution.d70171b604tofbf875e073@kotekompotek on GitHub · 2026-11-25 17:48 UTC · original
Reviewed against #2649 — complementary, not overlapping: this fixes the schedule loop (a finished lane on the last symbol no longer opens a header request that would steal a peer's bytes), while #2649 fixes the in-lane phase machine (a partial refill below LOW drains for one step across the boundary instead of ending the fragment). Both are needed for correct fragment-boundary behavior. The regression tests here exercise the byte-order swap that occurs when lane 0's early request shifts lane 1's header. CI green.
@oni-swr on GitHub · 2026-11-25 17:58 UTC · original
Independent verification of head
d70171b604cfb4a3c0a0019c4d3bf254ec81f34e(merge-base940d32f6, one commit) merged ontoorigin/main13f91caee25f2fdf2c062be5f7a27f058e51cbca.-j 4, CPU-only.bcpack.rslanes()(a lane with its last symbol out and no payload left does not start another header), a test-helper change, and 2 tests. Merges cleanly.cargo clippy --locked -p victory-formats --all-targets: no warnings.cargo test --locked -p victory-formats: 40 passed, 0 failed, 5 ignored (origin/main: 38/0/5).bcpack.rs): both merged ontoorigin/mainauto-merge with no conflict; clippy clean; 41 passed, 0 failed, 5 ignored (38 + 3 new tests, all passing together). #2649 alone: 39/0/5. They compose cleanly.continueblock removed, 4 tests fail: both new ones (a_last_symbol_can_precede_its_final_payload_bytes,finished_lanes_leave_the_remaining_payload_for_their_peers) and, because thestream()helper no longer appends filler bytes,bc7_mode6_blockandevery_layout_round_trips_through_the_lanes("a lane read past its fragment"). The existing round-trip tests therefore enforce the fix too.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
d70171b6merged ontomain(13f91ca), both standalone and combined with #2649 (42279736, auto-merges cleanly without conflicts):cargo test -p victory-formats --lib bcpack— 11 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)Both standalone and combined paths look solid.
@Marvisak on GitHub · 2026-11-25 22:15 UTC · original · edited 2026-11-26 05:28 UTC
Automated triage for the maintainers.
Thanks for the rebase.
fbf875enow merges cleanly, so the earlier needs-rebase no longer applies. Inbcpack.rslanes(), a lane that has delivered the last symbol and has no payload bytes left (lane.left == 0) no longer opens another header request, so it can't take a peer's header or payload bytes. The test helperstream()stops adding filler bytes for finished lanes, which means the existing round-trip tests now enforce the fix too. The two new tests cover both directions: finished lanes leave the bytes to their peers, and a lane still takes the trailing bytes of its last payload. The PR body cites public references for the schedule: bcpack-rs and Microsoft's single-lane rANS RTL. Independent runs in the thread report that it composes cleanly with #2649. CI: passing.Verdict: merge candidate. Recommending a look, not approving.
Generated by Claude Code
@chaseb64 on GitHub · 2026-11-26 04:23 UTC · original
Rebased onto
main(63bcca43c6a00a758510398fa43096ce7e4f7df0) atfbf875e0730d3e8e9bd5dcf8054bac2e84e1227a(original validated revision:d70171b604cfb4a3c0a0019c4d3bf254ec81f34e).mod testsadd/add conflict incrates/victory-formats/src/bcpack.rsby keeping#2036(bc1_endpoint_prediction_and_quadrant_order) untouched and placing PR #2648's two regression tests immediately after it;lanes(),stream(), and both regression tests are unchanged (git range-diffdiffers only by the context line preceding the new tests).fbf875e(OrbStackrustc 1.98.1):victory-formatspassed 48/48 (0 failed, 5 ignored) in debug and--release, negative control reproduced all 4 expected failures,victory-formatsClippy (--all-targets -- -D warnings, default &--all-features, Linux &x86_64-pc-windows-msvc) passed,xtask/cargo xtask policy(191 files ok) passed, and composition with PR #2649 (4227973) merged cleanly and passed 49/49.gpt-6.2-astra) approved preservation of the original decoder semantics. Historical native Windows runs (45579091079,45582050258,45583602232,45665538370) apply to the pre-rebase revision (d70171b/42a4e75), while upstream Windows CI onfbf875eis running now.@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: 40 passed, 5 ignored (benchmarks and the external-data tests).continueguard inlanesremoved (bcpack.rs:434-438) and the test changes kept, 4 tests fail: both new tests, plusevery_layout_round_trips_through_the_lanesandbc7_mode6_block. The last two fail because the helper no longer appends the[0, 1, 0, 0]filler fragment: "a lane read past its fragment". So the new behaviour is pinned both by the new tests and by the reworked round-trip helper.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
The cited
mdu_minirans.vat 2f6827d backs the change. InDSTATE_PROCESSINGthe decoder keeps taking payload bytes after the last symbol untilinput_remainingreaches 0. Then, withoutput_remaining == 0, it goes toDSTATE_IDLEwithdone <= 1(lines 1183-1195) instead ofDSTATE_HDR0. So a finished lane drains its declared payload and never reads another header, which is what the guard implements. Main's assumption, written in the old helper comment, was that a finished lane keeps asking and is fed a filler fragment. Nothing in that RTL supports it.I found no defect. Two small notes:
continues beforelane.stalledis recomputed and beforelane.out.take(). That is fine for valid streams, because the lane has already delivered. A one-line comment saying the lane is done for good would stop a later edit from moving code under the guard.Lane::step. Whichever lands later needs a careful rebase, because the round-trip helper semantics change here.Not verified
reference_chunks(needsVICTORY_BCPACK_TABLES/VICTORY_BCPACK_CASES): not run. I don't have title chunks. Running it on this branch is the one check that would show real title streams don't contain the filler fragments main used to expect.Reviewed with Claude Code.
@futurepro62 on GitHub · 2026-11-26 11:19 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
fbf875e(on its base63bcca4).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: 868 passed, 0 failed, 10 ignored.finished_lanes_leave_the_remaining_payload_for_their_peers,a_last_symbol_can_precede_its_final_payload_bytes.--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
fbf875e0and verified both standalone and composed with #2649 (42279736): guarding onpos + 1 == symbols && done & bit != 0 && lane.left == 0afterlane.step(t)?(crates/victory-formats/src/bcpack.rs:424-447) prevents finished lanes from starting a spurious next header request while still letting them drain any trailing renormalization bytes in their current payload, and removing the[0, 1, 0, 0]filler fromstream()strengthens existing round-trip coverage as well.rustfmt --edition 2024 --check,xtask policy(191 files ok),cargo clippy -p victory-formats --all-targets -- -D warnings(default and--all-features),cargo test -p victory-formats --lockedstandalone (48 passed, 0 failed, 5 ignored), and composed with #2649 (clean merge, Clippy clean, 49 passed, 0 failed, 5 ignored) all pass.@guialmm on GitHub · 2026-11-26 17:19 UTC · original
Cross-check against an independent decoder, for this PR and #2649 together.
I decoded synthetic streams from bcpack-rs's encoder (
encode::syntheticand fragments split mid-state, all six modes, 1 to 1000 blocks) with both bcpack-rs's lane decoder (rans::decode_slice) and VIctory'slanes(), and compared the symbols lane by lane. bcpack-rs uses its own MIT model tables (fromsilicon-rans); VIctory usedbcpack-tables.bin. No game files.main63bcca4main+ this PR (fbf875e) + #2649 (4227973)The minimal case is one one-symbol fragment per lane: on
mainit decodes for 1 to 8 lanes and fails every time from 9 lanes up (300 of 300 each, "the stream ends early or is corrupt"); with both PRs it passes for 9, 10, 12 and 16 lanes. That fits the eight-byte round: lanes 0..7 finish and, onmain, ask for a header and take lane 8's bytes.Microsoft's
mdu_minirans.vagrees with the fixed behaviour for a single lane: when a fragment's input runs out withoutput_remaining == 0(inDSTATE_PROCESSING, or inDSTATE_DRAININGonce the state is at or below the limit) the lane setsdoneand goes toDSTATE_IDLE, whereneed_ib_load(sodin_req) is never set. It only returns toDSTATE_HDR0while it still has output to give. The feeder between lanes is not in that file, so the eight-byte schedule itself is not checked by this.With both PRs, on damaged streams (one bit flipped) where both decoders return symbols, the symbols are identical in every case (352 of 3000; on
main, 92 differed). The remaining difference is policy: bcpack-rs rejects non-zero bytes after the last one a lane needs, VIctory ignores them.The harness is a local scratch crate (path dependencies on both crates,
lanes()madepublocally); I can post it if useful.AI-assisted (Claude Code, Claude Opus 5.5): wrote the harness, ran it on my machine and drafted this.
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.