startup: check the plane size families and shape bounds #1672
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1679"
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-24T16:58:32Z.
Refs #1149.
Change
This adds 22 cases to
startup_plane_size, the device-free check ofsrc/startup_stubs/console_plane_size.h. That header answers the console allocation size for two texture families where the desktop answer is larger. Depth with stencil formats (19-22, 44-47 and the console-only 118-120) are sized as a depth plane plus a 1-byte stencil plane. Multisampled colour formats in eight families get every plane padded to whole 64 KiB tiles at 64 KiB alignment. The header only handles a validated 2D shape and keeps a valid desktop answer unless the console size or alignment is smaller.Two tests reach the header today:
startup_plane_size(plusstartup_plane_size_packed_control) compares hand-worked sizes;startup_plane_size_device_warp/_hardwaregoes through the wrapper. Its expectation isconsole_plane_sizeapplied to the adapter's own answer, so a mutant of the header changes the expectation and the wrapper's answer together. It cannot catch a wrong size or a wrong format range.docs/startup-runtime.mdsays the reference sizes cover the added colour families, including B8G8R8A8/B8G8R8X8 (87-93). The check had no format from that family, used one or two formats inside each other colour family, and had no multisampled 16-bit depth with stencil. Its only R16G16B16A16 case (64 x 64, two samples, three slices) gives the same size at 4 bytes a texel as at 8. 28 of 38 single-point mutants of the header left the check passing (table below).New hand-worked cases:
Alignment == 0x10000is in the ruleThe change touches only
tests/startup_plane_size_check.cpp, where it adds cases and changes no existing case, and three lines in the "Allocation sizes for depth with stencil and multisampled textures" section ofdocs/startup-runtime.md. There is no CMake change. The new cases whose sizes are not whole tiles also take the packed expectation under--mutate packed, so the existing negative control now fails on 17 cases instead of 13.Verification
Commit
1f5d0bac(branchtests/plane-size-checkonc864f138main; merges cleanly with the currentmain). Environment: Windows 11 Pro build 26300, MSVC 19.51.36260 (Visual Studio), Windows SDK,devpreset (Debug).tests/docs_links_check.py(16 Markdown files, 350 links),tests/bidi_controls_check.pyandgit diff --checkpassed. I did not runstartup_plane_size_device_*. This change does not touch it or the header, and its expectation comes from the header itself.Mutation probe
I applied each mutation to the header alone, rebuilt
startup_plane_size_check, ran it, then reverted. None of this is committed.Width >= 1droppedplane_bytesdropped>=to>)Height >= 1droppedThree survivors are left unpinned on purpose:
R32_FLOAT_X8X24_TYPELESS,X32_TYPELESS_G8X24_UINT) and 46-47 (R24_UNORM_X8_TYPELESS,X24_TYPELESS_G8_UINT) are view formats. The docs list them inside the families, but I have not shown that a resource description with them reaches the allocation query with a valid desktop answer. After a desktop failure they are already left alone either way.+ 0xFFFF & ~0xFFFFinplane_bytesis an equivalent mutant. The padded width times the padded height times the bytes is always a whole number of 64 KiB tiles, so the round cannot change the result.The format just past each family (for example 15, R32G32 at 8 bytes, or 86, B5G5R5A1) is not pinned either way. Whether those should be answered is a question about the rule, not about this check.
Checklist
AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:08:54Z.
Review: COMMENTED
Review for head
1f5d0bac(comment only, no approval).Verdict: no blocking findings. The PR only adds cases and one doc paragraph, and I found nothing weakened or tautological.
Read line by line:
tests/startup_plane_size_check.cpp: 19 newansweredcases and 3 newleft_alonecases. No existing case is removed, reordered or loosened. The PASS line moves from 24/29 to 43/32, which matches what is added (24+19, 29+3).0x1FE0000, R16G16B16A16 1920x1080 x4 =0x3FC0000, d16s8 2560x1440 x4 =0x2BC0000, format 120 =0xB40000, d32s8 at 64 KiB alignment =0x1400000, and the five 128x128 x4 sizes (1 MiB down to 64 KiB). All agree.--mutate packedcontrol still fails (17 failures), and the two new d16s8 multisample/120 cases usepad(), so the control now bites on them too.console_plane_shape, each with desktop{~0ull, 0}so only the shape check can refuse them.docs/startup-runtime.md: the new sentence matches the code and the test (first and last format of each multisampled colour family, B8G8R8A8 1920x1080, format 118 with 4 samples, format 120, 64 KiB alignment, desktop answer of equal size at 4 MiB alignment, the three refused shapes). The Windows claims in the paragraph are unchanged and I cannot check them on Linux.Checks on Linux (g++ 17,
-Wall -Wextra, no warnings).d3d12.hdoes not exist here, so I compiled the unmodified PR test and header against a small scratch stand-in header (the few structs, enums and two constants used; kept outside the repo):git diff --check: clean.python3 -I tests/docs_links_check.py: self-test passed, 16 files, 350 links.python3 -I tests/bidi_controls_check.py: self-test passed, 1277 files, none found.Mutation checks I actually ran: 64 single-point mutants of
src/startup_stubs/console_plane_size.h, built against the merge-base test and the PR test. The merge-base test passes 33 of the 60 mutants I had not labelled equivalent beforehand; the PR test passes 15 (most of those 15 turn out equivalent, see below), so 18 more are now killed. Examples now killed: dropping the whole 87-93 family; R16G16B16A16 at 4 bytes; the upper end of the 23-32, 33-38, 39-43, 53-59, 60-65 and 87-93 ranges, and the lower end of 87-93; d16s8 depth or stencil ignoring the sample count; format 120 dropped; 64 KiB description alignment refused; the alignment-only replacement dropped; the height, slice and zero-width checks dropped.Survivors with the PR test (none is caused by this PR, so not a request for changes):
samples > 1->>= 1(same size as desktop for valid answers).Limits: Linux only, with the stand-in header, so the Windows build, the
startup_plane_size_device_*tests and the full ctest suite were not run. I did not change any CMake line (this PR has none).AI-assisted; commands listed were executed locally.