textures: check 4 KiB BC7 surface linearization against a bit-order oracle #439

Merged
roansystemlabs merged 1 commit from upstream-pr/445 into main 2026-11-22 04:06:13 +00:00
roansystemlabs commented 2026-11-22 03:45:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-22T03:45:25Z.


Change

tools/bc7_tiles.py::linearize_4k_s converts a GFX10 4 KiB standard-swizzle BC7
surface into linear block rows. Today it is exercised only by bc7_draw_check.py,
which needs DXC and a D3D12 adapter, so the platform-independent Python job never
runs it, and nothing checks its rejection paths.

This PR adds tests/bc7_tiles_check.py (standard library only) and registers it
like the neighbouring texture checks: CTest bc7_tile_swizzle, the Ubuntu
"platform-independent Python checks" job, and the AGENTS.md texture filter and
pure-Python list.

The check:

  • builds tagged surfaces from an oracle written out from the block order
    stated in tools/bc7_tiles.py, y0 y1 x0 x1 y2 x2 y3 x3 (not from the
    tool's precomputed tables), and confirms the oracle is a bijection over the
    256 blocks of a tile;
  • compares the tool against it for single blocks, pixel sizes that are not
    multiples of four, exact tile edges, and surfaces that cross tile columns and
    rows (up to 3x5 tiles);
  • confirms padding blocks outside the surface are never read and that
    bytes, bytearray and memoryview payloads give the same result;
  • confirms ValueError for non-positive dimensions (including an empty payload,
    which matches the zero tiles such sizes would need) and for payloads that are
    16 bytes or one tile too short or too long.

No tool behavior changes. The check pins the existing order; it does not
re-derive it from the AMD swizzle tables linked in docs/experiments.md.
Independent problem; it does not touch a shared interface.

Verification

Windows 11, Python 3.12, isolated venv, on top of 318d9c3 (after #348):

python -B tests/bc7_tiles_check.py       Ran 6 tests  OK
python -B tests/bc7_blocks_check.py      Ran 8 tests  OK (skipped=1)
python -B tests/bcpack_check.py          Ran 8 tests  OK
python -B tests/resource_ranges_check.py Ran 17 tests OK
python -B tests/docs_links_check.py      Self-test passed. Checked 10 Markdown files and 81 links.
python -B tests/bidi_controls_check.py   Self-test passed. Checked 354 tracked files: no bidirectional controls.

The new check sits right after bc7_blocks_check.py in the Ubuntu job and in the
AGENTS.md pure-Python list (the two lists stay identical, as #348 left them), and
bc7_tile_swizzle is registered right after bc7_block_reference in CTest.

Negative controls:

  • In the test itself: transposed bit tables, x2/x3 exchanged, the two tile
    columns of a payload exchanged, and one altered block in the second tile row
    (reported at block (1, 16)) are all detected.
  • Outside the PR, each of these in-memory mutations of linearize_4k_s made the
    check fail, and it passed again after restoring the original: tile pitch
    rounded down, tile row ignoring the pitch, x and y swapped inside a tile, size
    check accepting an extra tile, dimension check removed, row stride computed
    from the pixel width, y2/y3 exchanged in _Y_BITS, one wrong _X_BITS entry.
    The dimension-check mutant initially survived (a zero-tile size check still
    rejected a one-tile payload), which is why the empty-payload cases are included.

CTest and the CI jobs were not run locally; the CMake entry mirrors
bcpack_prefix_and_mip_tail.

AI-assisted: prepared and submitted with the support of Roan System (AI-assisted development), reviewed before posting.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6538077482 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/445). Originally posted by [roansystemlabs](https://github.com/roansystemlabs) on 2026-11-22T03:45:25Z. --- ## Change `tools/bc7_tiles.py::linearize_4k_s` converts a GFX10 4 KiB standard-swizzle BC7 surface into linear block rows. Today it is exercised only by `bc7_draw_check.py`, which needs DXC and a D3D12 adapter, so the platform-independent Python job never runs it, and nothing checks its rejection paths. This PR adds `tests/bc7_tiles_check.py` (standard library only) and registers it like the neighbouring texture checks: CTest `bc7_tile_swizzle`, the Ubuntu "platform-independent Python checks" job, and the `AGENTS.md` texture filter and pure-Python list. The check: - builds tagged surfaces from an oracle written out from the block order stated in `tools/bc7_tiles.py`, `y0 y1 x0 x1 y2 x2 y3 x3` (not from the tool's precomputed tables), and confirms the oracle is a bijection over the 256 blocks of a tile; - compares the tool against it for single blocks, pixel sizes that are not multiples of four, exact tile edges, and surfaces that cross tile columns and rows (up to 3x5 tiles); - confirms padding blocks outside the surface are never read and that `bytes`, `bytearray` and `memoryview` payloads give the same result; - confirms `ValueError` for non-positive dimensions (including an empty payload, which matches the zero tiles such sizes would need) and for payloads that are 16 bytes or one tile too short or too long. No tool behavior changes. The check pins the existing order; it does not re-derive it from the AMD swizzle tables linked in `docs/experiments.md`. Independent problem; it does not touch a shared interface. ## Verification Windows 11, Python 3.12, isolated venv, on top of `318d9c3` (after #348): ``` python -B tests/bc7_tiles_check.py Ran 6 tests OK python -B tests/bc7_blocks_check.py Ran 8 tests OK (skipped=1) python -B tests/bcpack_check.py Ran 8 tests OK python -B tests/resource_ranges_check.py Ran 17 tests OK python -B tests/docs_links_check.py Self-test passed. Checked 10 Markdown files and 81 links. python -B tests/bidi_controls_check.py Self-test passed. Checked 354 tracked files: no bidirectional controls. ``` The new check sits right after `bc7_blocks_check.py` in the Ubuntu job and in the `AGENTS.md` pure-Python list (the two lists stay identical, as #348 left them), and `bc7_tile_swizzle` is registered right after `bc7_block_reference` in CTest. Negative controls: - In the test itself: transposed bit tables, x2/x3 exchanged, the two tile columns of a payload exchanged, and one altered block in the second tile row (reported at block `(1, 16)`) are all detected. - Outside the PR, each of these in-memory mutations of `linearize_4k_s` made the check fail, and it passed again after restoring the original: tile pitch rounded down, tile row ignoring the pitch, x and y swapped inside a tile, size check accepting an extra tile, dimension check removed, row stride computed from the pixel width, y2/y3 exchanged in `_Y_BITS`, one wrong `_X_BITS` entry. The dimension-check mutant initially survived (a zero-tile size check still rejected a one-tile payload), which is why the empty-payload cases are included. CTest and the CI jobs were not run locally; the CMake entry mirrors `bcpack_prefix_and_mip_tail`. AI-assisted: prepared and submitted with the support of Roan System (AI-assisted development), reviewed before posting.
upstream-sync closed this pull request 2026-11-24 06:43:04 +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!439
No description provided.