Repository navigation
Conversation
The rANS lanes a BCPack stream is split into, for BC1, BC3, BC4, BC5, BC6H and BC7: a port of the decoder module of Microsoft's silicon-rans sample (MIT), with the byte feeder and symbol release after the format notes of bcpack-decoder and bcpack-rs (MIT, no code taken). The 128 static models are generated by scripts/gen_bcpack_tables.py from the sample. Nothing calls it yet; DirectStorage still refuses BCPack requests. Tested against fixtures from an encoder written independently from the notes (tests/data/bcpack/generate.py) and a round-trip encoder. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
BC1 blocks are rebuilt from the 12 lanes of the entropy stage (bc1.rs, after the BC1 sections of the bcpack-decoder and bcpack-rs format notes, MIT, no code taken). The rebuild needs two tables of constants that no stream carries: the 255 endpoint sets a stream starts with and the order of the 256 selector quadrants. bcpack-rs by Ahmet Dedeler (https://github.com/Ahmet-Dedeler/bcpack-rs, MIT) estimated both from retail data; bc1_fitted.rs is generated from its data files by scripts/gen_bcpack_bc1_tables.py and carries its MIT notice. The constants belong to the codec, not to a game. dstorage.rs runs the BCPack stage for BC1, alone or after zlib; every other mode is refused and counted as before. A stream the decoder does not take fails the request with E_DECOMPRESSION and writes nothing. report.json gets dstorage.bcpack_unpacked per mode (requests, bytes rebuilt, failed). The output is an approximation where an estimate is off: one history entry is not known (a block that refers to it fails the request), 17 differ by a step or so between fits on two halves of the data, and 8 rare quadrants may be swapped with their mirror. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…called Stacked on ivall#273 (BC1), which is stacked on ivall#208 (entropy stage). Adds hle/bcpack/bc4.rs: BC4 blocks from the 12 lane symbols of a BC4 stream, in the form of ivall#273's bc1.rs. Lane 0 is a back-reference to the block whose endpoints predict this one's (or to a built-in history before block 0, or 128/128 for none), lane 1 must be 0, lanes 2-3 are zigzag differences of A0/A1 modulo 256, and lanes 4-11 are the 3-bit selectors two texels at a time through a 64-entry pair table, row by row, left half first. The rebuild needs two constants that no stream carries: the order of the 64 pairs and the 255-entry history. XCL has no source for them it can take, so they are a parameter (bc4::Tables), nothing is shipped and nothing calls the rebuild: DirectStorage refuses BC4 requests exactly as before. Every BC4 chunk of the retail title checked here predicts from the history in its first blocks, so the pair table alone would unlock none of them. Checked: - tests/data/bcpack/generate.py builds bc4-300-4 (300 blocks, predictions from the history and from the stream) with made-up tables and its own per-texel Python assembly; the decoder gives the same blocks, and refuses a block whose history entry is unknown. - A hand-built three-block case covers every field, wrapping differences and a non-zero lane 1. AI-assisted.
…called Stacked on the BC4 rebuild. Adds hle/bcpack/bc5.rs: BC5 blocks from the 12 lanes, two symbols per lane and block (units 2i and 2i+1). Lane 0 is a back-reference split over the two units (even bits in the first, odd bits in the second) and then read as BC4's; lane 1 must be 0 in both; lanes 2 and 3 are the differences of R0/R1 and G0/G1, one per unit; lanes 4-7 and 8-11 are the red and green selectors, a row per lane, the row's left half in the first unit and its right half in the second, through a pair table as BC4's. It reuses BC4's back-reference, difference and selector helpers. As for BC4, the pair order and the 255-entry history of endpoints (R0, R1, G0, G1) are not in a stream and XCL has no source for them it can take: they are a parameter, nothing is shipped or wired, and BC5 requests are refused as before. Every BC5 chunk of the retail title checked here predicts from the history in its first blocks. Checked: - generate.py builds bc5-600-5 (300 blocks) with the made-up tables and its own Python assembly; the decoder gives the same blocks, refuses an unknown history entry and a size of half a block. - A hand-built two-block case: the split back-reference (one block back, then 255 back), both channels' differences and selector rows, lane 1. AI-assisted.
…called Stacked on the BC5 rebuild. Adds hle/bcpack/bc3.rs: BC3 blocks from the 12 lanes, two symbols per lane and block. Lane 0 is BC5's split back-reference (prediction 128/128 for alpha and 0 for colour when there is none), lane 1 must be 0, lane 2 holds the A0/A1 differences, lanes 3-6 the alpha selector rows through a pair table as BC4's, lanes 7-9 the red/green/blue differences of colour 0 (first unit) and colour 1 (second unit) modulo 32, 64 and 32, and lanes 10-11 the colour selectors as BC1's 2x2 quadrants (top-left/top-right, bottom-left/bottom-right). Three constants are not in a stream: the alpha pair order, the quadrant order and the 255-entry history of endpoints (A0, A1, R0, G0, B0, R1, G1, B1). XCL has no source for them it can take, so they are a parameter and nothing is shipped or wired; BC3 requests are refused as before. Of the 35 BC3 chunks of the retail title checked here, 8 never predict from the history, so the two orders alone would unlock those 8. Checked: - generate.py builds bc3-600-6 (300 blocks) with made-up tables and its own per-texel Python assembly; the decoder gives the same blocks, refuses an unknown history entry and half a block. - A hand-built two-block case: every field, colour differences wrapping in 5 and 6 bits, a prediction from a rebuilt block's colours, lane 1. AI-assisted.
Owner
This was referenced Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #273 (itself on #208); only the top three commits belong here:
6fd5a60(BC4),f58df2f(BC5),e02a003(BC3).Adds the block rebuild for the three remaining 12-lane BCPack modes, from #208's lanes and in the form of #273's
bc1.rs. Each needs constants that no stream carries: the order of the 64 selector pairs (BC3 also the order of the 256 colour quadrants) and a built-in history of 255 endpoint sets that a stream's first blocks refer back to. XCL has no source for them it can take, so they are aTablesparameter: no table is shipped, nothing calls the new code, and DirectStorage refuses BC3 / BC4 / BC5 requests exactly as onmain. It is here so that whoever has the tables only has to supply them.No overlap found: #273 and #233 cover BC1 only.
What is in it
hle/bcpack/bc4.rs,bc5.rs,bc3.rs: lanes to blocks, one commit per mode. A block whose history entry is unknown fails withError::Historyand nothing is written.hle/bcpack/mod.rs: the modules and their docs.hle/bcpack/tests.rs,tests/data/bcpack/generate.py,tests/data/bcpack/bc{3,4,5}-*: a synthetic fixture per mode, built with made-up tables by the generator's own per-texel assembly, and a hand-built case per mode that covers every field. The fixtures are 2 to 7 KB each.Tested
cargo test --release -p xcl --lib bcpack: 17 passed.cargo test --release -p xcl --lib dstorage: 13 passed.cargo test --workspace --no-fail-fast -- --test-threads=4(debug): 665 passed, 0 failed, 40 ignored. SKIPPED:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64).Regression run
scripts/smoke.ps1 -Game <folder> -Seconds 60, release builds, no input (the title stays on its first menu), each run with the machine to itself. The new code is not called by the runtime, so the runs can only show that nothing else moved. The stack sits on #273's base (9ab7d76), so the two builds differ by more than these commits.gpu:is the first video controller Windows lists (#281 / #282 / #285); XCL's log names the RTX 5090 as its backend in both runs.main:
PR:
Not tested
AI use