dstorage: rebuild a BC6H/BC7 request with a few lost blocks instead of failing it (BCPACK-LOST-BLOCK-LIMIT) #1715
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1715"
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?
Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-25T09:20:52Z.
Claim: BCPACK-LOST-BLOCK-LIMIT, https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7158195672
What and why
In fitted mode,
bcpack::decoderebuilds a BC6H/BC7 block from the local profile's history entry. Some blocks have a predictor chain that starts at an entry the profile does not know. They are rebuilt from the bits the profile has, and are counted as lost. Pastmax(2, blocks / 1024)lost blocks the whole request fails withE_DSTORAGE_DECOMPRESSION_ERROR(missing-endpoint/missing-index). The destination is then never written, so the texture region stays blank.On the 1.0.2.1 package, two BC7 requests in
data/ttdb/props/octa_imposters.ttpffail this way at every boot (DadaCap counted 6 of 6 runs in #1537; I see the same two in every boot of mine). With a profile rebuilt bytools/build_dstorage_history.pyon main, each request has exactly one unknown endpoint entry:A few approximate 4×4 blocks are far cheaper than a blank request. So:
runtime/src/bcpack.{h,cpp}:max(2, blocks / lost_divisor), through a newlost_divisorparameter;Reportreturns the block and lost counts;anchor-or-pbit) keep the 1-in-1,024 limit;runtime/shims/dstorage.cpp:LEONIDA_DSTORAGE_LOST_DIVISOR=Noverrides it, and1024is the old behaviour. A value that is not a positive number is logged once and 32 is used;[rt] dstorage: BC7 request approximated N of M blocks ...), the first eight and then at powers of two.docs/directstorage.md: the rule, the switch, and these two requests.Test
runtime/test/dstorage_test.cpp, for both BC6H and BC7, using the test profile with its slot 255 made unknown:missing-endpoint;lost_divisor = 1it decodes asfitted, and the report has every block and more than 2 lost;dstorage_test: 481 checks, 0 failures (Windows 11 Pro 26300, MSVC 19.50).gta6rtbuilds.The two real requests above were decoded with
tools/bcpack.pyand the locally fitted JSON profile:I did not boot the retail title with this branch, so the runtime log line on those two requests is not yet seen.
scripts/check_no_game_data.pyis clean.Why 32: it covers these requests (15 of 768 is 1 in 51), and it still refuses a request that has lost a real share of its blocks. It is a judgement, not a measurement. The switch is there to compare against.
AI-assisted: yes (Claude Code, Claude Opus 5.5).
🤖 Generated with Claude Code
Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-25T15:31:07Z.
Independent verification of head
7b251064ade817ade05a1bfe40d160558ac62604, merged onto currentmain(71a769d7d) without conflicts.Windows 11 Pro, RTX 4070 SUPER (NVIDIA 621.01), MSVC 19.52.37029, RelWithDebInfo.
dstorage(ctest, which holds the new BC6H/BC7 lost-block checks): pass, "506 checks, 0 failures".bcpack::decodewith the two new parameters, so they do not compile againstmain; there is no red run to compare with.Diff read: the shim's default divisor is 32 (the header's default stays the reference 1024), as
docs/directstorage.mdsays; inconsistent blocks keep the 1-in-1,024 limit; strict mode still refuses. No problem found.No game files used. AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-25T17:56:18Z.
Reviewed
7b25106: dstorage_test itself is MSVC/Windows-only and was not built here. Instead I compiled runtime/src/bcpack.cpp standalone on both this branch and main with the generated tables and vectors, replicated every check the PR adds to test_extended (all pass; the same checks on main behave as this PR's default does), ran tests/test_bcpack.py (20 ok), and probed the policy with a crafted 1536-block BC7 stream whose first five blocks chain to an unknown history entry: main and the default divisor 1024 refuse it as missing-endpoint (the Python reference refuses the same stream with "5/1536 blocks from unknown built-in history entries"), while the DirectStorage divisor 32 rebuilds it fitted and reports 5 lost. The boundary is exactly lost <= max(2, blocks/divisor) (307 admits 5, 308 refuses), strict mode still refuses, and inconsistent blocks keep the old limit. No findings; the package-level counts (5 of 1,536 / 15 of 768) are unverified here without game data.AI-assisted review.
Recommendation: Merge
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T17:57:31Z.
Red/green: On main dstorage_test does not compile because bcpack::Report and the new decode parameters are missing, and main refuses a BC6H/BC7 request with a few lost blocks, and with the PR ctest -R "^dstorage$" passes, including the lost-block rebuild checks.
Independent tester (OreoFR, RTX 4070, Windows 11): PR head merged with the other PRs of its batch on main
c1ecf04ed, full ctest run (485 tests, tests that launch the game excluded): no new failure compared with main.Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T21:53:14Z.
Verified by OreoFR
c1ecf04ed+ PR head0f71e7670; green run in a merge package of 15 PRs, no new ctest failure vs mainctest -R ^dstorage$AI-assisted (Claude Code, Claude Opus 5.5).