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

Open
github-bot wants to merge 2 commits from github-bot/gh-1751 into main AGit
Owner

@⁠kirigayakazima on GitHub · 2026-11-25 11:14 UTC · original
kirigayakazima:codex/batch-glb-dds-sibling-fallback → main · +93 −24 · 2 files · 2 commits · open

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.
**@⁠kirigayakazima** on GitHub · 2026-11-25 11:14 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1751) `kirigayakazima:codex/batch-glb-dds-sibling-fallback` → `main` · +93 −24 · 2 files · 2 commits · open Claimed in the coordination issue as: [BATCH-GLB-DDS-SIBLING-FALLBACK](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ### 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:03:40 +00:00
Author
Owner

@⁠lixonik on GitHub · 2026-11-25 11:19 UTC · original · reviewed

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.

**@⁠lixonik** on GitHub · 2026-11-25 11:19 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1751#pullrequestreview-6056672434) · **reviewed** 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.
@ -134,0 +126,4 @@
candidates = next((tex_index[key] for key in lookup_keys if key in tex_index), [])
if isinstance(candidates, str):
candidates = [candidates] # callers may supply a single path for each stem
for found_path in candidates:
Author
Owner

@⁠lixonik on GitHub · 2026-11-25 11:19 UTC · original

The fallback still stops at a corrupt PNG if the file is readable and nonempty. I used a preferred PNG with a valid signature but truncated contents and a usable same-stem DDS. Conversion reported success, embedded the truncated bytes as image/png, and produced neither a warning nor the DDS image. The candidate loop sees any nonempty PNG bytes as success. Could the loader validate the preferred PNG enough to reject corruption before deciding whether to try the sibling?

**@⁠lixonik** on GitHub · 2026-11-25 11:19 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1751#discussion_r4694122826) The fallback still stops at a corrupt PNG if the file is readable and nonempty. I used a preferred PNG with a valid signature but truncated contents and a usable same-stem DDS. Conversion reported success, embedded the truncated bytes as image/png, and produced neither a warning nor the DDS image. The candidate loop sees any nonempty PNG bytes as success. Could the loader validate the preferred PNG enough to reject corruption before deciding whether to try the sibling?
Author
Owner

@⁠ZroIsHere on GitHub · 2026-11-26 01:15 UTC · original

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

**@⁠ZroIsHere** on GitHub · 2026-11-26 01:15 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1751#issuecomment-7179585295) 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
@ -134,0 +173,4 @@
candidates = next((tex_index[key] for key in lookup_keys if key in tex_index), [])
if isinstance(candidates, str):
candidates = [candidates] # callers may supply a single path for each stem
for found_path in candidates:
Author
Owner

@⁠kirigayakazima on GitHub · 2026-11-27 12:09 UTC · original

Fixed: added PNG signature, IHDR/IDAT/IEND framing, and per-chunk CRC32 validation in tools/batch_glb.py so truncated or corrupt preferred PNGs fall back cleanly to their sibling DDS with diagnostic reporting. Added truncated-PNG fallback coverage in tests/test_batch_glb.py.

**@⁠kirigayakazima** on GitHub · 2026-11-27 12:09 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1751#discussion_r4719193840) Fixed: added PNG signature, IHDR/IDAT/IEND framing, and per-chunk CRC32 validation in `tools/batch_glb.py` so truncated or corrupt preferred PNGs fall back cleanly to their sibling DDS with diagnostic reporting. Added truncated-PNG fallback coverage in `tests/test_batch_glb.py`.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1751/head:github-bot/gh-1751'
git switch 'github-bot/gh-1751'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1751'
git switch 'github-bot/gh-1751'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1751'
git switch 'github-bot/gh-1751'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1751'
git switch 'main'
git merge --squash 'github-bot/gh-1751'
git switch 'main'
git merge --ff-only 'github-bot/gh-1751'
git switch 'main'
git merge 'github-bot/gh-1751'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.