OLD-7640: restore old upstream PR 7640 - docs/bvh.md: the BVH4 parent table's start and extent (BUILD-1390) #748

Merged
aslan2142 merged 1 commit from upstream-pr/748 into main 2026-11-25 22:29:16 +00:00
aslan2142 commented 2026-11-24 13:26:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-24T13:26:13Z.


Claimed in the coordination issue as: OLD-7640 https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7132777216

Restoration of my original pull request, old upstream PR 7640 in ItsNotRexed/Leonida, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Rebased onto main at 2d73c242fd. The cherry-pick applied cleanly. Changes in the rebase:

  • The worked example from the §3.1 sample header is gone from the new text.
  • The unit test that used those header values now uses synthetic ones.

#690 and #626 also touch docs/bvh.md, but both merge cleanly with this branch.

What and why

  • docs/bvh.md §3.1 replaced the console BVH4 parent table's start and size with an "Open:" line. This pull request puts the rules there instead:
    • Start: offsetToParents = 0x40 - (((offsetToNodes - offsetToElements) / 16) & ~127). The leaf entries' whole 128-byte blocks fall below the header end, so the first box node's entry lands in [0x40, 0xc0).
    • Extent: one entry per box unit (one for BOX16, two for BOX32) from the first box entry. offsetToElements is the end of the last entry, rounded up to 128.
    • Not shipped: the bytes from the header end to offsetToElements are all zero.
    • Header count: totalSizeIn64BNodes + 1 also counts the level table's units, which have no entry. That is why an end computed from the header alone missed on about 13,400 streams.
  • Measured on all 272,874 streams of the two bvh4 packs. Each rule holds on every stream it applies to. The doc's table has counts only.
  • tools/bvh_packing_check.py checks three new rules: parent_offset, parent_area_nonzero and parent_extent. It also gets two helpers, parent_table and elements_after_parents.
  • tests/test_bvh_packing_check.py:
    • The synthetic fixture moves to the console layout for its four leaves and three BOX16 units.
    • Six tests are added for the helpers and the three new failures.
  • The section ends with a hypothesis: whether updatable or top-level structures lay the table out the same way. Every measured stream is a non-updatable BLAS, so this is not measured.

Tested

  • python -I tests/test_bvh_packing_check.py:
    • Before (main with only this branch's test file): the 31 existing tests pass and the 6 new ones fail (3 failures, 3 errors).
    • After (this branch): all 37 pass.
  • tests/test_docs_*.py (12 files): all pass.
  • python -m compileall -q tools tests: ok.
  • git diff --check: clean.
  • python -I scripts/check_no_game_data.py on the three changed files: clean.
  • The corpus counts come from the original pull request's run over the user's own copy. They were not re-measured for this rebase.

GPUs tested: n/a

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. (n/a: no translator change)

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

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5473020804 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/748). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-24T13:26:13Z. --- Claimed in the coordination issue as: OLD-7640 https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7132777216 Restoration of my original pull request, old upstream PR 7640 in `ItsNotRexed/Leonida`, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Rebased onto main at 2d73c242fddfe26d57b52ee150704e6c3b23cff4. The cherry-pick applied cleanly. Changes in the rebase: - The worked example from the §3.1 sample header is gone from the new text. - The unit test that used those header values now uses synthetic ones. #690 and #626 also touch `docs/bvh.md`, but both merge cleanly with this branch. ### What and why - `docs/bvh.md` §3.1 replaced the console BVH4 parent table's start and size with an "**Open:**" line. This pull request puts the rules there instead: - *Start:* `offsetToParents = 0x40 - (((offsetToNodes - offsetToElements) / 16) & ~127)`. The leaf entries' whole 128-byte blocks fall below the header end, so the first box node's entry lands in `[0x40, 0xc0)`. - *Extent:* one entry per box unit (one for BOX16, two for BOX32) from the first box entry. `offsetToElements` is the end of the last entry, rounded up to 128. - *Not shipped:* the bytes from the header end to `offsetToElements` are all zero. - *Header count:* `totalSizeIn64BNodes + 1` also counts the level table's units, which have no entry. That is why an end computed from the header alone missed on about 13,400 streams. - Measured on all 272,874 streams of the two `bvh4` packs. Each rule holds on every stream it applies to. The doc's table has counts only. - `tools/bvh_packing_check.py` checks three new rules: `parent_offset`, `parent_area_nonzero` and `parent_extent`. It also gets two helpers, `parent_table` and `elements_after_parents`. - `tests/test_bvh_packing_check.py`: - The synthetic fixture moves to the console layout for its four leaves and three BOX16 units. - Six tests are added for the helpers and the three new failures. - The section ends with a hypothesis: whether updatable or top-level structures lay the table out the same way. Every measured stream is a non-updatable BLAS, so this is not measured. ### Tested - `python -I tests/test_bvh_packing_check.py`: - Before (main with only this branch's test file): the 31 existing tests pass and the 6 new ones fail (3 failures, 3 errors). - After (this branch): all 37 pass. - `tests/test_docs_*.py` (12 files): all pass. - `python -m compileall -q tools tests`: ok. - `git diff --check`: clean. - `python -I scripts/check_no_game_data.py` on the three changed files: clean. - The corpus counts come from the original pull request's run over the user's own copy. They were not re-measured for this rebase. GPUs tested: n/a 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. (n/a: no translator change) AI-assisted (Claude Code, Claude Opus 5.5).
abnalstlll-byte commented 2026-11-24 13:30:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T13:30:34Z.

