[PR #982] [CLOSED] RT-BCPACK-DECODER: BC7 in the runtime BCPack decoder, and a lenient policy for the request path #1019

Closed
opened 2026-11-26 20:19:49 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/982
Author: @iFeyz
Created: 11/24/2026
Status: ❌ Closed

Base: main ← Head: feat/bcpack-bc7


📝 Commits (2)

  • a371a73 RT-BCPACK-DECODER: a runtime BCPack decoder, BC1/BC3/BC4/BC5, checked against tools/bcpack.py
  • eba0442 RT-BCPACK-DECODER: BC7, and a lenient policy for the request path

📊 Changes

10 files changed (+3493 additions, -1 deletions)

View changed files

📝 docs/directstorage.md (+11 -1)
📝 runtime/CMakeLists.txt (+15 -0)
➕ runtime/src/bcpack.cpp (+818 -0)
➕ runtime/src/bcpack.h (+89 -0)
➕ runtime/src/bcpack_tables.h (+970 -0)
➕ runtime/test/bcpack_test.cpp (+117 -0)
➕ runtime/test/bcpack_vectors.h (+921 -0)
➕ runtime/test/bcpack_vectors.py (+312 -0)
➕ tests/test_bcpack_header.py (+48 -0)
➕ tools/bcpack_header.py (+192 -0)

📄 Description

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

Depends on: #976 (this branch is built on it; its first commit is #976's, the second is this pull request)

What and why

BC7 is the mode the retail title asks for most among the BCPack requests the DirectStorage shim refuses today
(@DesertGamer's counts, #14 comment 7135719755). This adds it to the runtime decoder of #976, and a second policy the
request path will need.

  • BC7 (runtime/src/bcpack.cpp): _bc7_check then _bc7_rebuild of tools/bcpack.py, in that order, so a chunk
    is refused for the same reason as in Python: a signature outside the table (Status::bad_block), an inferred
    signature or a reference into the built-in history (unconfirmed_history; tools/bcpack_tables_bptc.py knows no
    bit of the BC7 built-in history), then the anchor / p-bit consistency check (bad_block). The rebuild follows the
    structure of @DadaCap's prototype port, which they offered in #14 (comment 7136979744); credited as co-author.
  • Two policies (Options / Result): strict stays the default and is what the vectors hold to Python. Lenient,
    for the request path, decodes what strict refuses for its history, an inferred signature or a consistency check,
    from the zero state where the history is unknown (exactly what Python's provisional mode rebuilds for BC7), and
    counts in Result::guessed every such block and every block that predicts from one. A texture then has a few wrong
    blocks instead of missing, which is DadaCap's choice for the prototype. A signature outside the table is refused
    under both.
  • Tables: tools/bcpack_header.py also writes the BC7 signature configurations, the rank of every lane-15 symbol
    pair, the D3D11 partitions and anchors, and the inferred ranks. It stops if the built-in BC7 history ever gains
    known bits, so they cannot be left out silently.
  • Vectors: 80 BC7 chunks from tests/test_bcpack.py's encoder (one signature per block, now and then an inferred
    one; endpoint and index distances within the chunk or into the built-in history; random endpoints; indices that
    mostly keep the anchor bit representable; a few corrupted streams), each with the strict Python answer and, where
    Python's provisional decode succeeds, its blocks.
  • Docs: docs/directstorage.md.

Not in this PR: BC6H (still unsupported_codec), the user's calibrated BC7 history (strict refuses, lenient takes
the zero state), and the request-path wiring, which DadaCap handed to this claim and which goes on top of
RT-DSTORAGE-DEST-PAGES.

Tested

  • bcpack_test: 120 lane cases and 170 chunk cases (90 BC1/BC3/BC4/BC5, 80 BC7) all agree with the strict Python
    decoder: 95 decoded to the same bytes, the others refused with the same class of error. Lenient decoding gives
    Python's provisional blocks on the 36 chunks where that succeeds, agrees with strict wherever strict decodes (no
    guessed block there), and takes 67 chunks with guessed blocks. MSVC /W4, no warning.
  • tests/test_bcpack_header.py (both generated headers current), tests/test_docs_links.py,
    tests/test_text_write_line_endings.py, tests/test_tool_startup.py, scripts/check_no_game_data.py on every
    changed file. tests/test_tool_stdout_encoding.py lists only tools/native_pso_hashes.py, red on main too.
  • Runtime (Windows 11, MSVC 2022 Build Tools, RelWithDebInfo, full build): ctest 302 of 306 pass, 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).

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.

