dds_png: pick the BC4/BC5 SNORM ramp from the stored endpoints (DDS-PNG-SNORM-MODE) #2084
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2084"
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 ubiquitarianism/leonida. Originally posted by syfyra on 2026-11-25T19:50:23Z.
Claimed in the coordination issue as: DDS-PNG-SNORM-MODE (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7172770290)
What and why
tools/dds_png.py_bc_interp_lut_snormclamped a -128 endpoint to -127 before choosing between the eight- and six-value ramps. D3D's BC4_SNORM rule compares the stored int8 endpoints (red_0 > red_1) and reads -128 as -127 only once it becomes a value; DirectXTex and Pillow decode it the same way.So the endpoint pair
0x81, 0x80(-127 > -128) is an eight-value block whose entries are all -1.0. The clamp made the two endpoints equal, the six-value ramp was taken, and index 7 decoded to its constant +1.0: 255 instead of 0 in the PNG, for BC4_SNORM and both channels of BC5_SNORM (DXGI 81/84 and theBC4S/BC5SFourCCs). The ramp is now chosen from the stored values and only the values are clamped. Of the 65,536 endpoint pairs this changes the ramp of exactly that one.Tested
Windows 11, Python 3.14.7, synthetic blocks only:
python -I tests/test_dds_png.py: the newBc4Tests.test_snorm_ramp_is_chosen_by_the_raw_endpoints(BC4S and BC5S, both endpoint orders) fails onmainwith255 != 0and passes with the fix; 101 tests OK.dds_pngand by Pillow 12.3: onmainone mismatch (0x81, 0x80, index 7: 255 vs 0); with the fix the largest difference is 1 (rounding).test_dds_png_dx10,test_dds_subresources,test_gallery,test_world_build,test_batch_glb;python -m compileall;scripts/check_no_game_data.pyon both files. Not run:tests/test_tex_export.py(pytest and numpy).GPUs tested: n/a (CPU-only decoder)
AI-assisted: yes (Claude Code, Claude Opus 5.5)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code
Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-28T10:12:20Z.
#2084 | head
9797ec66a1afc092aa64ce4304860af1f18185c7|python3 -I tests/test_dds_png.py -v| red: 101 run, 2 failures | green: 101 passed | Red → greenThe signed BC4/BC5 endpoint cases failed their decoded-value assertions on main.
Pinned main
33db04a7010e81c40a7a6a15624525aa0c4a3a58, merged into this PR head. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Full suite: not run. AI-assisted: OpenAI Codex. Batch claim.Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-28T10:47:15Z.
Merged, thank you @syfyra!
What it does: dds_png: pick the BC4/BC5 SNORM ramp from the stored endpoints (DDS-PNG-SNORM-MODE)
How it was checked: sodove tested this PR at head
9797ec66aon main33db04a70: the PR's own test fails on main and passes with this PR merged in (his result is linked from the batch summary in #1608). We then re-ran the same test locally on Windows 11 and got the same verdict: on main, red (2 failures); with the PR, green (101 OK).CI: the red jobs on this PR fail the same way on main, or on the older main it was built on (the
cs_dpp_cmp.asmtranslator fixture, since fixed on main, and the Windows runner's Visual Studio setup), so none comes from this change.Merged one by one with 20 other PRs of the same reviewed batch, pinned to the tested head.
AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.