[PR #140] tools/native: unified zero-dependency Rust workspace for 8 hot accelerators (13x-228x, Python fallback) #192

Open
opened 2026-11-26 20:17:05 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/140
Author: @Andretuta
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: old-pr/9872


📝 Commits (1)

  • 20e7ccd tools/native: one Cargo workspace for eight Rust accelerators

📊 Changes

60 files changed (+13510 additions, -11 deletions)

View changed files

📝 .github/workflows/ci.yml (+32 -0)
➕ tests/test_anim_clips_native.py (+250 -0)
➕ tests/test_bc7_native.py (+143 -0)
➕ tests/test_bvh_native.py (+282 -0)
➕ tests/test_glb_native.py (+379 -0)
➕ tests/test_meshlet_native.py (+305 -0)
➕ tests/test_native_workspace.py (+89 -0)
➕ tests/test_rdna2_decode_native.py (+402 -0)
➕ tests/test_spirv_asm_native.py (+305 -0)
➕ tests/test_spirv_opt_native.py (+541 -0)
➕ tools/_anim_clips_native.py (+117 -0)
📝 tools/anim_clips.py (+17 -7)
➕ tools/anim_clips_native/.gitignore (+1 -0)
➕ tools/anim_clips_native/Cargo.toml (+9 -0)
➕ tools/anim_clips_native/README.md (+25 -0)
➕ tools/anim_clips_native/src/lib.rs (+664 -0)
➕ tools/bc7_native/.gitignore (+1 -0)
➕ tools/bc7_native/Cargo.toml (+11 -0)
➕ tools/bc7_native/README.md (+30 -0)
➕ tools/bc7_native/src/lib.rs (+377 -0)

...and 40 more files

📄 Description

Carried over from old PR 9872 by TG0000 in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9872, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
TG0000: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Unified zero-dependency Rust Cargo workspace (tools/native/Cargo.toml) consolidating our 8 highest-impact optional native accelerators (replacing closed PRs #8447, #8638, #8654, #8751, #8761, #8808, #8936, and #9645) into one single workspace build, one CI step, and one global LEONIDA_NATIVE=0 kill-switch (plus per-module LEONIDA_*_NATIVE=0), with automatic byte-identical pure-Python fallback everywhere.

Included Crates (0 external dependencies, Rust 1.85+, catch_unwind FFI guards, try_reserve_exact)

Crate Accelerates Measured Speedup Real-Corpus / Fuzz Parity
rdna2_decode_native tools/rdna2_decode.py 50.7x real (32.33 s -> 0.64 s on 2,000 real shaders) 2,000/2,000 real shaders + 634k fuzzed streams (0 mismatches)
spirv_asm_native tools/spirv_asm.py 13.8x real (24.59 s -> 1.78 s on 500 modules / 408 MiB) 500/500 real modules + 6.7M fuzzed cases (0 mismatches)
spirv_opt_native tools/spirv_opt.py 13.8x real (102.35 s -> 7.41 s on 500 modules) 500/500 real modules + 6.5k random modules (0 mismatches)
bvh_native tools/bvh_rehydrate.py 86x real (0.344 s -> 0.004 s) / 130–228x synthetic 8/8 real console BLAS + 8,192 random trees (0 mismatches)
bc7_native tools/dds_png.py 136x (5.9 s -> 43 ms on 2048x2048 BC7) 1.31M random blocks byte-identical
meshlet_native tools/meshlet_page.py 94.5x (25.2 s -> 0.27 s on 2.03M tris) 2,400 random pages bit-identical + shared-block sparse fix
anim_clips_native tools/anim_clips.py 15–17x end-to-end / 77–85x kernel 2,400 random sequences bit-identical
glb_native tools/glb_writer.py 16–30x pack_primitive / 10–18x build_glb 17.68M hypot + 1.37M mesh calls (0 mismatches)

(Real-corpus checks were read-only on personal 1.0.2.1 copies — counts and timings only, no game data.)

Unified Build & Fallback

  • Build all 8 crates in one command: cargo build --release --workspace --locked --offline --manifest-path tools/native/Cargo.toml
  • Every loader checks tools/native/target/release/ first, then per-crate target/release/, and falls back transparently to pure Python if unbuilt, LEONIDA_NATIVE=0, or LEONIDA_<MODULE>_NATIVE=0.
  • Includes one unified CI step in .github/workflows/ci.yml (--locked --offline with -D warnings) and tests/test_native_workspace.py.

Testing (Windows 11, Ryzen 9 5900X, Rust 1.100.0, Python 3.12.10, CPU only)

  • RUSTFLAGS="-D warnings" cargo build --release --workspace --locked --offline --manifest-path tools/native/Cargo.toml: 0 warnings.
  • RUSTFLAGS="-D warnings" cargo test --release --workspace --locked --offline --manifest-path tools/native/Cargo.toml: 45/45 passed.
  • All 8 Python native parity suites pass with 0 skipped (102/102 tests OK) + test_native_workspace.py (4/4 OK) + all 9 pure-Python reference suites pass.
  • compileall, make_game.py --help, scripts/check_no_game_data.py, and git diff --check all clean. No game data used.

AI-assisted (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/140 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `old-pr/9872` --- ### 📝 Commits (1) - [`20e7ccd`](https://github.com/ubiquitarianism/leonida/commit/20e7ccd0f59e0b477b84a7001fee09eb921c9deb) tools/native: one Cargo workspace for eight Rust accelerators ### 📊 Changes **60 files changed** (+13510 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/ci.yml` (+32 -0) ➕ `tests/test_anim_clips_native.py` (+250 -0) ➕ `tests/test_bc7_native.py` (+143 -0) ➕ `tests/test_bvh_native.py` (+282 -0) ➕ `tests/test_glb_native.py` (+379 -0) ➕ `tests/test_meshlet_native.py` (+305 -0) ➕ `tests/test_native_workspace.py` (+89 -0) ➕ `tests/test_rdna2_decode_native.py` (+402 -0) ➕ `tests/test_spirv_asm_native.py` (+305 -0) ➕ `tests/test_spirv_opt_native.py` (+541 -0) ➕ `tools/_anim_clips_native.py` (+117 -0) 📝 `tools/anim_clips.py` (+17 -7) ➕ `tools/anim_clips_native/.gitignore` (+1 -0) ➕ `tools/anim_clips_native/Cargo.toml` (+9 -0) ➕ `tools/anim_clips_native/README.md` (+25 -0) ➕ `tools/anim_clips_native/src/lib.rs` (+664 -0) ➕ `tools/bc7_native/.gitignore` (+1 -0) ➕ `tools/bc7_native/Cargo.toml` (+11 -0) ➕ `tools/bc7_native/README.md` (+30 -0) ➕ `tools/bc7_native/src/lib.rs` (+377 -0) _...and 40 more files_ </details> ### 📄 Description > Carried over from **old PR 9872** by `TG0000` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9872`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `TG0000`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): Unified zero-dependency Rust Cargo workspace (`tools/native/Cargo.toml`) consolidating our 8 highest-impact optional native accelerators (replacing closed PRs `#8447`, `#8638`, `#8654`, `#8751`, `#8761`, `#8808`, `#8936`, and `#9645`) into **one single workspace build**, **one CI step**, and **one global `LEONIDA_NATIVE=0` kill-switch** (plus per-module `LEONIDA_*_NATIVE=0`), with automatic byte-identical pure-Python fallback everywhere. ### Included Crates (0 external dependencies, Rust 1.85+, `catch_unwind` FFI guards, `try_reserve_exact`) | Crate | Accelerates | Measured Speedup | Real-Corpus / Fuzz Parity | |---|---|---|---| | `rdna2_decode_native` | `tools/rdna2_decode.py` | **50.7x** real (`32.33 s -> 0.64 s` on 2,000 real shaders) | **2,000/2,000** real shaders + 634k fuzzed streams (0 mismatches) | | `spirv_asm_native` | `tools/spirv_asm.py` | **13.8x** real (`24.59 s -> 1.78 s` on 500 modules / 408 MiB) | **500/500** real modules + 6.7M fuzzed cases (0 mismatches) | | `spirv_opt_native` | `tools/spirv_opt.py` | **13.8x** real (`102.35 s -> 7.41 s` on 500 modules) | **500/500** real modules + 6.5k random modules (0 mismatches) | | `bvh_native` | `tools/bvh_rehydrate.py` | **86x** real (`0.344 s -> 0.004 s`) / **130–228x** synthetic | **8/8** real console BLAS + 8,192 random trees (0 mismatches) | | `bc7_native` | `tools/dds_png.py` | **136x** (`5.9 s -> 43 ms` on 2048x2048 BC7) | 1.31M random blocks byte-identical | | `meshlet_native` | `tools/meshlet_page.py` | **94.5x** (`25.2 s -> 0.27 s` on 2.03M tris) | 2,400 random pages bit-identical + shared-block sparse fix | | `anim_clips_native` | `tools/anim_clips.py` | **15–17x** end-to-end / **77–85x** kernel | 2,400 random sequences bit-identical | | `glb_native` | `tools/glb_writer.py` | **16–30x** `pack_primitive` / **10–18x** `build_glb` | 17.68M `hypot` + 1.37M mesh calls (0 mismatches) | *(Real-corpus checks were read-only on personal 1.0.2.1 copies — counts and timings only, no game data.)* ### Unified Build & Fallback - Build all 8 crates in one command: `cargo build --release --workspace --locked --offline --manifest-path tools/native/Cargo.toml` - Every loader checks `tools/native/target/release/` first, then per-crate `target/release/`, and falls back transparently to pure Python if unbuilt, `LEONIDA_NATIVE=0`, or `LEONIDA_<MODULE>_NATIVE=0`. - Includes one unified CI step in `.github/workflows/ci.yml` (`--locked --offline` with `-D warnings`) and `tests/test_native_workspace.py`. ### Testing (Windows 11, Ryzen 9 5900X, Rust 1.100.0, Python 3.12.10, CPU only) - `RUSTFLAGS="-D warnings" cargo build --release --workspace --locked --offline --manifest-path tools/native/Cargo.toml`: **0 warnings**. - `RUSTFLAGS="-D warnings" cargo test --release --workspace --locked --offline --manifest-path tools/native/Cargo.toml`: **45/45 passed**. - All 8 Python native parity suites pass with **0 skipped** (`102/102` tests OK) + `test_native_workspace.py` (`4/4` OK) + all 9 pure-Python reference suites pass. - `compileall`, `make_game.py --help`, `scripts/check_no_game_data.py`, and `git diff --check` all clean. No game data used. AI-assisted (Claude Opus 5.5). --- <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#192
No description provided.