Repository navigation
build_dstorage_history: fit missing BPTC history slots across multi-level sibling mips (DSTORAGE-MULTILEVEL-MIP-FIT) - #2236
Conversation
…ling mips When a BC6H or BC7 stream still references an unfitted built-in predictor slot after adjacent-mip fitting, pair its mips with the closest raw or zlib mip on the same layer across multi-level mip distances before running the full-stream constraint pass. Existing adjacent-mip, array, and cubemap fits keep precedence.
|
Verified on main a73a57e (Ubuntu 24.04 x86-64, Python 3.13, no GPU, no game data). Merges cleanly. With this PR, python -I tests/test_dstorage_multilevel_fit.py: 3 tests OK. The PR's test file against main's tools: 3 errors, so the new tests fail on main and pass with the change. compileall clean. AI-assisted: yes (Claude Code) |
lixonik
left a comment
There was a problem hiding this comment.
Tested this head locally with synthetic fixtures. In Ubuntu on WSL, all 7 DirectStorage tests passed, including a native bcpack_history_train build and build/resume/repair, the BC7 parent and child cases, and BC6H slot precedence. On Windows, the 6 Python checks passed and the native fitter integration skipped without a C++ compiler on PATH. No findings from these checks. The retail pool coverage numbers were outside this run.
AI-assisted.
Run fit_distant_mips ahead of fit_decoded_neighbors so mixed-codec BC6H and BC7 streams fit directly against lossless raw/zlib mips across multi-level distances before iterative BCPack sibling decoding, eliminating all 10 remaining BC6H stream refusals on 1.0.2.1 (210 -> 226/256 endpoints, 249 -> 251/256 indices) and cutting fit_decoded_neighbors runtime by 46%.
|
Thanks @real-rusher and @lixonik for verifying the synthetic and native fitter checks! Merged
No game files. AI-assisted. |
|
#2236 | head All four baseline cases stopped at AttributeError because main lacks fit_distant_mips. This demonstrates the missing API. The baseline did not reach a value comparison. Pinned main |
Exercise the public history.build(...) pipeline end-to-end across all four synthetic multi-level BPTC mip fitting tests so running the test file against main reaches value assertions (4 AssertionErrors, 0 AttributeErrors) instead of stopping on the missing fit_distant_mips helper.
|
Thanks @sodove for the baseline verification! Merged
No game files. AI-assisted. |
…in multilevel mip fit - Keep secret_entry >= 192 with ref_count <= secret_entry across all synthetic BPTC streams so predictor distances never wrap mod 256 and main leaves unknown slots at zero rather than self-fitting wrapped blocks. - Drive dual-slot BC6H and BC7 chunks (missing slot 240 + pre-populated slot 241 with conflicting pool colors) so extend_missing precedence is genuinely exercised for both codecs. - Assert fitted BC6H endpoint values, zero confirmed-bit masks, and per-block decoded RGBA / unquantized HDR pixels across both parent-downsample and child-upsample streams, and include codec mode in fit_distant_mips wanted keys.
timbot103
left a comment
There was a problem hiding this comment.
I reviewed head b55056766 statically against the PR base and checked the predictor consumers in tools/ and runtime/. No builds, tests, GPU runs, or game-data access. The synthetic cases in tests/test_dstorage_multilevel_fit.py exercise both directions and existing-slot precedence through build() with native vote collection stubbed. I found two fitting errors.
- [MAJOR]
tools/build_dstorage_history.py:257Signed BC6H references reach an unsigned fitter. With a missing mode-14 history row, zero base-endpoint deltas, and a constant signed reference endpoint of −16384, the clamp intools/bcpack_history_calib.py:1401turns the target into zero and the new pass publishes a fitted zero endpoint. Preserve signed targets and evaluate candidates in signed unquantized space. A DXGI 96 regression case should check that the decoded endpoint remains negative. - [MAJOR]
tools/build_dstorage_history.py:151At a four-level downsample, the stride samples only one column phase. A BC7 reference with alternating 0 and 254 columns gives the fitter 0 for every quadrant when the box mean is 127. Average the full footprint and add a patterned reference case at that distance.
AI-assisted.
…ti-level footprint - Thread signed=(format == 96) into Bc6hCalibrator.add_pool_chunk so signed BC6H_SF16 reference targets clamp to [-32768, 32767] instead of [0, 65535] and _eval_w_ops sign-extends and unquantizes candidates in signed space. - Average the full [x0, x1) x [y0, y1) quadrant footprint across multi-level downsamples in _make_multilevel_quads_getter (caching per-4x4-block sums), eliminating single-phase column/row aliasing at 4+ mip levels. - Add DXGI 96 negative-endpoint and 4-level alternating-column BC7 regression tests in tests/test_dstorage_multilevel_fit.py.
|
Thanks @timbot103 for catching both fitting issues! Fixed in
No game files. AI-assisted. |
lixonik
left a comment
There was a problem hiding this comment.
Re-reviewed ab4102efe (tools/bcpack_history_calib.py, tools/build_dstorage_history.py, tests/test_dstorage_multilevel_fit.py).
Both fitting fixes look clean: signed BC6H_SF16 (DXGI 96) endpoints are now clamped and unquantized in signed space, and _make_multilevel_quads_getter averages the full quadrant footprint across multi-level downsamples with new regression coverage for both cases.
Local verification (Windows 11, Python 3):
python -I tests/test_dstorage_multilevel_fit.py -v: 6/6 passed (includingtest_signed_bc6h_sf16_multilevel_fit_preserves_negative_endpointsandtest_bc7_four_level_downsample_averages_full_footprint_across_alternating_columns).python -I scripts/check_no_game_data.py: passed.
AI-assisted (Antigravity, Gemini).
Claimed in the coordination issue as:
DSTORAGE-MULTILEVEL-MIP-FIT(#1608 (comment))What and why
calibrate_from_poolsandfit_slicesintools/build_dstorage_history.pyonly pair BC6H and BC7 chunks with immediatelevel ± 1raw or zlib neighbor mips. When a mixed-codec texture stores lossless raw/zlib atmip[0](<= 1 MiB) and BCPack acrossmips[1..N], packed tail and mid-chain BC7/BC6H mips at|level - ref_level| >= 2are never visited, leaving initial-history slots (eslot = 256 + i - de,islot = 256 + i - di) at0bits and causingruntime/src/bcpack.cpp(missing-endpointat:387) to reject the stream with0x89240030(E_DSTORAGE_DECOMPRESSION_ERROR) when transitive descendants exceedmax(2, blocks / 1024).fit_distant_mipsruns aftercalibrate_from_poolsandfit_slices(preserving full precedence of existing adjacent-mip, array, and cubemap fits viaextend_missing) and scans only BC6H/BC7 chunks whose 256-block prefix still references an unfitted slot (77 / 5,167BC7 chunks across the 57 retail pools), pairing those mips with the closest raw or zlib mip on the same layer across multi-level mip distances (child upsample fordelta_level < 0, parent box average fordelta_level > 0) ahead of the nativebcpack_history_trainfull-stream constraint pass.Across all 57 v1.0.2.1 pools (
5,435BPTC streams evaluated at strictdivisor = 1024, counts only):4,228 / 6,144->4,336 / 6,144(+108); index fields8,160 / 8,192.210 / 256->226 / 256(+16); indices249 / 256->251 / 256(+2).0 / 268(100%pass).60 / 5,167->18 / 5,167(-70%), resolving25 / 25mixed-codec BC7 streams (including both world-load0x89240030missing-endpointrequests, each decoding with0unknown blocks and0consistency violations atdivisor = 1024). The remaining 18 streams belong to pure-BCPack textures with no raw or zlib mips.Tested
python -m compileall -q make_game.py tools tests(exit 0)python -I tests/test_dstorage_multilevel_fit.py -v(3/3synthetic multi-level BC7 downsample, BC7 upsample, and BC6H + slot-precedence tests pass; fails withoutfit_distant_mips)python -I -m unittest discover -s tests -p "test_dstorage_*.py" -v(7/7pass, includingbcpack_history_trainintegration)python -I tests/test_bcpack_history_calib.py -v(19/19pass)python -I tests/test_text_write_line_endings.py&python -I -m unittest discover -s tests -p "test_docs_*.py"(55/55pass)python -I scripts/check_no_game_data.py tools/build_dstorage_history.py docs/directstorage.md tests/test_dstorage_multilevel_fit.py(exit 0)bcpack_history_trainrefinement on Windows 11 (fit_distant_mipspass: ~88 s)GPUs tested: n/a (CPU calibration tool and unit tests; verified on Windows 11 x64, Ryzen 9 5950X / RTX 3090 host)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.