RT-BCPACK-DECODER: the user's calibrated BC1/BC3/BC4/BC5 history in the sidecar and the request path #1103

Closed
iFeyz wants to merge 7 commits from upstream-pr/1103 into main
iFeyz commented 2026-11-24 18:29:10 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by iFeyz on 2026-11-24T18:29:10Z.


Claimed in the coordination issue as: RT-BCPACK-DECODER (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7136759575)

Depends on: #976, #982, #991, #1020, #1044 (this branch is built on them; its last commit is this pull request)

What and why

#1044 brought the user's calibrated BC6H/BC7 history to the runtime decoder and left BC1/BC3/BC4/BC5 out. Those
matter as much: the repository's tables confirm 252 BC1 entries but none for BC3, 2 for BC4 and 5 for BC5, so
without a calibration nearly every BC3/BC4/BC5 block that predicts from the built-in history is decoded from zeros
on the request path (and the retail title asks for mode 5, issue #14 comment 7135719755).

  • tools/bcpack_history_sidecar.py: when the history JSON has a bc1 / bc3 / bc4 / bc5 section (read by
    load_bc_history, as tools/bcpack.py --history reads it), a BC15HIS1 section follows the BC6H/BC7 tables: per
    mode a given byte, the section's replace byte and its 256 confirmed entries (int16, -1 where not confirmed).
    71,192 bytes in all. A history without those sections still gives the 60,936-byte file of #984's profile, byte
    for byte
    ; only a file with BC1-5 history is longer, which #984's profile reader may not take.
  • runtime/src/bcpack.{h,cpp}: History::replace, and read_history_sidecar reads the optional section. The
    merge is _resolve_bc_history's: an entry given there wins over the built-in one, and with replace the built-in
    table is not read. Provisional entries are not written, as for the built-in tables (strict decoding takes confirmed
    history only).
  • runtime/shims/dstorage.cpp: the request path reads files up to 128 KiB (it stopped at 70,000 bytes, which
    would have cut the longer sidecar and ignored it), and its log line says whether BC1-5 history came with it.
  • Docs: docs/directstorage.md; the "not done yet" entry for this is gone.

Tested

  • bcpack_test: the synthetic history now has BC1-5 sections (BC1 replacing its table, the one with many confirmed
    entries; BC4 and BC5 merged, with confirmed and provisional entries; BC3 not given), and 100 BC1-5 chunks that read
    the built-in history often, each with tools/bcpack.py's strict answer for that same history. All agree; 10 decode
    only with the history, and BC1's replace decides the result of 9 (checked by decoding them with the flag off).
    The sidecar without its BC1-5 section (#984's size) still reads. The earlier cases are unchanged: the BC1-5 part
    has a random generator of its own, so the regenerated header only adds.
  • dstorage_test: 355 checks, 0 failures. Its BC1 chunk is now one whose blocks are the same with the calibrated
    history, since that history replaces BC1's built-in table for the whole process; a failing check now names its case.
  • tests/test_bcpack_history_sidecar.py (6): the BC15HIS1 offsets, flags and a provisional entry left out, and the
    unchanged size without BC1-5 sections.
  • Runtime (Windows 11, MSVC 2022 Build Tools, RelWithDebInfo, full build): ctest 302 of 306 pass, dstorage and bcpack included. The 4 failures are the same as on main here (d3d12_clear, d3d12_execute_indirect_validation, d3d12_texture_tiles, d3d12_pipeline_library_host, all already reported in #14).
  • tests/test_bcpack_header.py, runtime/test/bcpack_vectors.py --check, tests/test_docs_links.py,
    tests/test_tool_startup.py, tests/test_text_write_line_endings.py, scripts/check_no_game_data.py on every
    changed file.

GPUs tested: n/a (CPU only)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5478011543 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1103). Originally posted by [iFeyz](https://github.com/iFeyz) on 2026-11-24T18:29:10Z. --- Claimed in the coordination issue as: RT-BCPACK-DECODER (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7136759575) Depends on: #976, #982, #991, #1020, #1044 (this branch is built on them; its last commit is this pull request) ### What and why #1044 brought the user's calibrated BC6H/BC7 history to the runtime decoder and left BC1/BC3/BC4/BC5 out. Those matter as much: the repository's tables confirm 252 BC1 entries but **none for BC3, 2 for BC4 and 5 for BC5**, so without a calibration nearly every BC3/BC4/BC5 block that predicts from the built-in history is decoded from zeros on the request path (and the retail title asks for mode 5, issue #14 comment 7135719755). - **`tools/bcpack_history_sidecar.py`**: when the history JSON has a `bc1` / `bc3` / `bc4` / `bc5` section (read by `load_bc_history`, as `tools/bcpack.py --history` reads it), a `BC15HIS1` section follows the BC6H/BC7 tables: per mode a given byte, the section's `replace` byte and its 256 confirmed entries (int16, -1 where not confirmed). 71,192 bytes in all. **A history without those sections still gives the 60,936-byte file of #984's profile, byte for byte**; only a file with BC1-5 history is longer, which #984's profile reader may not take. - **`runtime/src/bcpack.{h,cpp}`**: `History::replace`, and `read_history_sidecar` reads the optional section. The merge is `_resolve_bc_history`'s: an entry given there wins over the built-in one, and with `replace` the built-in table is not read. Provisional entries are not written, as for the built-in tables (strict decoding takes confirmed history only). - **`runtime/shims/dstorage.cpp`**: the request path reads files up to 128 KiB (it stopped at 70,000 bytes, which would have cut the longer sidecar and ignored it), and its log line says whether BC1-5 history came with it. - **Docs**: `docs/directstorage.md`; the "not done yet" entry for this is gone. ### Tested - `bcpack_test`: the synthetic history now has BC1-5 sections (BC1 replacing its table, the one with many confirmed entries; BC4 and BC5 merged, with confirmed and provisional entries; BC3 not given), and 100 BC1-5 chunks that read the built-in history often, each with `tools/bcpack.py`'s strict answer for that same history. All agree; 10 decode only with the history, and BC1's `replace` decides the result of 9 (checked by decoding them with the flag off). The sidecar without its BC1-5 section (#984's size) still reads. The earlier cases are unchanged: the BC1-5 part has a random generator of its own, so the regenerated header only adds. - `dstorage_test`: 355 checks, 0 failures. Its BC1 chunk is now one whose blocks are the same with the calibrated history, since that history replaces BC1's built-in table for the whole process; a failing check now names its case. - `tests/test_bcpack_history_sidecar.py` (6): the BC15HIS1 offsets, flags and a provisional entry left out, and the unchanged size without BC1-5 sections. - Runtime (Windows 11, MSVC 2022 Build Tools, RelWithDebInfo, full build): `ctest` 302 of 306 pass, `dstorage` and `bcpack` included. The 4 failures are the same as on `main` here (`d3d12_clear`, `d3d12_execute_indirect_validation`, `d3d12_texture_tiles`, `d3d12_pipeline_library_host`, all already reported in #14). - `tests/test_bcpack_header.py`, `runtime/test/bcpack_vectors.py --check`, `tests/test_docs_links.py`, `tests/test_tool_startup.py`, `tests/test_text_write_line_endings.py`, `scripts/check_no_game_data.py` on every changed file. GPUs tested: n/a (CPU only) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed.
abnalstlll-byte commented 2026-11-24 18:39:50 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T18:39:50Z.

Review: APPROVED


Audited and verified. Implements BC1-BC5 calibrated history sidecar serialization in ools/bcpack_history_sidecar.py and runtime integration in DirectStorage, allowing local calibration tables to be consumed cleanly without embedding proprietary data. Documentation in docs/directstorage.md updated. Clean-room compliant. Approved.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6045201843 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1103#pullrequestreview-6045201843). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T18:39:50Z. **Review:** APPROVED --- Audited and verified. Implements BC1-BC5 calibrated history sidecar serialization in ools/bcpack_history_sidecar.py and runtime integration in DirectStorage, allowing local calibration tables to be consumed cleanly without embedding proprietary data. Documentation in docs/directstorage.md updated. Clean-room compliant. Approved.
abnalstlll-byte commented 2026-11-24 18:52:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T18:52:51Z.

Review: APPROVED


Clean-Room Audit — PR #1103 (RT-BCPACK-DECODER History Sidecar)

Comprehensive addition extending tools/bcpack_history_sidecar.py (BC15HIS1 section), runtime/src/bcpack.cpp, and runtime/shims/dstorage.cpp with up-to-128 KiB calibrated BC1/BC3/BC4/BC5 history tables and synthetic test vectors (bcpack_vectors.h, dstorage_test.cpp). Clean-room verified (0 game data).

Verdict: APPROVED

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6045382045 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1103#pullrequestreview-6045382045). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T18:52:51Z. **Review:** APPROVED --- ### Clean-Room Audit — PR #1103 (`RT-BCPACK-DECODER` History Sidecar) Comprehensive addition extending `tools/bcpack_history_sidecar.py` (`BC15HIS1` section), `runtime/src/bcpack.cpp`, and `runtime/shims/dstorage.cpp` with up-to-128 KiB calibrated BC1/BC3/BC4/BC5 history tables and synthetic test vectors (`bcpack_vectors.h`, `dstorage_test.cpp`). Clean-room verified (0 game data). **Verdict: APPROVED**
Deedlyy commented 2026-11-24 20:17:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Deedlyy on 2026-11-24T20:17:37Z.


Recommendation: [WAIT]

Reasoning: Brings calibrated BC1/BC3/BC4/BC5 history into the runtime BCPack decoder and DirectStorage request path: +5,788 lines including a 1.1k-line decoder and large generated tables/vectors. It is stacked on five unmerged PRs (#976, #982, #991, #1020, #1044), so the diff can't be judged or merged on its own. There is no independent review beyond a boilerplate comment. Land the dependencies first, rebase so only this PR's commit shows, and get at least one independent decode verification before merging. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main.

Impact level: 7/10

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7143318094 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1103#issuecomment-7143318094). Originally posted by [Deedlyy](https://github.com/Deedlyy) on 2026-11-24T20:17:37Z. --- **Recommendation:** [WAIT] **Reasoning:** Brings calibrated BC1/BC3/BC4/BC5 history into the runtime BCPack decoder and DirectStorage request path: +5,788 lines including a 1.1k-line decoder and large generated tables/vectors. It is stacked on five unmerged PRs (#976, #982, #991, #1020, #1044), so the diff can't be judged or merged on its own. There is no independent review beyond a boilerplate comment. Land the dependencies first, rebase so only this PR's commit shows, and get at least one independent decode verification before merging. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with `main`. **Impact level:** 7/10
MoonEyes commented 2026-11-28 02:50:22 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T02:50:22Z.


Hi @iFeyz, thanks for this pull request. It currently conflicts with main (conflicting file(s): docs/directstorage.md, runtime/CMakeLists.txt, runtime/shims/dstorage.cpp, runtime/src/bcpack.cpp, runtime/src/bcpack.h, runtime/test/dstorage_test.cpp), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232626666 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1103#issuecomment-7232626666). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T02:50:22Z. --- Hi @iFeyz, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `docs/directstorage.md`, `runtime/CMakeLists.txt`, `runtime/shims/dstorage.cpp`, `runtime/src/bcpack.cpp`, `runtime/src/bcpack.h`, `runtime/test/dstorage_test.cpp`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
DadaCap commented 2026-11-28 10:33:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-28T10:33:58Z.


Thanks for the contribution! This PR was reviewed by the maintainers and is being closed as part of a large batch of closures.

Reason: stale and conflicting.

If this looks like a mistake, mention @DadaCap here at any time and it will be looked at again.

AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7237979160 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1103#issuecomment-7237979160). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-28T10:33:58Z. --- Thanks for the contribution! This PR was reviewed by the maintainers and is being closed as part of a large batch of closures. Reason: stale and conflicting. If this looks like a mistake, mention @DadaCap here at any time and it will be looked at again. AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!1103
No description provided.