[PR #1715] dstorage: rebuild a BC6H/BC7 request with a few lost blocks instead of failing it (BCPACK-LOST-BLOCK-LIMIT) #1729

Open
opened 2026-11-26 21:18:45 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1715
Author: @kawaii-shakal
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: bcpack-bc7-partial


📝 Commits (2)

  • 7b25106 dstorage: rebuild a BC6H/BC7 request with a few lost blocks instead of failing it (BCPACK-LOST-BLOCK-LIMIT)
  • ca39fa9 Merge upstream main into bcpack-bc7-partial

📊 Changes

5 files changed (+81 additions, -6 deletions)

View changed files

📝 docs/directstorage.md (+11 -1)
📝 runtime/shims/dstorage.cpp (+31 -1)
📝 runtime/src/bcpack.cpp (+9 -3)
📝 runtime/src/bcpack.h (+12 -1)
📝 runtime/test/dstorage_test.cpp (+18 -0)

📄 Description

Claim: BCPACK-LOST-BLOCK-LIMIT, https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7158195672

What and why

In fitted mode, bcpack::decode rebuilds 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. Past max(2, blocks / 1024) lost blocks the whole request fails with E_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.ttpf fail 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 by tools/build_dstorage_history.py on main, each request has exactly one unknown endpoint entry:

request (file offset) blocks lost unknown entry
76014336 1,536 5 endpoint 223
455285504 768 15 endpoint 176

A few approximate 4×4 blocks are far cheaper than a blank request. So:

  • runtime/src/bcpack.{h,cpp}:
    • lost blocks get their own limit, max(2, blocks / lost_divisor), through a new lost_divisor parameter;
    • the default stays 1024, so existing callers are unchanged;
    • an optional Report returns the block and lost counts;
    • inconsistent blocks (anchor-or-pbit) keep the 1-in-1,024 limit;
    • strict mode still refuses any lost block.
  • runtime/shims/dstorage.cpp:
    • passes a divisor of 32 by default; LEONIDA_DSTORAGE_LOST_DIVISOR=N overrides it, and 1024 is the old behaviour. A value that is not a positive number is logged once and 32 is used;
    • logs each approximated request ([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:

    • at the reference limit the request fails as missing-endpoint;
    • with lost_divisor = 1 it decodes as fitted, and the report has every block and more than 2 lost;
    • strict mode still fails.
  • dstorage_test: 481 checks, 0 failures (Windows 11 Pro 26300, MSVC 19.50). gta6rt builds.

  • The two real requests above were decoded with tools/bcpack.py and the locally fitted JSON profile:

    • with the reference limit, both are refused, 5/1,536 and 15/768 blocks;
    • with 1/32, both decode to their full 24,576 and 12,288 bytes.

    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.py is 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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1715 **Author:** [@kawaii-shakal](https://github.com/kawaii-shakal) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `bcpack-bc7-partial` --- ### 📝 Commits (2) - [`7b25106`](https://github.com/ubiquitarianism/leonida/commit/7b251064ade817ade05a1bfe40d160558ac62604) dstorage: rebuild a BC6H/BC7 request with a few lost blocks instead of failing it (BCPACK-LOST-BLOCK-LIMIT) - [`ca39fa9`](https://github.com/ubiquitarianism/leonida/commit/ca39fa9379b4075bebc4bb5400d489bcf2555402) Merge upstream main into bcpack-bc7-partial ### 📊 Changes **5 files changed** (+81 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `docs/directstorage.md` (+11 -1) 📝 `runtime/shims/dstorage.cpp` (+31 -1) 📝 `runtime/src/bcpack.cpp` (+9 -3) 📝 `runtime/src/bcpack.h` (+12 -1) 📝 `runtime/test/dstorage_test.cpp` (+18 -0) </details> ### 📄 Description Claim: BCPACK-LOST-BLOCK-LIMIT, https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7158195672 ### What and why In fitted mode, `bcpack::decode` rebuilds 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. Past `max(2, blocks / 1024)` lost blocks the whole request fails with `E_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.ttpf` fail 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 by `tools/build_dstorage_history.py` on main, each request has exactly one unknown endpoint entry: | request (file offset) | blocks | lost | unknown entry | |---|---|---|---| | 76014336 | 1,536 | 5 | endpoint 223 | | 455285504 | 768 | 15 | endpoint 176 | A few approximate 4×4 blocks are far cheaper than a blank request. So: - `runtime/src/bcpack.{h,cpp}`: - lost blocks get their own limit, `max(2, blocks / lost_divisor)`, through a new `lost_divisor` parameter; - the default stays 1024, so existing callers are unchanged; - an optional `Report` returns the block and lost counts; - inconsistent blocks (`anchor-or-pbit`) keep the 1-in-1,024 limit; - strict mode still refuses any lost block. - `runtime/shims/dstorage.cpp`: - passes a divisor of 32 by default; `LEONIDA_DSTORAGE_LOST_DIVISOR=N` overrides it, and `1024` is the old behaviour. A value that is not a positive number is logged once and 32 is used; - logs each approximated request (`[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: - at the reference limit the request fails as `missing-endpoint`; - with `lost_divisor = 1` it decodes as `fitted`, and the report has every block and more than 2 lost; - strict mode still fails. - `dstorage_test`: 481 checks, 0 failures (Windows 11 Pro 26300, MSVC 19.50). `gta6rt` builds. - The two real requests above were decoded with `tools/bcpack.py` and the locally fitted JSON profile: - with the reference limit, both are refused, 5/1,536 and 15/768 blocks; - with 1/32, both decode to their full 24,576 and 12,288 bytes. 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.py` is 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](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#1729
No description provided.