DirectStorage: BCPack BC1 requests are unpacked, tables from bcpack-rs #273
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!273
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/273/head"
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?
@Kalmarv on GitHub · 2026-11-23 22:16 UTC · original
Kalmarv:feat/bcpack-bc1→main· +1794 −29 · 45 files · 2 commits · closed without mergingStacked on #208. With this PR, DirectStorage unpacks BCPack BC1 requests, alone or after zlib, instead of refusing them. The BC1 blocks are rebuilt from #208's lanes with two tables of constants that no stream carries; XCL takes the estimates bcpack-rs made of them. BC3–BC7 requests are refused and counted as on
main.This is the second half of #208's earlier form (
a7ffb2f), which a tester ran on a retail title (below). One commit,ce8839b, on #208's42c90e0, which is onmain9ce2070; GitHub shows both commits until #208 is merged. Both were rebased from5f12643and34c0ee5on9ab7d76, without conflicts and without a changed line (git range-diff: both commits=).What is in it
hle/bcpack/bc1.rs: BC1 blocks from the 12 lanes. A back-reference for the endpoints, six zigzag differences, and four 2×2 selector quadrants through a codebook. It follows the BC1 sections of the format notes of bcpack-decoder and bcpack-rs, both MIT. No code was taken from either. The file's header names both, with URL and licence.hle/bcpack/bc1_fitted.rs: the two tables, which no specification publishes. One is the 255 endpoint sets a stream starts with; the other is the order of the 256 quadrants.python scripts/gen_bcpack_bc1_tables.py <bcpack-rs>/data/bc1_window.json <bcpack-rs>/data/bc1_quad_table.json(bcpack-rs at c51ec52; the script is in this PR). The file carries bcpack-rs's MIT notice.hle/bcpack/mod.rs:decode(mode, bytes, len)(lanes, then blocks), and the errorslane 1andunknown history.hle/dstorage.rs: a BC1 request runs the BCPack stage after zlib, or alone.E_DECOMPRESSIONand writes nothing, as a refusal does.XCL_DSTORAGE_BCPACK_FILLnow applies to the refused modes only.report.rs:report.jsongetsdstorage.bcpack_unpackedper mode, withrequests,destination_bytes(bytes of blocks rebuilt) andfailed.tests/data/bcpack/*.bc1: the blocks of #208's BC1 fixtures, from the same independent encoder.THIRD_PARTY.md:bc1_fitted.rs, generated by the script above).Tested
cargo test --workspace -- --test-threads=4once8839b: 692 passed, 0 failed, 41 ignored, with #208's commit under it (thexcllibrary: 652 passed, 21 ignored). SKIPPED GPU tests:gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware, both "no wave64".cargo test -p xcl --lib bcpackonce8839b: 11 passed, 0 failed.cargo build -p xclgives one warning, inhle/xgameruntime/mod.rs, which this PR does not touch.a7ffb2f, merged ontomain60565c4plus #215. "Without" is the same branch before the merge.report.json'sdstorage.bcpack_refusedcompared.a7ffb2f.git diff 6da33fa a7ffb2fandgit diff 9ab7d76 5f12643differ only in the provenance comments oflanes.rsandbc1.rs, which now carry the sources' URLs; no code line differs.git diff 9ce2070 ce8839b, the stack as rebased, has the same changed lines asgit diff 9ab7d76 5f12643.mainhas moved since, so it is the same change but not the same build.More from that run:
BCPack BC1: first request unpacked (39541 to 65536 bytes), and one BC1 stream was not unpacked (BCPack BC1 streams not unpacked so far: 1).XCL_RUN_SECONDSended the run.cargo test --release -p xcl --lib bcpack: 11 passed.Retail run, by @vibryxcx (https://github.com/ivall/xcl/pull/273#issuecomment-7119213477): RX 6800 (RDNA2, driver 32.0.21045.5002), Core i5-10600KF, Windows 11 26200, Rust 1.100.0, release.
main508a0c7, this PR's earlier head5f12643(then onmain9ab7d76), and5f12643merged into508a0c7(no conflicts).cargo test --workspace -- --test-threads=4on5f12643: 659 passed, 0 failed, 40 ignored, no SKIPPED GPU tests.mainagainst the merge: BC1 6 refused (393,216 bytes) to 6 unpacked, 0 failed; BC5 100 and BC7 20 refused in both; failed DirectStorage requests 126 to 120; 817 and 736 frames; peak commit 15,612 and 15,593 MB; no crash or device removal. One run of each.scripts/smoke.ps1:main1562 frames,5f12643on its own 30 frames (1 present per 2 s), the merge 1544 frames. So the slowdown came from the older base, and that head failed the 80 % frames rule againstmain. This is why the PR is rebased; the rebased head has not been run on that card.Retail run, by @0klavair (https://github.com/ivall/xcl/pull/273#issuecomment-7119709460): RTX 5060 8 GB (driver 621.01), Ryzen 9 5950X, 32 GB RAM, Windows 11 23H2 (22631), rustc 1.94.1, release.
main508a0c7against508a0c7with5f12643merged in, into world loading, with warm caches. Both builds also carry a one-line launcher fix of theirs, outside DirectStorage.main; with the PR none refused, 1,913 unpacked (142.6 MB) and 1 failed. The failure isBC1 block 0 refers to the unknown history entry 4, the entry listed as not known below.+0x23cf683) after about 5 min 25 s, the stop of #505 / #232, and show nothing past the loading screen. So the PR did not change where or when the run ends.What the tests show, all on synthetic data:
bc1_fixtures_decode_to_their_blocks: #208's independent BC1 fixtures decode to their blocks.bc1_block_rebuild: one block by hand, every field.fitted_bc1_tables_are_well_formed: every quadrant appears once, the ranges hold, and one block goes through the shipped tables.bcpack_bc1_requests_are_unpacked_alone_and_after_zlib: seven requests through a memory queue.IntermediateSize.IntermediateSize, a cut stream and a wrong block count; these three fail and write nothing.main's BCPack refusal tests now use BC3 / BC7 where they used BC1.With the fitted tables, five BC1 streams (8,926 blocks) give byte-identical blocks here and in bcpack-rs's CLI.
Mutations of the earlier form, each failing at least one of these tests:
execute;IntermediateSizenot compared.#208 lists its other six.
Known to be approximate or assumed:
The BC1 tables are estimates. Per bcpack-rs:
A wrong history entry gives a slightly wrong colour in the blocks that refer to it and in the ones chained to them. bcpack-rs reports a median 35.4 dB against the next mip level, where 37.9 dB is the ceiling of that measure.
BC1 lane 1 is 0 in every stream the notes describe. A stream where it is not is refused (
lane 1); bcpack-rs ignores it instead.One request is taken to be one stream that unpacks to
DestinationSizebytes.IntermediateSize0 with zlib + BCPack is accepted; zlib may then yield any size up to the destination's. The GDK documents the field as the size of the stream BCPack reads. What a console does with 0 was not tested.The blocks are written in stream order. Requests with a swizzle mode are still refused.
Overlaps:
hle/dstorage.rs, so the two conflict there. It is opt-in (XCL_DSTORAGE_BCPACK_BC1=1) and takes the decoder from the bcpack-rs crate, a git dependency pinned to c51ec52 (MIT). It handles BC1 alone and zlib → BC1, into virtual or physical-page destinations. It rejects malformed streams, unknown lane-1 symbols and unfitted entries. It also changes the window title (present.rs,pso_async.rs), and its run on a title saw no BCPack request. This PR differs as follows:THIRD_PARTY.md, and takes only bcpack-rs's two generated tables;executeinhle/dstorage.rs: a destination page-array entry that is 0 at enqueue is read again at the request's turn. It is merged and is in9ce2070; the rebase onto it had no conflict. Its change is in the physical-page write; this PR's is in the stages before it (zlib, then BCPack). A BC1 request into physical pages now goes through #289's late read too; that combination is not tested.5f12643, so it needs a rebase ontoce8839b. Other open PRs that touchhle/dstorage.rs(#487, #501, #509, #549, #561) merge withce8839bwithout conflicts (git merge-tree).HANDOFF.mdsays "BCPack (and other console formats) are refused". With this PR that holds for every mode but BC1.docs/specs/2026-11-20-xcl-design.mdnames BCPack as having "no public decoder (risk)". Neither is edited here.scripts/smoke.ps1, 60 s, no input:main9ab7d761505 frames, peak commit 14902 MB; this PR5f126431503 frames, 14883 MB; exit 0x0, 0 device removals and 0 crashes in both.main85bdf21against it with5f12643merged: BC1 refusals 114 (3,383,296 bytes) to none,BCPack BC1: first request unpackedin the log; failed DirectStorage requests 220 to 26. BC5 and BC7 requests are still refused.cargo test --workspace -- --test-threads=4on5f12643: 659 passed, 0 failed, 40 ignored, no SKIPPED GPU tests (RDNA4).main9ab7d76and this head: 1505 frames onmain, no crash or device removal on either (https://github.com/ivall/xcl/pull/273#issuecomment-7117408211).Regression run
Our own runs, one after the other on the machine under Tested (RTX 5070 Ti), release builds, no uncommitted changes.
main:
PR:
Not tested
scripts/smoke.ps1, was ofa7ffb2f, and is not a substitute for it.physical_page_destinations_and_sourcescovers.AI use
@Kalmarv on GitHub · 2026-11-23 22:39 UTC · original
@Cattn your run of
a7ffb2f(BC1 refusals 1,492 → 0) is in the description; this PR is the same code. For the merge rules it now needs a regression run: if you can runscripts/smoke.ps1 -Game <your title folder>twice, once built frommain(9ab7d76) and once from this PR's head (5f12643), please paste bothxcl-smokeblocks here. I'll copy them into the description under Regression run, with your name and hardware. We have no title on our machine.🤖 Claude Opus 5.5
mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175@ExMoha on GitHub · 2026-11-23 23:49 UTC · original
Test report for #273 at
5f12643. Written by Claude Code (Claude Sonnet 5.5), which ran the commands; the game ran on my machine.Setup: AMD Radeon RX 9070 (16 GB; XCL's report.json: "AMD Radeon RX 9070 (16191 MiB VRAM)"), Ryzen 7 7800X3D, 31.2 GB RAM, Windows 11 Pro 10.0.26300, DXC 1.8.2502.11, rustc 1.98.1 (48a229cea 2026-09-01), release build for the runs, debug for the tests. Retail title 1.0.2.1,
XCL_NETWORK=0.Regression run (
scripts/smoke.ps1, 60 s, same title, back to back, clean checkouts, no input). Firstmain9ab7d76(this PR's base), then this PR's head. Thegpu:line is the script's first video controller (the CPU's integrated GPU, see #281 / #285); the runs used the RX 9070.main9ab7d76:5f12643:Frames 1503 vs 1505 (99.9 %), peak commit 14883 vs 14902 MB, no device removal, no crash. An earlier pair of runs with inputs gave 1194 (
main) and 1211 frames, peak commit 16287 and 16276 MB, no crash and no device removal either; the PR's last three windows there were0 0 60, which the no-input pair does not repeat.BC1 effect, scripted menus (
XCL_PRESS_A_AT=14,17,21 XCL_ACTIVITY=1, one run each, both stopped by an external kill-switch at 90 % system RAM, no crash, no device removal): currentmain85bdf21against the same with5f12643merged in locally (merge commit not published):BCPack BC1: first request unpacked (39541 to 65536 bytes). BC5 (107) and BC7 (20 to 34) are still refused.Tests on
5f12643(cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4): 659 passed, 0 failed, 40 ignored; no SKIPPED GPU tests. The 11 bcpack tests passed.@Kalmarv on GitHub · 2026-11-24 00:00 UTC · original
@ExMoha thank you: the first run where this decoder is actually called. Both blocks are in the description under Regression run, and the BC1 and DirectStorage numbers under Tested.
🤖 Claude Opus 5.5
@Kalmarv on GitHub · 2026-11-24 00:16 UTC · original
@ivall, for the provenance question you raised on #340: the facts on this PR's two BC1 tables, with no argument about whether they are acceptable. Sources: bcpack-rs at
c51ec52and its research branches, bcpack-decoder atd2cb8f3.1. How bcpack-rs made them
Input: the texture files of one retail title, read from the author's own copy: per texture the BCPack BC1 chunk of mip 0 and the plain BC1 mip 1 (
sem-indicesbranch,docs/findings/sem-indices.md:27: 3,276 textures, 20.3 M blocks for the selector fit).data/bc1_window.json(endpoint history): per slot six numbers, searched so that the decoded blocks' colour segment lies closest to the mip-1 texels over every texture using the slot (sem-endpointsbranch,docs/findings/sem-endpoints.md:37-41). Its source line: "fitted against mip-1 consistency on retail texture pools (endpoint-window fit); values only".data/bc1_quad_table.json(symbol to 2x2 selector pattern): a permutation of the 256 patterns, the cheapest assignment against the same target (sem-indices.md:115-126).The files hold the constants and, per entry, summary numbers of the fit (textures and blocks behind it, rms, frequency share, whether two half-fits agree). No texels, blocks or names.
tools/import_tables.py:16: "Only the fitted values and summary confidence numbers are copied; no per-texture data and no game bytes."bc1_fitted.rstakes only the six numbers per slot and the pattern per symbol.They are estimates computed from game textures, not exact readings: "fitted: constants estimated from retail data; mostly right, some entries uncertain or missing" (
docs/BCPACK_SPEC.md:9). Counted from the JSON: 254 of 256 slots set; a slot rests on 2 to 1,500 textures (median 22; 11 slots on fewer than 5); half-fits differ in 17 slots and 8 patterns.On content: "Entries look like a trained codebook of common endpoint pairs [...] An exact search of the store's decompressed plain data for the slot-121/254/82 colour pairs found nothing systematic." (
sem-endpoints.md:128-130)bcpack-rs's own notes also say "Nothing derived from game data is committed" (
sem-indices.md:3-4), while these fitted tables are committed in itsdata/; we report both statements as they stand.2. The same for every stream and title?
Every stream of the title measured: yes by both projects' reports. "a fixed 256-entry table of endpoint fields, the same for every chunk. The table is not in the stream." (
BCPACK_SPEC.md:122); "a static table of 255 endpoint pairs [...], identical for every chunk" (bcpack-decoderdocs/SPEC.md:230).Every title: nobody has shown it. Each project reports one title; neither compares a second. That the tables belong to the codec is an inference: a stream's bytes are all taken by its 12 lanes, and a DirectStorage request names only the mode.
From us: nothing. The fixtures of #208 and of this PR are synthetic, built with made-up tables.
Our own wording is firmer than this evidence:
bc1_fitted.rs's header and the commit message call the tables "constants of the codec, not game content". The sources support that for one title. If the PR goes ahead in any form, we reword it to say exactly that.3. Another route to the same constants
silicon-rans(MIT) is the rANS lane only. The related patent has "nothing BC-specific" by bcpack-rs's notes (patentbranch,docs/findings/patent.md:159; we did not read the patent). The public DirectStorage documentation, as far as we have read it, gives stage order and mode numbers.learn-tablesderives them from your own BCPack data." (README 101-105)4. What #208 needs
34c0ee5refers to them. Its only tables are the 16 rANS models, generated from Microsoft'smdu_minirans.v(MIT) byscripts/gen_bcpack_tables.py.THIRD_PARTY.mdsay so.What we can do
main, without a table and not called; it merges cleanly ontoa6f5f7a(git merge-tree). It can be decided alone.bc1_fitted.rs:bc1.rstakes the tables as a parameter and its tests use made-up ones, so the rebuild stays and BC1 requests are refused as onmain. Say which.Not checked: bcpack-rs's fits were not rerun (that needs game files; we have none), so both projects' statements are quoted, not verified. Whether they measured the same title.
🤖 Claude Fable 5.2
@vibryxcx on GitHub · 2026-11-24 01:33 UTC · original
Test report: Intel before Ice Lake + AMD RDNA2, a hardware pair not in the list above, on the same retail title.
Tested
cargo clean --release -p xclbefore each build.cargo test --workspace -- --test-threads=4on5f12643: 659 passed, 0 failed, 40 ignored, no SKIPPED GPU tests.main508a0c7; this PR's head5f12643; and7f2d1b3, a local merge of5f12643into508a0c7(no conflicts).BC1 on a retail run.
XCL_PRESS_AT=20:A,45:A,55:A,65:A,75:A,85:A,95:A,105:A,115:A,scripts/smoke.ps1 -Game <folder> -Seconds 150(the presses go through the intro to the menus). Fromreport.jsonand the log:main508a0c75f12643merged into508a0c7The log has
BCPack BC1: first request unpacked (39541 to 65536 bytes)and no BC1 warning. Both runs end at 3 – 4 presents per 2 s in the menus. A 75 s run with only20:A(intro video) makes no BCPack request on this title, so it does not reach the change.This PR's head on its own is far behind
main. The standard comparison,XCL_PRESS_AT=20:A,-Seconds 75:main508a0c71562 frames,5f1264330 frames (1 present per 2 s),5f12643merged into508a0c71544 frames. So the slowdown comes from the older base, not from the BC1 change, but the head as it is would not pass the 80 % frames rule against currentmainuntil it is rebased. Blocks as printed:main508a0c7:5f12643:5f12643merged into508a0c7(local merge commit7f2d1b3):Not tested
main's 817 (90 %); I did not repeat it, so I cannot say whether that is variance.AI use
@0klavair on GitHub · 2026-11-24 02:03 UTC · original
Retail run of #273 on NVIDIA, into world loading, with a run of
mainfor comparison.Setup
main508a0c7with #273 (5f12643, on #208) merged in. Without:main508a0c7. Both also carry a one-line launcher fix so they start from a network share (the game folder is on a NAS); it does not touch DirectStorage.XCL_NETWORK=0,XCL_PRESS_A_AT=45,50,60, warm caches (same data folder, learned coherent window), killed at 720 s / 420 s if still running.Results (
report.json→dstorage)main)+0x23cf683+0x23cf683BC1 block 0 refers to the unknown history entry 4 (packed=5157, dst=8192).GPU Loc Sigstop of #505 / #232. So on this machine #273 moves BC1 from refused to unpacked without changing where or when the run ends; something else is in the way (as in Cattn's run above).Not tested
cargo testsuite on the merged tree (only onmain+ the launcher fix).Test report written with Claude Code (Claude Opus 5.5) from runs on the hardware above.
@Kalmarv on GitHub · 2026-11-24 02:08 UTC · original
Thanks, @0klavair. The one failure is the history entry the tables don't have. The description lists it under "Known to be approximate or assumed": "One history entry (slot 4) was never seen and is not known. A block that refers to it fails the request." Your message is that case: symbol 7 in the first block refers to entry 4. A synthetic stream built the same way gives exactly that error with the shipped tables, and the neighbouring entries 3 and 5 unpack. The request fails with
E_DECOMPRESSIONand writes nothing, rather than delivering guessed colours. That's 1 request in 1,914 in your run, close to the 1 in 5,162 chunks that bcpack-rs's own scan found touching an unfitted slot.🤖 Claude Fable 5.2
@Kalmarv on GitHub · 2026-11-24 03:16 UTC · original
Plan for the other BCPack modes, so nobody duplicates it. No code yet. @NiiRoZz (#340), @Prime1997 (#438), @Ahmet-Dedeler (bcpack-rs): say if any of this is already yours.
What's unclaimed.
8b86a5edocuments the lane-to-block rebuild and 205 of the 285 control codes. Nobody has, from data, the 255-entry dictionary (without it, bcpack-rs rebuilds 2.4 % of blocks) or the 80 codes of modes 0 and 2. #438 covers one mode-6 configuration with zero or in-chunk history.How. We fit the missing constants from our own copy of a retail title. We read it in place, and nothing from it leaves the machine except the fitted constants. Each value is voted on by byte equality: a packed mip-0 block against the plain block that must equal it (a plain duplicate of the same mip, or the next mip where both are one flat colour). An entry needs a clear majority. The rest stay unknown, and a request that needs one is refused before anything is written. Tables from other decoders whose licence doesn't fit XCL's GPL-2.0-only are not used or compared against.
Checks.
PRs, each under ~400 lines.
8b86a5e's documentation (MIT), credited.Provenance. These are constants fitted from retail data, the same open question as #273's BC1 tables. Each PR will say so, and how each value was obtained, so it can be decided once for all of them.
🤖 Claude Opus 5.5
@gabrielsteglich on GitHub · 2026-11-24 04:21 UTC · original
Hi @Kalmarv, I’m adding a test-only regression for the BC1 physical-page destination path in this PR using the existing synthetic fixtures. The test will check byte-for-byte writes across noncontiguous pages and verify that a truncated stream returns
E_DECOMPRESSIONwith the destination untouched. I’ll run the XCL suite on an RTX 3090. Would you prefer to fold the test into this PR or take it as a follow-up?@Kalmarv on GitHub · 2026-11-24 04:23 UTC · original
@gabrielsteglich, a follow-up PR, please: #273 is already at the size the maintainers asked for, and its smoke runs are on the current head. Base it on #273's branch (or on main once #273 merges) and say so in its description; I'll answer review points on the #273 side if the test finds anything.
🤖 Claude Opus 5.5
@mastrr9 on GitHub · 2026-11-24 04:45 UTC · original
Provenance check + NVIDIA RTX 5080 Windows test run on
ce8839b938e06767379be0cc1f84f366a5609bb3:Review
THIRD_PARTY.mdprovenance (silicon-ransMIT,bcpack-rsMIT tables with generator scriptscripts/gen_bcpack_bc1_tables.py) is clean and GPL-2.0-only compatible, and the DirectStorage integration test covers standalone BC1, zlib+BC1, intermediate-size mismatch, damaged streams, and non-overwrite bounds.Tested
rustc 1.100.0(MSVC), debug build.cargo build --workspace && cargo test --workspace -- --test-threads=4: 692 passed, 0 failed, 41 ignored.bc1_fixtures_decode_to_their_blocks,bc1_block_rebuild,fitted_bc1_tables_are_well_formed,bcpack_bc1_requests_are_unpacked_alone_and_after_zlib(plus the 4 stacked #208 tests): all 8 passed.SKIPPEDGPU tests (2, wave32-only adapter):gpu_geometry_wave32_prefix_count_over_a_mask: no wave64,gpu_wave32_program_in_wave64_hardware: no wave64.Not tested
scripts/smoke.ps1run (test suite only); AMD / Intel GPUs.AI use: review and test run orchestrated with Antigravity (Gemini 4 Neon) on the hardware listed above.
@Prime1997 on GitHub · 2026-11-24 04:51 UTC · original
Sorry, just saw all these notifications. If anything is done to update the code I have done, my tool will know and close the request.
Just tag me if you see anything @Kalmarv that is mine that you want to work on.
@ivall on GitHub · 2026-11-24 10:39 UTC · original
#905 is merged (
67a3735): DirectStorage now unpacks BCPack BC1, BC3, BC4, BC5, BC6H and BC7 with the format's exact tables, so this PR is superseded. Thank you for the work and for collecting the retail runs – they showed where the BC1 wall was. The merged decoder decodes the BC1 blocks bit for bit with the reference (no estimated tables, no unknown history entry); your #208 fixtures test its lane stage.Pull request closed