textures: reject invalid BC7 mode and negative partition indices #560

Merged
Neoplayer merged 1 commit from upstream-pr/566 into main 2026-11-22 13:16:30 +00:00
Neoplayer commented 2026-11-22 12:47:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Neoplayer on 2026-11-22T12:47:23Z.


Change

Reject negative, boolean, and out-of-range mode or partition arguments in tools/bc7_blocks.py (subsets, anchors, layout, pack, fixture_fields) via _mode_entry() and _check_partition(). Previously subsets(1, -1) silently indexed PARTITIONS_2[-1] (partition 63) and layout(-1) indexed MODES[-1] before failing with AssertionError on assert offset == 128. Adds negative controls in tests/bc7_blocks_check.py.

Verification

  • Base commit: d3586dd
  • Host: macOS 26.5.1 (arm64), Python 3.12.13 (out/pe-env)
  • Commands and results:
    • ./out/pe-env/bin/python -B tests/bc7_blocks_check.py -> Ran 10 tests in 0.125s, OK (skipped=2) (the 2 skips are optional BCPACK_REFERENCE_TOOLS and texture2ddecoder)
    • ./out/pe-env/bin/python -B tests/bcpack_check.py -> Ran 8 tests in 0.074s, OK
    • ./out/pe-env/bin/python -B tests/bc7_tiles_check.py -> Ran 6 tests in 0.008s, OK
    • ./out/pe-env/bin/python -B tests/bidi_controls_check.py -> Self-test passed. Checked 549 tracked source, script and build/CI files: no bidirectional controls.
    • git diff --check -> exit 0
  • Not run locally: Windows D3D12/WARP BC7 draw checks (bc7_draw_*) require x64 Windows and are deferred to CI (build-and-test).

Evidence and follow-up

All new negative controls in tests/bc7_blocks_check.py are pure-Python unit assertions over tools/bc7_blocks.py with no external inputs or game assets.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed. (N/A — no build requirements changed)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6542561617 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/566). Originally posted by [Neoplayer](https://github.com/Neoplayer) on 2026-11-22T12:47:23Z. --- ## Change Reject negative, boolean, and out-of-range `mode` or `partition` arguments in `tools/bc7_blocks.py` (`subsets`, `anchors`, `layout`, `pack`, `fixture_fields`) via `_mode_entry()` and `_check_partition()`. Previously `subsets(1, -1)` silently indexed `PARTITIONS_2[-1]` (partition 63) and `layout(-1)` indexed `MODES[-1]` before failing with `AssertionError` on `assert offset == 128`. Adds negative controls in `tests/bc7_blocks_check.py`. ## Verification - Base commit: `d3586dd` - Host: macOS 26.5.1 (`arm64`), Python 3.12.13 (`out/pe-env`) - Commands and results: - `./out/pe-env/bin/python -B tests/bc7_blocks_check.py` -> `Ran 10 tests in 0.125s`, `OK (skipped=2)` (the 2 skips are optional `BCPACK_REFERENCE_TOOLS` and `texture2ddecoder`) - `./out/pe-env/bin/python -B tests/bcpack_check.py` -> `Ran 8 tests in 0.074s`, `OK` - `./out/pe-env/bin/python -B tests/bc7_tiles_check.py` -> `Ran 6 tests in 0.008s`, `OK` - `./out/pe-env/bin/python -B tests/bidi_controls_check.py` -> `Self-test passed. Checked 549 tracked source, script and build/CI files: no bidirectional controls.` - `git diff --check` -> exit 0 - Not run locally: Windows D3D12/WARP BC7 draw checks (`bc7_draw_*`) require x64 Windows and are deferred to CI (`build-and-test`). ## Evidence and follow-up All new negative controls in `tests/bc7_blocks_check.py` are pure-Python unit assertions over `tools/bc7_blocks.py` with no external inputs or game assets. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. (N/A — no build requirements changed) - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
upstream-sync closed this pull request 2026-11-24 06:43:43 +00:00
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
R0Y00/Xbox2Windows!560
No description provided.