🔄 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/982 **Author:** [@iFeyz](https://github.com/iFeyz) **Created:** 11/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/bcpack-bc7` --- ### 📝 Commits (2) - [`a371a73`](https://github.com/ubiquitarianism/leonida/commit/a371a739c3aeda38642429d4fed01eb9605689fb) RT-BCPACK-DECODER: a runtime BCPack decoder, BC1/BC3/BC4/BC5, checked against tools/bcpack.py - [`eba0442`](https://github.com/ubiquitarianism/leonida/commit/eba0442ae36307e93e738f47841dad804ceeae9b) RT-BCPACK-DECODER: BC7, and a lenient policy for the request path ### 📊 Changes **10 files changed** (+3493 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `docs/directstorage.md` (+11 -1) 📝 `runtime/CMakeLists.txt` (+15 -0) ➕ `runtime/src/bcpack.cpp` (+818 -0) ➕ `runtime/src/bcpack.h` (+89 -0) ➕ `runtime/src/bcpack_tables.h` (+970 -0) ➕ `runtime/test/bcpack_test.cpp` (+117 -0) ➕ `runtime/test/bcpack_vectors.h` (+921 -0) ➕ `runtime/test/bcpack_vectors.py` (+312 -0) ➕ `tests/test_bcpack_header.py` (+48 -0) ➕ `tools/bcpack_header.py` (+192 -0) </details> ### 📄 Description Claimed in the coordination issue as: RT-BCPACK-DECODER (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7136759575) Depends on: #976 (this branch is built on it; its first commit is #976's, the second is this pull request) ### What and why BC7 is the mode the retail title asks for most among the BCPack requests the DirectStorage shim refuses today (@DesertGamer's counts, #14 comment 7135719755). This adds it to the runtime decoder of #976, and a second policy the request path will need. - **BC7** (`runtime/src/bcpack.cpp`): `_bc7_check` then `_bc7_rebuild` of `tools/bcpack.py`, in that order, so a chunk is refused for the same reason as in Python: a signature outside the table (`Status::bad_block`), an inferred signature or a reference into the built-in history (`unconfirmed_history`; `tools/bcpack_tables_bptc.py` knows no bit of the BC7 built-in history), then the anchor / p-bit consistency check (`bad_block`). The rebuild follows the structure of @DadaCap's prototype port, which they offered in #14 (comment 7136979744); credited as co-author. - **Two policies** (`Options` / `Result`): strict stays the default and is what the vectors hold to Python. Lenient, for the request path, decodes what strict refuses for its history, an inferred signature or a consistency check, from the zero state where the history is unknown (exactly what Python's provisional mode rebuilds for BC7), and counts in `Result::guessed` every such block and every block that predicts from one. A texture then has a few wrong blocks instead of missing, which is DadaCap's choice for the prototype. A signature outside the table is refused under both. - **Tables**: `tools/bcpack_header.py` also writes the BC7 signature configurations, the rank of every lane-15 symbol pair, the D3D11 partitions and anchors, and the inferred ranks. It stops if the built-in BC7 history ever gains known bits, so they cannot be left out silently. - **Vectors**: 80 BC7 chunks from `tests/test_bcpack.py`'s encoder (one signature per block, now and then an inferred one; endpoint and index distances within the chunk or into the built-in history; random endpoints; indices that mostly keep the anchor bit representable; a few corrupted streams), each with the strict Python answer and, where Python's provisional decode succeeds, its blocks. - **Docs**: `docs/directstorage.md`. Not in this PR: BC6H (still `unsupported_codec`), the user's calibrated BC7 history (strict refuses, lenient takes the zero state), and the request-path wiring, which DadaCap handed to this claim and which goes on top of RT-DSTORAGE-DEST-PAGES. ### Tested - `bcpack_test`: 120 lane cases and 170 chunk cases (90 BC1/BC3/BC4/BC5, 80 BC7) all agree with the strict Python decoder: 95 decoded to the same bytes, the others refused with the same class of error. Lenient decoding gives Python's provisional blocks on the 36 chunks where that succeeds, agrees with strict wherever strict decodes (no guessed block there), and takes 67 chunks with guessed blocks. MSVC `/W4`, no warning. - `tests/test_bcpack_header.py` (both generated headers current), `tests/test_docs_links.py`, `tests/test_text_write_line_endings.py`, `tests/test_tool_startup.py`, `scripts/check_no_game_data.py` on every changed file. `tests/test_tool_stdout_encoding.py` lists only `tools/native_pso_hashes.py`, red on `main` too. - Runtime (Windows 11, MSVC 2022 Build Tools, RelWithDebInfo, full build): `ctest` 302 of 306 pass, `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). 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:19:49 +01:00
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#1019
No description provided.