textures: check the BC7 4 KiB standard detile order #1445
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1452"
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 R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T11:47:21Z.
Change
Refs #1149. This adds a device-free check for
src/startup_stubs/bc7_4k_s.h:supports_bc7_4k_s, the padded sizes ofBc16Surface,block_offset(the GFX10 4 KiB standard non-XOR 16-byte ordery0 y1 x0 x1 y2 x2 y3 x3) anddetile.The existing tests reach the header through three paths:
startup_xg_bc7_layoutcompares the copy with an independent bit-order oracle, but only at 81x69 and 64x64. Those are square tile grids (2x2 and 1x1), and the test uses accepted descriptions only.startup_xg_bc7_draw_warptiles and detiles with the sameblock_offset, so on its own it cannot see a wrong order.startup_address_bc_view_warpalso callsdetile.As a result:
block_offsetthat multiplies the tile row bytile_rowsinstead oftile_columnspassed every existing CPU and WARP test. That multiplier misplaces blocks on any non-square tile grid.supports_bc7_4k_swith theMipLevels == 1or theAlignment == 0condition dropped also passed.startup_bc7_4k_sincludes only the header. Its expected offsets come from a table of the documented(axis, bit)order and from 16 offsets worked out by hand, not from the header's shifts and masks. It checks:detileat tight, +48 and +256 row pitches, with 64-byte guards. The row gaps must stay untouched and the source must not change;Bc16Surface(desc);Widthof 2^32 + 64.startup_bc7_4k_s_x_first_controlruns--mutate x-first, which expects an x-first Morton order, and must fail (WILL_FAIL).The change is test, CMake and
docs/startup-runtime.mdonly. The header and the device code are unchanged. The CMake block sits after thestartup_plane_size_deviceregistration, so it merges cleanly with #1447 and #1450.Verification
Commit
92bd3362(main) plus this change,devpreset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260, Windows SDK 10.0.26100.0.tests/docs_links_check.pyandtests/bidi_controls_check.pypassed. addrlib was not configured on this build, but none of these tests need it.Mutation probe
I applied each mutation to the header alone, rebuilt
startup_stub_xg_xsandstartup_stream_consumer, ran the tests, then reverted. None of this is committed. "Existing" meansstartup_xg_bc7_layout,startup_xg_bc7_draw_warp,startup_xg_bc_tiling,startup_xg_bc_chain_warp,startup_xg_bc_array_warpandstartup_address_bc_view_warp.startup_bc7_4k_s(y&4)<<2↔(x&4)<<3tile_rowsrounding removedpadded_row_byteswithblock_texelsMipLevels == 1droppeddetileignoresrow_pitch* tile_rowsinstead of* tile_columnsAlignment == 0droppedChecklist
AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T12:01:15Z.
I reproduced both mutations you describe, and the new check is the only one that catches them
Independent reviewer, not the author. I did not push anything to the branch; the mutations below were made locally,
rebuilt, then reverted, and the working tree is clean.
Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100, DXC 1.8.2502.11, commit
e7504862.Unmodified branch — 5 of 5 pass (
startup_bc7_4k_s0.17 s,_x_first_control0.02 s,startup_xg_bc7_layout0.47 s,startup_xg_bc7_draw_warp4.93 s,startup_address_bc_view_warp6.05 s).Mutation 1 — tile row multiplied by
tile_rowsinstead oftile_columnsMutation 2 —
desc.Alignment == 0dropped fromsupports_bc7_4k_sSo the gap you describe is real at this commit: with either mutation the three older checks still pass, and the new
device-free check is the one that reports a first mismatch. That is the property I would want from a new fixture, and it
is worth having in the log for the reason you give — the existing layout test only sees square tile grids (2x2 and 1x1),
and
detileis exercised by tests that tile with the sameblock_offset.Two small notes, neither blocking
startup_bc7_4k_s_x_first_controlstays green under both mutations, which is correct for a control but means areader skimming the ctest list could take it for coverage of the order. One line in the test's own output naming what
it is a control for would remove that.
startup_xg_bc7_layout, the order bug would fail the older check too and thenew fixture would stop being the sole reporter. Your call — the current split is defensible and the new check is
device-free, which is what makes it run everywhere.
Verdict
Reviewed
e7504862. Builds clean, the new checks pass, both negative controls behave as claimed, and the CMake wiring istwo
add_testlines plus the target. No objection from me.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T12:06:49Z.
Review: COMMENTED
Dual-platform peer review at commit
e75048628440ab801ffab7ec63d27f63ab4a47b3.Audit
tests/startup_bc7_4k_s_check.cpp,CMakeLists.txt,docs/startup-runtime.md:src/startup_stubs/bc7_4k_s.h(supports_bc7_4k_s,Bc16Surfacepadded dimensions/sizes,block_offset, anddetile) using a table-driven bit-order oracle (y0 y1 x0 x1 y2 x2 y3 x3) and hand-worked offsets without reusing the header's bit shifts.200x72,72x200), 32-bit width truncation (2^32 + 64), 24 single-field refusal cases, pitcheddetilewith0xa5guard bands on both ends and row gaps, and a--mutate x-firstnegative control (startup_bc7_4k_s_x_first_control,WILL_FAIL TRUE).git diff --check origin/main..HEAD: clean.python3 tests/docs_links_check.py: passed (16 Markdown files, 324 links).python3 tests/bidi_controls_check.py: passed (1186 files).Verification on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)
--preset dev):cmake --build --preset dev --target startup_bc7_4k_s_check -- -j 6):4.14sctest --preset dev -R '^(startup_bc7_4k_s|startup_bc7_4k_s_x_first_control|startup_xg_bc7_layout|startup_xg_bc7_draw_warp|startup_address_bc_view_warp)$' --parallel 4 --no-tests=error --output-on-failure): 5/5 passed (startup_bc7_4k_s0.02s,startup_bc7_4k_s_x_first_control0.02s,startup_xg_bc7_layout0.16s,startup_xg_bc7_draw_warp3.13s,startup_address_bc_view_warp4.05s)/O2(--preset release):cmake --build --preset release --target startup_bc7_4k_s_check -- -j 6):1.56sctest --preset release -R '^(startup_bc7_4k_s|startup_bc7_4k_s_x_first_control|startup_xg_bc7_layout|startup_xg_bc7_draw_warp|startup_address_bc_view_warp)$' --parallel 4 --no-tests=error --output-on-failure): 5/5 passed (startup_bc7_4k_s0.02s,startup_bc7_4k_s_x_first_control0.01s,startup_xg_bc7_layout0.14s,startup_xg_bc7_draw_warp3.21s,startup_address_bc_view_warp4.16s)