textures: harden bool/integer and byte-type bounds in texture_blocks with standalone unit suite #2884
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!2884
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2884"
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?
@Ammmae0x on GitHub · 2026-11-26 16:23 UTC · original
Ammmae0x:textures/texture-blocks-check→main· +317 −13 · 3 files · 1 commits · merged 2026-11-27 08:34 UTCChange
Harden integer, boolean, and byte-type validation in
tools/texture_blocks.pyand add a standalone unit, bounds-guard, and mutation test suite (tests/texture_blocks_check.py, registered viatests/cmake/textures_texture_blocks.cmake).booland non-intvalues forwidth,height,depth, andpitch_blockswithValueErroracross_grid,surface_bytes,linearize_blocks,tile_blocks,tile_volume_4k_s, andlinearize_volume_4k_s, and reject non-strformat names cleanly informat_info.paddingintile_blocksisbytes,bytearray, or a 1-D byte (format == "B")memoryviewof exactblock_byteslength.FORMATSentries and 2D/3D block round-trip behavior.Verification
Commit:
e710e909(Windows 11 x64,out\pe-env\Scripts\python.exe -B):out\pe-env\Scripts\python.exe -B tests\texture_blocks_check.py -v-> 6/6 tests OK (BC1..BC7 2D & BC7_UNORM_VOLUME 3D round-trips, non-multiple-of-4 dimensions, paddedpitch_blocks,bytes/bytearray/memoryviewpadding, bool/non-int/zero/negative/narrow-pitch/format-mismatch refusals, and 5 fast mutations).out\pe-env\Scripts\python.exe -B tests\bc7_tiles_check.py-> 6/6 tests OK.out\pe-env\Scripts\python.exe -B tests\gfx10_texture_roundtrip_check.py-> 6/6 tests OK (PASS).out\pe-env\Scripts\python.exe -B tests\texture_bc_volume_check.py-> 11/11 tests OK.out\pe-env\Scripts\python.exe -B tests\form_coverage_check.py-> passed (exit 0).out\pe-env\Scripts\python.exe -B tests\docs_links_check.py-> passed (29 Markdown files, 545 links, exit 0).out\pe-env\Scripts\python.exe -B tests\bidi_controls_check.py-> passed (2048 files, exit 0).boolcheck in_require_int, relaxing thememoryviewformat == "B"check intile_blocks, and disabling thepitch < columnscheck insurface_bytesone-by-one each causedtests\texture_blocks_check.pyto fail (exit 1).Evidence and follow-up
All fixtures are deterministic synthetic BC block payloads generated in memory by
tests/texture_blocks_check.py; zero external or game files are used.Checklist
AI-assisted.
@R0Y00 on GitHub · 2026-11-27 08:34 UTC · original · approved these changes
Reviewed
e710e909onmain3b6c38a8. The new integer guards cover dimensions and pitch before the block arithmetic. The padding path normalizes supported byte buffers and checks an exact one-block length. Existing tight and pitched output paths still round-trip.Independent Windows Python 3.12 runs of
tests/texture_blocks_check.py,tests/bc7_tiles_check.py,tests/gfx10_texture_roundtrip_check.py,tests/texture_bc_volume_check.pyandtests/bcpack_check.pypassed all 39 tests. The new suite includes direct input-refusal and mutation controls.git diff --checkwas clean. Hosted Windows, Linux Python and gfx1013 checks passed.