textures: add optional Rust BCPack support to the batch exporter #816

Merged
wish131400 merged 2 commits from upstream-pr/822 into main 2026-11-23 09:25:20 +00:00
wish131400 commented 2026-11-23 08:59:33 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by wish131400 on 2026-11-23T08:59:33Z.


Refs #811. Uses the optional Rust kernels from Leonida #5116 at ff5f36b or later.

The existing TTPF-to-DDS batch command can use the Rust kernels from the selected Leonida checkout. The default remains strict and also works with the earlier Python reference checkout. --require-rust checks the Release library and expected kernels before pool open. Chunk-level fallback still applies. --calibration PROFILE.json explicitly retries strict decode failures with a local version-1 profile and records successful retries as mode: fitted. DDS publication remains atomic. The current manifest records the hash of the published bytes and omits the file and hash for a failed entry.

Verification

Windows 10 x64 build 19045, CPython 3.14.2, Cargo 1.98.1, NumPy 2.5.2 for the fitted path. CPU only. The tests use generated input.

cargo build --release --locked --offline --manifest-path "$Leonida/tools/bcpack_calibration/Cargo.toml" --target-dir "$Leonida/tools/bcpack_calibration/target"
$env:TTPF_TOOLS_DIR = "$Leonida/tools"
python -B tests/ttpf_batch_export_check.py -q
python -B tests/docs_links_check.py
python -B tools/ttpf_batch_export.py "$Fixtures/timing.ttpf" --threads 8 --tools-path "$Leonida/tools" --require-rust -o "$Out/native-1"
python -B tools/ttpf_batch_export.py "$Fixtures/timing.ttpf" --threads 8 --tools-path "$Reference/tools" -o "$Out/reference-1"
  • The batch suite passed 11/11 against both b0befb4 and ff5f36b. The docs link check passed. Requiring Rust with the reference checkout exited 2 before creating the output directory.
  • The generated 4×4 BC1 and mode-6 BC7 controls matched expected blocks, independently decoded pixels and DDS hashes. The truncated BC7 stream failed without a file or hash while its BC1 sibling exported.
  • A generated multi-mip BC1 fixture requiring external history was refused in strict mode. Supplying a synthetic profile produced one fitted DDS of 2,876 bytes with byte-for-byte parity against NumPy reconstruction.
  • With eight workers, 1,024 generated BC1 and mode-6 BC7 textures and fresh directories on the same NTFS volume, the times below cover pool open through manifest publication. Each run produced 1,024 strict DDS files totaling 4,345,856 bytes. Every DDS and every manifest entry matched across the two configurations.
Trial Reference tools b0befb4 Rust enabled ff5f36b
1 15.269 s 1.983 s
2 15.503 s 2.021 s
3 15.510 s 2.064 s
Median 15.503 s 2.021 s

The measured path is the batch exporter, including hashing and file publication. The previously reported standalone Rust benchmark includes the fixture generator and runs a different exporter. The timings here use generated streams eligible for the strict BC7 shortcut. The upstream coverage check observed 0/5,167 whole-chunk acceptances on its BC7 corpus.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6555788424 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/822). Originally posted by [wish131400](https://github.com/wish131400) on 2026-11-23T08:59:33Z. --- Refs #811. Uses the optional Rust kernels from [Leonida #5116](https://github.com/ItsNotRexed/Leonida/pull/5116) at `ff5f36b` or later. The existing TTPF-to-DDS batch command can use the Rust kernels from the selected Leonida checkout. The default remains strict and also works with the earlier Python reference checkout. `--require-rust` checks the Release library and expected kernels before pool open. Chunk-level fallback still applies. `--calibration PROFILE.json` explicitly retries strict decode failures with a local version-1 profile and records successful retries as `mode: fitted`. DDS publication remains atomic. The current manifest records the hash of the published bytes and omits the file and hash for a failed entry. ### Verification Windows 10 x64 build 19045, CPython 3.14.2, Cargo 1.98.1, NumPy 2.5.2 for the fitted path. CPU only. The tests use generated input. ```powershell cargo build --release --locked --offline --manifest-path "$Leonida/tools/bcpack_calibration/Cargo.toml" --target-dir "$Leonida/tools/bcpack_calibration/target" $env:TTPF_TOOLS_DIR = "$Leonida/tools" python -B tests/ttpf_batch_export_check.py -q python -B tests/docs_links_check.py python -B tools/ttpf_batch_export.py "$Fixtures/timing.ttpf" --threads 8 --tools-path "$Leonida/tools" --require-rust -o "$Out/native-1" python -B tools/ttpf_batch_export.py "$Fixtures/timing.ttpf" --threads 8 --tools-path "$Reference/tools" -o "$Out/reference-1" ``` - The batch suite passed 11/11 against both `b0befb4` and `ff5f36b`. The docs link check passed. Requiring Rust with the reference checkout exited 2 before creating the output directory. - The generated 4×4 BC1 and mode-6 BC7 controls matched expected blocks, independently decoded pixels and DDS hashes. The truncated BC7 stream failed without a file or hash while its BC1 sibling exported. - A generated multi-mip BC1 fixture requiring external history was refused in strict mode. Supplying a synthetic profile produced one fitted DDS of 2,876 bytes with byte-for-byte parity against NumPy reconstruction. - With eight workers, 1,024 generated BC1 and mode-6 BC7 textures and fresh directories on the same NTFS volume, the times below cover pool open through manifest publication. Each run produced 1,024 strict DDS files totaling 4,345,856 bytes. Every DDS and every manifest entry matched across the two configurations. | Trial | Reference tools `b0befb4` | Rust enabled `ff5f36b` | | --- | ---: | ---: | | 1 | 15.269 s | 1.983 s | | 2 | 15.503 s | 2.021 s | | 3 | 15.510 s | 2.064 s | | Median | **15.503 s** | **2.021 s** | The measured path is the batch exporter, including hashing and file publication. The previously reported [standalone Rust benchmark](https://gist.github.com/wish131400/41e2c73bccf284bc7f58214ab788b665) includes the fixture generator and runs a different exporter. The timings here use generated streams eligible for the strict BC7 shortcut. The [upstream coverage check](https://github.com/ItsNotRexed/Leonida/pull/5116#issuecomment-7095547634) observed 0/5,167 whole-chunk acceptances on its BC7 corpus. AI-assisted.
upstream-sync closed this pull request 2026-11-24 06:44:56 +00:00
R0Y00 commented 2026-11-24 06:49:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T09:13:50Z.


I built the optional Rust library offline from Leonida ff5f36b, then ran the 11 batch-export checks against both the pinned Python reference checkout and the new checkout. The --require-rust CLI also exported both source-built control textures in strict mode. I pushed 10fa426 with the exact checkout and build commands so the Rust example does not silently reuse the older reference directory. Waiting for the new CI run.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7096380446 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/822#issuecomment-7096380446). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T09:13:50Z. --- I built the optional Rust library offline from Leonida `ff5f36b`, then ran the 11 batch-export checks against both the pinned Python reference checkout and the new checkout. The `--require-rust` CLI also exported both source-built control textures in strict mode. I pushed `10fa426` with the exact checkout and build commands so the Rust example does not silently reuse the older reference directory. Waiting for the new CI run.
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
R0Y00/Xbox2Windows!816
No description provided.