batch_glb: try a same-stem DDS when the preferred PNG cannot be read #1751

Merged
leonida/mandy
kirigayakazima merged 2 commits from codex/batch-glb-dds-sibling-fallback into main 2026-11-28 14:56:46 +00:00

Pull request successfully merged and closed

kirigayakazima commented 2026-11-25 11:14:28 +00:00

Claimed in the coordination issue as: BATCH-GLB-DDS-SIBLING-FALLBACK

What and why

Texture indexing kept only the preferred PNG for a stem. An empty or unreadable PNG therefore stripped the material's texture even if a usable DDS sat beside it. The index now retains candidates in preference order. Conversion records the failed PNG and tries the DDS for the same stem. A readable PNG still wins.

Tested

The synthetic OBJ uses UVs and a material shared by a PNG and DDS with distinct pixel values. The regression checks the actual embedded image bytes with a usable preferred PNG and again with an empty PNG. On the baseline the DDS image was absent in the second run.

  • python -I tests/test_batch_glb.py passed all 17 tests on this branch (Windows, Python 3.14.7).
  • git diff --check and the repository game-data scan of all changed paths passed.
  • The five independent changes were also merged locally. Both affected test files passed together (50 tests) and the three character-model consumer suites passed (28 tests). The shared base at bcaa13da passed 6,287 semantic tests across 488 files.

GPUs tested: N/A (CPU-only asset tooling).
AI-assisted: Yes.

Checklist

  • Based on current upstream main.
  • One topic.
  • Only synthetic test fixtures. No game data, keys or decryption.
  • Translator contract table: N/A.
Claimed in the coordination issue as: [BATCH-GLB-DDS-SIBLING-FALLBACK](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7160621714) ### What and why Texture indexing kept only the preferred PNG for a stem. An empty or unreadable PNG therefore stripped the material's texture even if a usable DDS sat beside it. The index now retains candidates in preference order. Conversion records the failed PNG and tries the DDS for the same stem. A readable PNG still wins. ### Tested The synthetic OBJ uses UVs and a material shared by a PNG and DDS with distinct pixel values. The regression checks the actual embedded image bytes with a usable preferred PNG and again with an empty PNG. On the baseline the DDS image was absent in the second run. - `python -I tests/test_batch_glb.py` passed all 17 tests on this branch (Windows, Python 3.14.7). - `git diff --check` and the repository game-data scan of all changed paths passed. - The five independent changes were also merged locally. Both affected test files passed together (50 tests) and the three character-model consumer suites passed (28 tests). The shared base at `bcaa13da` passed 6,287 semantic tests across 488 files. GPUs tested: N/A (CPU-only asset tooling). AI-assisted: Yes. ### Checklist - [x] Based on current upstream main. - [x] One topic. - [x] Only synthetic test fixtures. No game data, keys or decryption. - Translator contract table: N/A.
lixonik reviewed 2026-11-25 11:19:58 +00:00
lixonik left a comment
No description provided.
Independent check at "a0957dcd". Windows: all 17 batch tests passed, including the empty-PNG fallback. A readable but malformed PNG still won over a usable sibling DDS in a separate synthetic conversion. Details inline. AI-assisted review and CPU-only testing with synthetic inputs.
ZroIsHere commented 2026-11-26 01:15:07 +00:00

I addressed the corrupt-but-readable PNG case from the review in a stacked draft follow-up: https://github.com/kirigayakazima/leonida-continued/pull/1

I addressed the corrupt-but-readable PNG case from the review in a stacked draft follow-up: https://github.com/kirigayakazima/leonida-continued/pull/1
kirigayakazima reviewed 2026-11-27 12:09:52 +00:00
lixonik reviewed 2026-11-27 15:50:25 +00:00
lixonik left a comment
No description provided.
Re-verified at `2689c7f5b` (merged cleanly onto `main` `ec91d695c`). - Confirmed the prior finding is resolved: `_validate_png_bytes()` validates the PNG signature, chunk framing, per-chunk CRC32, `IHDR` length/dimensions, `IDAT` presence, and empty `IEND` with no trailing data, so corrupt or truncated preferred PNGs fall back to a sibling DDS while retaining the PNG diagnostic. Checked additional synthetic corrupt inputs (bad CRC, trailing bytes after `IEND`, missing `IDAT`, zero `IHDR` dimension, truncated header) directly. - Windows 11, Python 3.12: `python -I -B tests/test_batch_glb.py -v` passed (17/17); `scripts/check_no_game_data.py` and `git diff --check` clean. - No remaining findings. AI-assisted.
zmasi commented 2026-11-28 11:38:19 +00:00

#1751 | head 2689c7f5ba095d03a96df7db4d046d7efad40fe2 (merged cleanly with main 4a54aedcb) | python -I tests/test_batch_glb.py | red on main: FAILED (failures=2) (empty_png and truncated_png subtests failed to fall back to same-stem DDS and embedded truncated PNG bytes) | green on PR+main: 17 tests OK | Windows 11, Python 3.12.10 | AI-assisted: yes

Audited _build_texture_index, _validate_png_bytes, and convert_single in tools/batch_glb.py (validating PNG signature, chunk bounds/CRC32, IHDR dimensions, IDAT presence, and IEND framing, retaining the failed PNG diagnostic in dropped while falling back to a same-stem .dds, and preserving single-path tex_index compatibility). Also verified clean merge (0 conflicts) and combined execution with #1752 (19 tests OK; note a trivial import-block context overlap in tools/batch_glb.py if merged alongside #1750), plus tests/test_ci_registration.py (18 OK), tests/test_text_write_line_endings.py (3 OK), and scripts/check_no_game_data.py.

#1751 | head 2689c7f5ba095d03a96df7db4d046d7efad40fe2 (merged cleanly with main 4a54aedcb) | `python -I tests/test_batch_glb.py` | red on main: `FAILED (failures=2)` (`empty_png` and `truncated_png` subtests failed to fall back to same-stem DDS and embedded truncated PNG bytes) | green on PR+main: `17 tests OK` | Windows 11, Python 3.12.10 | AI-assisted: yes Audited `_build_texture_index`, `_validate_png_bytes`, and `convert_single` in `tools/batch_glb.py` (validating PNG signature, chunk bounds/CRC32, `IHDR` dimensions, `IDAT` presence, and `IEND` framing, retaining the failed PNG diagnostic in `dropped` while falling back to a same-stem `.dds`, and preserving single-path `tex_index` compatibility). Also verified clean merge (`0` conflicts) and combined execution with #1752 (`19 tests OK`; note a trivial `import`-block context overlap in `tools/batch_glb.py` if merged alongside #1750), plus `tests/test_ci_registration.py` (`18 OK`), `tests/test_text_write_line_endings.py` (`3 OK`), and `scripts/check_no_game_data.py`.
MoonEyes commented 2026-11-28 14:56:44 +00:00

Red/green: pytest tests/test_batch_glb.py fails on main (2 failed, 17 passed, 12 subtests passed) and passes on head 2689c7f5ba09 merged with main (17 passed, 14 subtests passed).
Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main d48a957bb in GitHub Actions: no new failure.
AI-assisted (Claude Code, Claude Opus 5.5)

Red/green: `pytest tests/test_batch_glb.py` fails on main (2 failed, 17 passed, 12 subtests passed) and passes on head 2689c7f5ba09 merged with main (17 passed, 14 subtests passed). Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main d48a957bb in GitHub Actions: no new failure. AI-assisted (Claude Code, Claude Opus 5.5)
Sign in to join this conversation.
No description provided.