Review: APPROVED


Audited and verified. Clean-room compliant.

  • Measures and documents BVH parent table layout and zero-padded region before offsetToElements in docs/bvh.md.
  • Implements parent_table and elements_after_parents in tools/bvh_packing_check.py with full test coverage in tests/test_bvh_packing_check.py.
<!-- greyfinch-sync:ubiquitarianism/leonida:review:6040062749 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/748#pullrequestreview-6040062749). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T13:30:34Z. **Review:** APPROVED --- Audited and verified. Clean-room compliant. - Measures and documents BVH parent table layout and zero-padded region before offsetToElements in docs/bvh.md. - Implements parent_table and elements_after_parents in tools/bvh_packing_check.py with full test coverage in tests/test_bvh_packing_check.py.
abnalstlll-byte commented 2026-11-24 13:30:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T13:30:48Z.

Review: APPROVED


LGTM. Thoroughly verified reverse-engineering of the BVH4 parent table layout (offsetToParents and offsetToElements calculations) across 272,874 streams in docs/bvh.md, validated in ools/bvh_packing_check.py with synthetic tests in ests/test_bvh_packing_check.py.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6040066566 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/748#pullrequestreview-6040066566). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T13:30:48Z. **Review:** APPROVED --- LGTM. Thoroughly verified reverse-engineering of the BVH4 parent table layout (offsetToParents and offsetToElements calculations) across 272,874 streams in docs/bvh.md, validated in ools/bvh_packing_check.py with synthetic tests in ests/test_bvh_packing_check.py.
aslan2142 commented 2026-11-25 22:29:19 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-25T22:29:19Z.


Merged: docs/bvh.md: the BVH4 parent table's start and extent.

  • Changed since review: Nothing. It merges cleanly with main, and no review point is open.
  • Tested: tests/test_bvh_packing_check.py passes on main + this head (Linux, CPython 3.14).
  • Checked on main 45129e6bc + 2e4ef18d8: the semantic suite passes (492 files, 6,315 tests, 0 files failed); test_bvh_packing_check pass; the 15 docs and writer tests pass; check_no_game_data.py is clean on the 3 changed files.

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7176423497 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/748#issuecomment-7176423497). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-25T22:29:19Z. --- Merged: `docs/bvh.md`: the BVH4 parent table's start and extent. - **Changed since review:** Nothing. It merges cleanly with `main`, and no review point is open. - **Tested:** `tests/test_bvh_packing_check.py` passes on `main` + this head (Linux, CPython 3.14). - **Checked on `main` `45129e6bc` + `2e4ef18d8`:** the semantic suite passes (492 files, 6,315 tests, 0 files failed); `test_bvh_packing_check` pass; the 15 docs and writer tests pass; `check_no_game_data.py` is clean on the 3 changed files. AI-assisted (Claude Code, Claude Opus 5.5).
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!748
No description provided.