Repository navigation
dstorage: rebuild a BC6H/BC7 request with a few lost blocks instead of failing it (BCPACK-LOST-BLOCK-LIMIT) - #1715
kawaii-shakal wants to merge 3 commits into
Conversation
…f failing it (BCPACK-LOST-BLOCK-LIMIT) A fitted BPTC request whose predictor chains reach a history entry the local profile does not know was refused once more than max(2, blocks/1024) blocks were affected, leaving the whole destination untouched. On the 1.0.2.1 package two BC7 requests fail this way at every boot, with one unknown endpoint entry each (5 of 1,536 and 15 of 768 blocks). bcpack::decode gets a separate limit for these lost blocks (lost_divisor, 1024 by default, as before) and an optional Report with the block and lost counts. DirectStorage passes 32 (LEONIDA_DSTORAGE_LOST_DIVISOR) and logs each approximated request. Inconsistent blocks keep the 1-in-1,024 limit; strict mode refuses any lost block. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent verification of head Windows 11 Pro, RTX 4070 SUPER (NVIDIA 621.01), MSVC 19.52.37029, RelWithDebInfo.
Diff read: the shim's default divisor is 32 (the header's default stays the reference 1024), as No game files used. AI-assisted (Claude Code). |
|
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 |
Claim: BCPACK-LOST-BLOCK-LIMIT, #1608 (comment)
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