[PR #2394] [MERGED] [integration] DDS preview formats: R8/RG8, RGBA16 UNORM/SNORM, R9G9B9E5, B5 packed, R10G10B10A2 UINT/TYPELESS (INTEGRATION-ZRO-DRAFTS) #2396

Closed
opened 2026-11-26 21:21:06 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2394
Author: @aslan2142
Created: 11/26/2026
Status: ✅ Merged
Merged: 11/26/2026
Merged by: @aslan2142

Base: main ← Head: integration/dds-preview-formats


📝 Commits (10+)

  • 26fd8ff dds_png: decode DXGI RGBA16 UNORM previews
  • 7286d78 docs: list RGBA16 UNORM PNG previews
  • c4439f5 dds_png: decode DXGI RGBA16 SNORM previews
  • d36c961 dds_png: decode R9G9B9E5 shared exponent previews
  • 3e8c273 dds_png: decode packed B5 color previews
  • 893f1a0 dds_png: decode R8G8_SNORM previews
  • 81df9f5 dds_png: decode R8G8 integer previews
  • c5efad4 dds_png: preview R10G10B10A2 typeless
  • 943bba2 Add R10G10B10A2_UINT PNG preview support
  • 4ba0afc Add R8 integer PNG preview support

📊 Changes

6 files changed (+356 additions, -24 deletions)

View changed files

📝 tests/test_dds_png_dx10.py (+109 -0)
📝 tests/test_tex_export.py (+23 -7)
📝 tests/test_tex_headers.py (+6 -0)
📝 tools/dds_png.py (+211 -13)
📝 tools/tex_export.py (+5 -3)
📝 tools/tex_headers.py (+2 -1)

📄 Description

One tested batch of DDS preview formats for tools/dds_png.py and tools/tex_export.py --png: 11 pull requests, merged one by one with a merge commit each, so the authors' commits stay theirs. Then one maintainer commit adds the missing tests and the tex_export --png fix for R9G9B9E5.

Claim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7200103121 (INTEGRATION-ZRO-DRAFTS)

Base: main at bdbc7e923.

Included

PR Author Formats (DXGI) Head merged
#2247 @kirigayakazima R8_UNORM (61), R8G8_UNORM (49) f833599c8
#2157 @ZroIsHere R16G16B16A16_UNORM (11) 7286d7823
#2158 @ZroIsHere R16G16B16A16_SNORM (13) c4439f583
#2218 @ZroIsHere R9G9B9E5_SHAREDEXP (67) d36c961c3
#2314 @ZroIsHere B5G6R5_UNORM (85), B5G5R5A1_UNORM (86) 3e8c273d6
#2317 @ZroIsHere R8G8_SNORM (51) 893f1a0f4
#2319 @ZroIsHere R8G8_UINT (50), R8G8_SINT (52) 81df9f5ed
#2320 @ZroIsHere R10G10B10A2_UINT (25) 943bba2dd
#2321 @ZroIsHere R10G10B10A2_TYPELESS (23) c5efad48c
#2323 @ZroIsHere R8_SNORM (63) 1c78f0fee
#2324 @ZroIsHere R8_UINT (62), R8_SINT (64) 4ba0afc2d

We checked each decoder against the format's definition:

  • channel order and bit layout (B5G6R5: blue in bits 0-4; B5G5R5A1: alpha in bit 15; R10G10B10A2: R in the low bits);
  • R9G9B9E5 uses mantissa * 2^(e - 24);
  • SNORM: -128 and -127 are both -1.0, the same mapping as the existing BC4/BC5 SNORM;
  • linear, not sRGB.

The merges conflicted in the same format tables. Every format is kept, and each PR's new decoder function is byte-identical to its head.

Added by the maintainers (commit a28d96796)

  • Tests: synthetic tests for every format that had none: R9G9B9E5, B5G6R5, B5G5R5A1, R8G8 SNORM/UINT/SINT, R8 SNORM/UINT/SINT, and R10G10B10A2 TYPELESS/UINT (checked against UNORM). Each uses hand-built 2x2 texels with a padded row pitch and a payload one byte short.
  • tex_export --png for R9G9B9E5 (ecox982745's finding on #2218): tools/tex_headers.py now lists DXGI 67 in DXGI and FMT_INFO. New tests:
    • test_shared_exponent_r9g9b9e5_writes_a_png follows the texture from the index through the DDS to the PNG;
    • test_shared_exponent_format_is_indexed_and_sized checks the indexer's table.
  • Test update for #2320: two test_tex_export.py cases used DXGI 25 as an undecodable format, and #2320 makes it decodable. They now use R8G8B8A8_UINT (30). len(T.FMT) is now 57.
  • Docstrings: one list of the decoded formats in dds_png.py and tex_export.py, instead of a line per PR.

Left out

  • #2322 and #2316 duplicate #2247: they add the same formats.
  • No other pull request by ZroIsHere is in this batch.

Tests

Linux, Python 3.13, CPU only, no GPU needed:

  • Texture tool tests (pytest): 503 passed, 3 skipped, 515 subtests. Files: test_tex_export.py, test_dds_png.py, test_dds_png_dx10.py, test_dds_subresources.py, test_tex_headers.py, test_tex_headers_report_paths.py, test_ttpf_mips.py, test_ttpf_assets.py, test_calibrated_texture.py, test_calibrated_texture_extra.py.
  • Standalone under python3 -I, all OK:
    • test_dds_png_dx10.py: 16 tests
    • test_dds_png.py: 100
    • test_dds_subresources.py: 13
    • test_tex_headers.py: 78
    • test_tex_headers_report_paths.py: 8
    • test_ci_registration.py: 16
    • test_text_write_line_endings.py: 3
  • The new tests fail on main: we ran the branch's three changed test files against main's tools. 16 tests fail: every new format test, the R9G9B9E5 export test, the indexer table test and the FMT count.
  • Other checks: compileall is clean, make_game.py --help runs, and check_no_game_data.py passes on all six changed files.

Not tested

  • No game files: the formats were not tested on game textures.
  • Indexer change: adding DXGI 67 means the indexer now keeps descriptors whose format byte is 67. We have not counted how many such descriptors the full corpus has.
  • restofworld_index.py: its own format table (commented "kept in step with tools/tex_headers.py") is unchanged.
  • B5G6R5, B5G5R5A1 and R10G10B10A2_TYPELESS: these decode in dds_png.py, but the indexer does not list them, so tex_export --png cannot reach them. The tex_export docstring no longer claims them.
  • Platforms: Windows and macOS not run.

AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)


🔄 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/2394 **Author:** [@aslan2142](https://github.com/aslan2142) **Created:** 11/26/2026 **Status:** ✅ Merged **Merged:** 11/26/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `integration/dds-preview-formats` --- ### 📝 Commits (10+) - [`26fd8ff`](https://github.com/ubiquitarianism/leonida/commit/26fd8ff036b1591986212689d5c9e71a1ee21e6a) dds_png: decode DXGI RGBA16 UNORM previews - [`7286d78`](https://github.com/ubiquitarianism/leonida/commit/7286d78232e170e64d24409f384b66e6cc6872f1) docs: list RGBA16 UNORM PNG previews - [`c4439f5`](https://github.com/ubiquitarianism/leonida/commit/c4439f58379278bc0948e3ba5471c91c1e27b5f3) dds_png: decode DXGI RGBA16 SNORM previews - [`d36c961`](https://github.com/ubiquitarianism/leonida/commit/d36c961c3e58f9d2a0fec93cf17c8bddcae13fff) dds_png: decode R9G9B9E5 shared exponent previews - [`3e8c273`](https://github.com/ubiquitarianism/leonida/commit/3e8c273d6b068973f60185e9f273d77cdbba6815) dds_png: decode packed B5 color previews - [`893f1a0`](https://github.com/ubiquitarianism/leonida/commit/893f1a0f444ed5535c57400ac5b37e242eb6da24) dds_png: decode R8G8_SNORM previews - [`81df9f5`](https://github.com/ubiquitarianism/leonida/commit/81df9f5ed937f47efcc5e795c3f934b98233979e) dds_png: decode R8G8 integer previews - [`c5efad4`](https://github.com/ubiquitarianism/leonida/commit/c5efad48c364211ebf971cc1bb1be92ec730f3f1) dds_png: preview R10G10B10A2 typeless - [`943bba2`](https://github.com/ubiquitarianism/leonida/commit/943bba2dd6447dc53271603e6213bf04b1c71b51) Add R10G10B10A2_UINT PNG preview support - [`4ba0afc`](https://github.com/ubiquitarianism/leonida/commit/4ba0afc2db513300d51a0004a682186b8feb90a9) Add R8 integer PNG preview support ### 📊 Changes **6 files changed** (+356 additions, -24 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_dds_png_dx10.py` (+109 -0) 📝 `tests/test_tex_export.py` (+23 -7) 📝 `tests/test_tex_headers.py` (+6 -0) 📝 `tools/dds_png.py` (+211 -13) 📝 `tools/tex_export.py` (+5 -3) 📝 `tools/tex_headers.py` (+2 -1) </details> ### 📄 Description One tested batch of DDS preview formats for `tools/dds_png.py` and `tools/tex_export.py --png`: 11 pull requests, merged one by one with a merge commit each, so the authors' commits stay theirs. Then one maintainer commit adds the missing tests and the `tex_export --png` fix for R9G9B9E5. Claim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7200103121 (`INTEGRATION-ZRO-DRAFTS`) Base: `main` at `bdbc7e923`. ## Included | PR | Author | Formats (DXGI) | Head merged | | --- | --- | --- | --- | | #2247 | @kirigayakazima | R8_UNORM (61), R8G8_UNORM (49) | `f833599c8` | | #2157 | @ZroIsHere | R16G16B16A16_UNORM (11) | `7286d7823` | | #2158 | @ZroIsHere | R16G16B16A16_SNORM (13) | `c4439f583` | | #2218 | @ZroIsHere | R9G9B9E5_SHAREDEXP (67) | `d36c961c3` | | #2314 | @ZroIsHere | B5G6R5_UNORM (85), B5G5R5A1_UNORM (86) | `3e8c273d6` | | #2317 | @ZroIsHere | R8G8_SNORM (51) | `893f1a0f4` | | #2319 | @ZroIsHere | R8G8_UINT (50), R8G8_SINT (52) | `81df9f5ed` | | #2320 | @ZroIsHere | R10G10B10A2_UINT (25) | `943bba2dd` | | #2321 | @ZroIsHere | R10G10B10A2_TYPELESS (23) | `c5efad48c` | | #2323 | @ZroIsHere | R8_SNORM (63) | `1c78f0fee` | | #2324 | @ZroIsHere | R8_UINT (62), R8_SINT (64) | `4ba0afc2d` | We checked each decoder against the format's definition: - channel order and bit layout (B5G6R5: blue in bits 0-4; B5G5R5A1: alpha in bit 15; R10G10B10A2: R in the low bits); - R9G9B9E5 uses `mantissa * 2^(e - 24)`; - SNORM: -128 and -127 are both -1.0, the same mapping as the existing BC4/BC5 SNORM; - linear, not sRGB. The merges conflicted in the same format tables. Every format is kept, and each PR's new decoder function is byte-identical to its head. ## Added by the maintainers (commit `a28d96796`) - **Tests:** synthetic tests for every format that had none: R9G9B9E5, B5G6R5, B5G5R5A1, R8G8 SNORM/UINT/SINT, R8 SNORM/UINT/SINT, and R10G10B10A2 TYPELESS/UINT (checked against UNORM). Each uses hand-built 2x2 texels with a padded row pitch and a payload one byte short. - **`tex_export --png` for R9G9B9E5** (ecox982745's finding on #2218): `tools/tex_headers.py` now lists DXGI 67 in `DXGI` and `FMT_INFO`. New tests: - `test_shared_exponent_r9g9b9e5_writes_a_png` follows the texture from the index through the DDS to the PNG; - `test_shared_exponent_format_is_indexed_and_sized` checks the indexer's table. - **Test update for #2320:** two `test_tex_export.py` cases used DXGI 25 as an undecodable format, and #2320 makes it decodable. They now use R8G8B8A8_UINT (30). `len(T.FMT)` is now 57. - **Docstrings:** one list of the decoded formats in `dds_png.py` and `tex_export.py`, instead of a line per PR. ## Left out - #2322 and #2316 duplicate #2247: they add the same formats. - No other pull request by ZroIsHere is in this batch. ## Tests Linux, Python 3.13, CPU only, no GPU needed: - **Texture tool tests (pytest):** 503 passed, 3 skipped, 515 subtests. Files: `test_tex_export.py`, `test_dds_png.py`, `test_dds_png_dx10.py`, `test_dds_subresources.py`, `test_tex_headers.py`, `test_tex_headers_report_paths.py`, `test_ttpf_mips.py`, `test_ttpf_assets.py`, `test_calibrated_texture.py`, `test_calibrated_texture_extra.py`. - **Standalone under `python3 -I`, all OK:** - `test_dds_png_dx10.py`: 16 tests - `test_dds_png.py`: 100 - `test_dds_subresources.py`: 13 - `test_tex_headers.py`: 78 - `test_tex_headers_report_paths.py`: 8 - `test_ci_registration.py`: 16 - `test_text_write_line_endings.py`: 3 - **The new tests fail on `main`:** we ran the branch's three changed test files against `main`'s tools. 16 tests fail: every new format test, the R9G9B9E5 export test, the indexer table test and the `FMT` count. - **Other checks:** `compileall` is clean, `make_game.py --help` runs, and `check_no_game_data.py` passes on all six changed files. ## Not tested - **No game files:** the formats were not tested on game textures. - **Indexer change:** adding DXGI 67 means the indexer now keeps descriptors whose format byte is 67. We have not counted how many such descriptors the full corpus has. - **`restofworld_index.py`:** its own format table (commented "kept in step with tools/tex_headers.py") is unchanged. - **B5G6R5, B5G5R5A1 and R10G10B10A2_TYPELESS:** these decode in `dds_png.py`, but the indexer does not list them, so `tex_export --png` cannot reach them. The `tex_export` docstring no longer claims them. - **Platforms:** Windows and macOS not run. AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 21:21:06 +01:00
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#2396
No description provided.