tools: add batch DDS exporter for TTPF texture pools #792
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/798"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-23T05:18:18Z.
Add
tools/ttpf_batch_export.pyto batch export BCPack/ETPF textures from RDS5 pools to Windows DDS with structured manifest generation and SHA-256 recording, addressing the workflow requested in #458.Change
tools/ttpf_batch_export.py:.ttpf(RDS5) texture pool and an index range (via--indicesor--start/--count).--allow-provisionalis explicitly specified..ddsfile on export failure or rejection, ensuring the currentmanifest.jsonremains the sole authority for published outputs.--threads) with configurable tools resolution via--tools-pathor environment variablesTTPF_TOOLS_DIR/BCPACK_REFERENCE_TOOLS.tests/ttpf_batch_export_check.pywith 8 unit and integration tests:test_real_exporter_dds_and_pixel_verificationgenerating a minimal valid 12,544-byte RDS5/ETPF pool (BC1 and BC7 entries), exporting via the real pinned exporter, and independently verifying decoded RGBA8 pixels against expected references andbcpack_mode6_vector.RGBA.ttpf_batch_exportinCMakeLists.txt(CTest),.github/workflows/windows.yml,AGENTS.md, anddocs/non-windows-hosts.md.docs/experiments.md.Verification and Evidence
1. Default test run (external tools absent)
2. Actual run of optional real-backend fixture with pinned external tools
Tested using the pinned Leonida reference exporter at revision
b0befb4b88d6640354940117448ea19d52507584:Observed result:
3. CMake / CTest dev preset and repository checks
Evidence and follow-up
Refs #458. Provides the in-repository batch exporter tool requested by @wish131400 with strict export as default, atomic publish, manifest as authority, stale file cleanup on reused directories, and synthetic integration tests with independent pixel decoding. The real-backend check on real local game pools remains tracked under #458.
Checklist
AI-assisted: yes
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T05:23:56Z.
The tests currently replace the DDS backend with a stub, so they verify batch orchestration. For #458, please add one generated or revision-pinned public input that the real, pinned exporter turns into DDS, then check expected decoded pixels independently. Keep strict as the default and require an explicit opt-in for fitted output. Right now
--strict-onlycan also accept a file merely because it exists, including one generated from another pool or in provisional mode. Reuse an output only when its pool/range, tool revision, mode and digest match, or disable that cache in the first slice. Please write each new export to a temporary path and publish it only on successful completion. Keep #458 open until the real-backend check is in place.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T05:49:45Z.
Thanks for the revisions. I verified that strict is now the default, fitted export needs an explicit flag, and the filename-only cache is gone.
38e7c8ealso adds a synthetic BC1/BC7 integration fixture with decoded pixel references. Please record the exact pinned external tools revision, command, and result for an actual run of that optional fixture so a default skip does not stand in for evidence. In a reused output directory, a failed strict run can leave last run’s DDS on disk. Please make the current manifest the authority for this case and test the fitted-then-strict sequence against the same directory.Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-23T05:34:13Z.
Thanks for the thorough review! Updated in commit
c555eeb:allow_provisional=False), requiring explicit--allow-provisionalopt-in to retry with fitted history calibration..tmp_*) and atomically published (os.replace) to the target destination only upon verified completion, with automatic cleanup on rejection or error.Refs #458so #458 remains open for the real-backend check follow-up.tests/ttpf_batch_export_check.pyto cover strict-by-default behavior, provisional opt-in, atomic publish and failure cleanup. All 7 tests and CTest pass.Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-23T05:44:50Z.
Added the real-backend verification test in commit
38e7c8e:make_synthetic_ttpf_archive): Generates a valid 12,544-byte RDS5/ETPF pool containing two test entries (entry 0: 4x4 BC1 format 71; entry 1: 4x4 BC7 format 98 withmode6.BLOCKfromtests/bcpack_mode6_vector.py).test_real_exporter_dds_and_pixel_verification): Invokes the real pinned exporter (ttpf_mips.py) to export both textures to DX10 DDS with manifest generation under strict mode.decode_bc1_blockindependently decodes the 8-byte BC1 payload into RGBA8, verifying that all 16 texels match pure red.bc7_blocks.decodeindependently decodes the 16-byte BC7 payload into RGBA8, verifying bit-exact agreement withmode6.RGBA.All 7 tests in
tests/ttpf_batch_export_check.pypass (0.05s with reference tools, gracefully skipped when absent), and all 23 pure-Python test suites pass cleanly.Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-23T05:57:32Z.
Updated in commit
ac66ea1and refreshed PR description:Manifest as authority and stale DDS cleanup:
tools/ttpf_batch_export.py,export_texture_entryunlinks any existing target DDS file when an export fails or is rejected, preventing stale files from prior runs in a reused directory from remaining on disk.test_export_fitted_then_strict_reused_directoryintests/ttpf_batch_export_check.pyto verify that running a provisional/fitted export followed by a strict-by-default export against the same output directory purges the stale provisional DDS upon strict failure, keeping the directory and manifest in sync.Pinned tools revision and actual run evidence:
b0befb4b88d6640354940117448ea19d52507584), the exact execution command (python -B tests/ttpf_batch_export_check.py -vwithTTPF_TOOLS_DIR), and the observed test output (test_real_exporter_dds_and_pixel_verification ... ok, 8 tests in 0.082s) alongside the default skip baseline (skipped=1).Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T06:28:26Z.
I independently reran
python -B tests/ttpf_batch_export_check.py -vatac66ea1withTTPF_TOOLS_DIRpointing to Leonidab0befb4. All 8 tests ran and passed, including the actual BC1 and BC7 pixel checks. The new cleanup deletes a colliding DDS even when analysis fails before writing anything. A failed run should preserve existing files in a reused directory: please make the current manifest authoritative, with no file or hash on the failed entry, and have the fitted-then-strict test check that the prior file still has its original bytes.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T06:44:59Z.
I pushed
7d3940bto preserve a prior DDS when a new export fails. The current manifest records the failed entry without a file or hash. The fitted-then-strict test checked that the old bytes stayed unchanged, and all eight tests passed with Leonidab0befb4, including both real-exporter pixel comparisons.Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-23T06:47:01Z.
Thanks for pushing
7d3940b, @R0Y00. I added regression coverage in2959baafor two cases. A descriptor analysis error preserves the existing DDS byte-for-byte, and a backend failure after writing partial output removes the temporary file. The fitted-then-strict test also checks the failure reason and verifies that the current manifest omitsfileandsha256for the failed entry.I ran
python -B tests/ttpf_batch_export_check.py -vwithTTPF_TOOLS_DIRpointing to Leonidab0befb4b88d6640354940117448ea19d52507584. All 9 tests passed, including the real BC1 and BC7 pixel comparisons.ctest --preset dev --no-tests=error -R '^ttpf_batch_export$' -Valso passed with the optional backend check skipped whenTTPF_TOOLS_DIRwas unset.