sandbox_scene: downsample sRGB albedo in linear light #2443

Merged
kirigayakazima merged 1 commit from upstream-pr/2443 into main 2026-11-28 15:12:38 +00:00
kirigayakazima commented 2026-11-27 10:16:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-27T10:16:58Z.


Claimed in the coordination issue as: SANDBOX-SCENE-SRGB-ALBEDO

What and why

The scene packer discarded the DDS color-space tag before filtering albedo. Allow the existing RGBA decoder to take a size limit and pass the decoded color space to the existing filter. A two-by-two black-and-white synthetic texture now averages to 188 for sRGB and 128 for linear UNORM. Both variants are checked against packed scene bytes.

Tested

Windows, Python 3.14.7, synthetic fixtures.

  • python -I tests/test_sandbox_scene.py
  • python -I tests/test_dds_png.py
  • python -I tests/test_dds_png_dx10.py
  • Changed-path game-data scan and git diff --check passed.
  • Shared main baseline: 6,374 translator semantic tests passed across 500 files. The combined five-topic checkout passed 172 focused tests.

GPUs tested: N/A (CPU-only).

AI-assisted: Yes.

Checklist

  • Based on current main and merges cleanly with the tested base.
  • One topic.
  • No game data, keys or decryption.
  • Translator contract table: N/A.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5524928855 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2443). Originally posted by [kirigayakazima](https://github.com/kirigayakazima) on 2026-11-27T10:16:58Z. --- Claimed in the coordination issue as: [SANDBOX-SCENE-SRGB-ALBEDO](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7215561737) ### What and why The scene packer discarded the DDS color-space tag before filtering albedo. Allow the existing RGBA decoder to take a size limit and pass the decoded color space to the existing filter. A two-by-two black-and-white synthetic texture now averages to 188 for sRGB and 128 for linear UNORM. Both variants are checked against packed scene bytes. ### Tested Windows, Python 3.14.7, synthetic fixtures. - `python -I tests/test_sandbox_scene.py` - `python -I tests/test_dds_png.py` - `python -I tests/test_dds_png_dx10.py` - Changed-path game-data scan and `git diff --check` passed. - Shared main baseline: 6,374 translator semantic tests passed across 500 files. The combined five-topic checkout passed 172 focused tests. GPUs tested: N/A (CPU-only). AI-assisted: Yes. ### Checklist - [x] Based on current main and merges cleanly with the tested base. - [x] One topic. - [x] No game data, keys or decryption. - Translator contract table: N/A.
zmasi commented 2026-11-28 07:35:40 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T07:35:40Z.


#2443 | head cb82451594 (merged cleanly with main 09c153948) | python -I tests/test_sandbox_scene.py | red on main: FAILED (failures=1) (test_texture_filter_honors_dds_color_space on fmt=29 sRGB produced 0x80 instead of 0xbc) | green on PR+main: 13 tests OK (-k test_texture_filter_honors_dds_color_space: 1 test OK) | Windows 11, Python 3.12.10 | AI-assisted: yes

Audited decode_dds(..., max_size=...) in tools/dds_png.py and texture_bytes in tools/sandbox_scene.py (forwarding srgb from _decode_dds into downscale_rgba), and verified both PR + main (09c153948) and combined sibling merges main + #2443 + #2442 and main + #2444 + #2443 + #2442 (0 conflicts; 14 tests OK in tests/test_sandbox_scene.py, 9 tests OK in tests/test_sandbox_scene_build.py). Also passed tests/test_dds_png.py (100 OK), tests/test_text_write_line_endings.py (3 OK), tests/test_runner_calls_all_tests.py (3 OK), and scripts/check_no_game_data.py.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7236039833 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2443#issuecomment-7236039833). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T07:35:40Z. --- #2443 | head cb8245159464d2c70b4c935b2b99577f53732ca8 (merged cleanly with main 09c153948) | `python -I tests/test_sandbox_scene.py` | red on main: `FAILED (failures=1)` (`test_texture_filter_honors_dds_color_space` on `fmt=29` sRGB produced `0x80` instead of `0xbc`) | green on PR+main: `13 tests OK` (`-k test_texture_filter_honors_dds_color_space`: `1 test OK`) | Windows 11, Python 3.12.10 | AI-assisted: yes Audited `decode_dds(..., max_size=...)` in `tools/dds_png.py` and `texture_bytes` in `tools/sandbox_scene.py` (forwarding `srgb` from `_decode_dds` into `downscale_rgba`), and verified both `PR + main` (`09c153948`) and combined sibling merges `main + #2443 + #2442` and `main + #2444 + #2443 + #2442` (`0` conflicts; `14 tests OK` in `tests/test_sandbox_scene.py`, `9 tests OK` in `tests/test_sandbox_scene_build.py`). Also passed `tests/test_dds_png.py` (`100 OK`), `tests/test_text_write_line_endings.py` (`3 OK`), `tests/test_runner_calls_all_tests.py` (`3 OK`), and `scripts/check_no_game_data.py`.
timbot103 commented 2026-11-28 14:36:49 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-28T14:36:49Z.

Review: COMMENTED


Static code audit against cb8245159 + ec740bcc3. I reproduced the baseline sRGB failure and confirmed that the patch packs 188 for sRGB and 128 for UNORM.

MINOR (tools/dds_png.py:1499, tools/sandbox_scene.py:70) Moving resize into decode_dds retains the entire input DDS while filtering. A synthetic 1024×1024 RGBA8 mip chain resized to 256×256 raised Python's peak traced allocation from 9.34 MiB to 11.34 MiB for both tags. Releasing data after decode and before resize restored the baseline peak in the same check.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6098419553 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2443#pullrequestreview-6098419553). Originally posted by [timbot103](https://github.com/timbot103) on 2026-11-28T14:36:49Z. **Review:** COMMENTED --- Static code audit against `cb8245159` + `ec740bcc3`. I reproduced the baseline sRGB failure and confirmed that the patch packs 188 for sRGB and 128 for UNORM. **MINOR** (`tools/dds_png.py:1499`, `tools/sandbox_scene.py:70`) Moving resize into `decode_dds` retains the entire input DDS while filtering. A synthetic 1024×1024 RGBA8 mip chain resized to 256×256 raised Python's peak traced allocation from 9.34 MiB to 11.34 MiB for both tags. Releasing `data` after decode and before resize restored the baseline peak in the same check. AI-assisted.
MoonEyes commented 2026-11-28 15:12:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T15:12:34Z.


Red/green: classified READY by oreo-lot3 (red on main b1619e0a3, green on head merged with main); head cb82451594 unchanged since 2026-11-27, before that run.
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)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7241287976 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2443#issuecomment-7241287976). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T15:12:34Z. --- Red/green: classified READY by oreo-lot3 (red on main b1619e0a3, green on head merged with main); head cb8245159464 unchanged since 2026-11-27, before that run. 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 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
ProjectLeonida/mandy!2443
No description provided.