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

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/748
Author: @aslan2142
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: build1390-bvh4-parent-table


📝 Commits (1)

  • 2e4ef18 docs/bvh.md: the BVH4 parent table's start and extent (BUILD-1390)

📊 Changes

3 files changed (+117 additions, -12 deletions)

View changed files

📝 docs/bvh.md (+37 -2)
📝 tests/test_bvh_packing_check.py (+46 -10)
📝 tools/bvh_packing_check.py (+34 -0)

📄 Description

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).


🔄 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/748 **Author:** [@aslan2142](https://github.com/aslan2142) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `build1390-bvh4-parent-table` --- ### 📝 Commits (1) - [`2e4ef18`](https://github.com/ubiquitarianism/leonida/commit/2e4ef18d858c1966a7b345f4e6c2ab306f1c420e) docs/bvh.md: the BVH4 parent table's start and extent (BUILD-1390) ### 📊 Changes **3 files changed** (+117 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `docs/bvh.md` (+37 -2) 📝 `tests/test_bvh_packing_check.py` (+46 -10) 📝 `tools/bvh_packing_check.py` (+34 -0) </details> ### 📄 Description 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). --- <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:02 +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#786
No description provided.