startup: check the plane size families and shape bounds #1672

Merged
Asimmimx merged 1 commit from upstream-pr/1679 into main 2026-11-24 17:12:34 +00:00
Asimmimx commented 2026-11-24 16:58:32 +00:00 (Migrated from github.com)

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 of src/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 (plus startup_plane_size_packed_control) compares hand-worked sizes;
  • startup_plane_size_device_warp/_hardware goes through the wrapper. Its expectation is console_plane_size applied 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.md says 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:

Case Desktop answer handed in Expected What it pins
B8G8R8A8 (87) 1920x1080, 4 samples 0x2000000, 4 MiB 0x1FE0000 the 87-93 family at 4 bytes
R16G16B16A16 (10) 1920x1080, 4 samples 0x4000000, 4 MiB 0x3FC0000 (64 x 32 tiles at 32 bytes) 8 bytes a texel, not 4
d16s8 (118) 2560x1440, 4 samples failure 0x1CC0000 + 0xF00000 = 0x2BC0000 both planes scale with the sample count
d16s8 format 120, 2560x1440 failure 0xB40000 last of the console-only formats
d32s8 2048x2048, description alignment 64 KiB 0x2000000, 64 KiB 0x1400000 Alignment == 0x10000 is in the rule
rgba8 1x1, 4 samples 0x10000, 4 MiB 0x10000 same size, smaller alignment is still answered
first and last format of each colour family (1, 4, 9, 14, 23, 32, 38, 43, 53, 59, 60, 65, 93), 128x128, 4 samples 0x400000, 4 MiB 1 MiB / 512 / 256 / 128 / 64 KiB for 16 / 8 / 4 / 2 / 1 bytes each range end, and neighbouring families with different texel sizes give different sizes
d16s8 width 0, height 16385, 2049 slices failure left alone the shape's lower width bound and the height and array-size limits

The 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 of docs/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 (branch tests/plane-size-check on c864f138 main; merges cleanly with the current main). Environment: Windows 11 Pro build 26300, MSVC 19.51.36260 (Visual Studio), Windows SDK, dev preset (Debug).

cmake --preset dev
cmake --build --preset dev --target startup_plane_size_check
ctest --preset dev --no-tests=error -R '^startup_plane_size(_packed_control)?$' -V
#   2/2 passed
#   startup_plane_size: PASS (43 answered, 32 left alone)
#   startup_plane_size_packed_control: "startup_plane_size: 17 FAILED" (WILL_FAIL, so it passes)

tests/docs_links_check.py (16 Markdown files, 350 links), tests/bidi_controls_check.py and git diff --check passed. I did not run startup_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.

Mutant Existing check With the new cases
B8G8R8A8/B8G8R8X8 family (87-93) answers 0 bytes survived killed
B8G8R8A8 range starts at 88 survived killed
B8G8R8A8 range ends at 92 survived killed
R16G16B16A16 at 4 bytes a texel survived killed
d16s8 depth plane ignores the sample count survived killed
d16s8 stencil plane ignores the sample count survived killed
description alignment 64 KiB refused survived killed
replacement on a smaller alignment alone dropped survived killed
Height upper bound dropped survived killed
DepthOrArraySize upper bound dropped survived killed
Width >= 1 dropped survived killed
d16s8 range ends at 118 survived killed
R32G32B32A32 range starts at 2 / ends at 3 survived / survived killed / killed
R16G16B16A16 range starts at 10 / ends at 13 survived / survived killed / killed
R10G10B10A2..R8G8B8A8 range starts at 24 / ends at 31 survived / survived killed / killed
R16G16 range ends at 37 survived killed
R32 range ends at 42 survived killed
R16 range starts at 54 / ends at 58 survived / survived killed / killed
R16 range takes format 60 (R8 at 2 bytes) survived killed
R8/A8 range starts at 61 / ends at 64 survived / survived killed / killed
R32G8X24 range ends at 20 survived survived (not pinned)
R24G8 range ends at 45 survived survived (not pinned)
final 64 KiB round in plane_bytes dropped survived survived (equivalent)
d16s8 range starts at 119 killed killed
R32 range starts at 40 killed killed
tile width and height swapped killed killed
answered size cut to 32 bits killed killed
equal size kept (>= to >) killed killed
Width upper bound dropped killed killed
Height >= 1 dropped killed killed
desktop failure answered for every format killed killed
8 samples refused killed killed
tile padding rounds down killed killed

Three survivors are left unpinned on purpose:

  • Formats 21-22 (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.
  • The final + 0xFFFF & ~0xFFFF in plane_bytes is 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

  • 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.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6587068906 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1679). Originally posted by [Asimmimx](https://github.com/Asimmimx) on 2026-11-24T16:58:32Z. --- Refs #1149. ## Change This adds 22 cases to `startup_plane_size`, the device-free check of `src/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` (plus `startup_plane_size_packed_control`) compares hand-worked sizes; - `startup_plane_size_device_warp`/`_hardware` goes through the wrapper. Its expectation is `console_plane_size` applied 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.md` says 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: | Case | Desktop answer handed in | Expected | What it pins | |---|---|---|---| | B8G8R8A8 (87) 1920x1080, 4 samples | 0x2000000, 4 MiB | 0x1FE0000 | the 87-93 family at 4 bytes | | R16G16B16A16 (10) 1920x1080, 4 samples | 0x4000000, 4 MiB | 0x3FC0000 (64 x 32 tiles at 32 bytes) | 8 bytes a texel, not 4 | | d16s8 (118) 2560x1440, 4 samples | failure | 0x1CC0000 + 0xF00000 = 0x2BC0000 | both planes scale with the sample count | | d16s8 format 120, 2560x1440 | failure | 0xB40000 | last of the console-only formats | | d32s8 2048x2048, description alignment 64 KiB | 0x2000000, 64 KiB | 0x1400000 | `Alignment == 0x10000` is in the rule | | rgba8 1x1, 4 samples | 0x10000, 4 MiB | 0x10000 | same size, smaller alignment is still answered | | first and last format of each colour family (1, 4, 9, 14, 23, 32, 38, 43, 53, 59, 60, 65, 93), 128x128, 4 samples | 0x400000, 4 MiB | 1 MiB / 512 / 256 / 128 / 64 KiB for 16 / 8 / 4 / 2 / 1 bytes | each range end, and neighbouring families with different texel sizes give different sizes | | d16s8 width 0, height 16385, 2049 slices | failure | left alone | the shape's lower width bound and the height and array-size limits | The 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 of `docs/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` (branch `tests/plane-size-check` on `c864f138` `main`; merges cleanly with the current `main`). Environment: Windows 11 Pro build 26300, MSVC 19.51.36260 (Visual Studio), Windows SDK, `dev` preset (Debug). ```powershell cmake --preset dev cmake --build --preset dev --target startup_plane_size_check ctest --preset dev --no-tests=error -R '^startup_plane_size(_packed_control)?$' -V # 2/2 passed # startup_plane_size: PASS (43 answered, 32 left alone) # startup_plane_size_packed_control: "startup_plane_size: 17 FAILED" (WILL_FAIL, so it passes) ``` `tests/docs_links_check.py` (16 Markdown files, 350 links), `tests/bidi_controls_check.py` and `git diff --check` passed. I did not run `startup_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. | Mutant | Existing check | With the new cases | |---|---|---| | B8G8R8A8/B8G8R8X8 family (87-93) answers 0 bytes | **survived** | killed | | B8G8R8A8 range starts at 88 | **survived** | killed | | B8G8R8A8 range ends at 92 | **survived** | killed | | R16G16B16A16 at 4 bytes a texel | **survived** | killed | | d16s8 depth plane ignores the sample count | **survived** | killed | | d16s8 stencil plane ignores the sample count | **survived** | killed | | description alignment 64 KiB refused | **survived** | killed | | replacement on a smaller alignment alone dropped | **survived** | killed | | Height upper bound dropped | **survived** | killed | | DepthOrArraySize upper bound dropped | **survived** | killed | | `Width >= 1` dropped | **survived** | killed | | d16s8 range ends at 118 | **survived** | killed | | R32G32B32A32 range starts at 2 / ends at 3 | **survived** / **survived** | killed / killed | | R16G16B16A16 range starts at 10 / ends at 13 | **survived** / **survived** | killed / killed | | R10G10B10A2..R8G8B8A8 range starts at 24 / ends at 31 | **survived** / **survived** | killed / killed | | R16G16 range ends at 37 | **survived** | killed | | R32 range ends at 42 | **survived** | killed | | R16 range starts at 54 / ends at 58 | **survived** / **survived** | killed / killed | | R16 range takes format 60 (R8 at 2 bytes) | **survived** | killed | | R8/A8 range starts at 61 / ends at 64 | **survived** / **survived** | killed / killed | | R32G8X24 range ends at 20 | **survived** | **survived** (not pinned) | | R24G8 range ends at 45 | **survived** | **survived** (not pinned) | | final 64 KiB round in `plane_bytes` dropped | **survived** | **survived** (equivalent) | | d16s8 range starts at 119 | killed | killed | | R32 range starts at 40 | killed | killed | | tile width and height swapped | killed | killed | | answered size cut to 32 bits | killed | killed | | equal size kept (`>=` to `>`) | killed | killed | | Width upper bound dropped | killed | killed | | `Height >= 1` dropped | killed | killed | | desktop failure answered for every format | killed | killed | | 8 samples refused | killed | killed | | tile padding rounds down | killed | killed | Three survivors are left unpinned on purpose: - Formats 21-22 (`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. - The final `+ 0xFFFF & ~0xFFFF` in `plane_bytes` is 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 - [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. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-24 18:02:27 +00:00
tedin7 commented 2026-11-24 18:02:27 +00:00 (Migrated from github.com)

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 new answered cases and 3 new left_alone cases. 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).
  • Every expected size is a hand-worked constant, not computed by the code under test. I recomputed the main ones with an independent script (tile of 64 KiB, pad each plane, round up): B8G8R8A8 1920x1080 x4 = 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.
  • The --mutate packed control still fails (17 failures), and the two new d16s8 multisample/120 cases use pad(), so the control now bites on them too.
  • The 3 new refused shapes (width 0, height 16385, 2049 slices) hit three different clauses of 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.
  • Added lines are plain ASCII.

Checks on Linux (g++ 17, -Wall -Wextra, no warnings). d3d12.h does 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):

  • PR test: PASS (43 answered, 32 left alone). Merge-base test: PASS (24, 29).
  • 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.
  • No temp files or processes: the check is pure arithmetic.

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):

  • Equivalent mutants: 23->22 (22 is already taken by the d32s8 branch), 43->44 (same for d24s8), 60->59 (the 53-59 range answers first), the final round-up (planes are already whole tiles), and samples > 1 -> >= 1 (same size as desktop for valid answers).
  • Unpinned edges just outside a family: formats 0, 5, 8, 15, 52, 66, 86 and 94, plus the upper ends of the d32s8 (22) and d24s8 (47) ranges. A follow-up could add one refused-format case for each, and a couple of these would tighten the "first and last format" claim into "and nothing next to them".

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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6043885459 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1679#pullrequestreview-6043885459). Originally posted by [tedin7](https://github.com/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 new `answered` cases and 3 new `left_alone` cases. 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). - Every expected size is a hand-worked constant, not computed by the code under test. I recomputed the main ones with an independent script (tile of 64 KiB, pad each plane, round up): B8G8R8A8 1920x1080 x4 = `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. - The `--mutate packed` control still fails (17 failures), and the two new d16s8 multisample/120 cases use `pad()`, so the control now bites on them too. - The 3 new refused shapes (width 0, height 16385, 2049 slices) hit three different clauses of `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. - Added lines are plain ASCII. Checks on Linux (g++ 17, `-Wall -Wextra`, no warnings). `d3d12.h` does 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): - PR test: PASS (43 answered, 32 left alone). Merge-base test: PASS (24, 29). - `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. - No temp files or processes: the check is pure arithmetic. 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): - Equivalent mutants: 23->22 (22 is already taken by the d32s8 branch), 43->44 (same for d24s8), 60->59 (the 53-59 range answers first), the final round-up (planes are already whole tiles), and `samples > 1` -> `>= 1` (same size as desktop for valid answers). - Unpinned edges just outside a family: formats 0, 5, 8, 15, 52, 66, 86 and 94, plus the upper ends of the d32s8 (22) and d24s8 (47) ranges. A follow-up could add one refused-format case for each, and a couple of these would tighten the "first and last format" claim into "and nothing next to them". 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.
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!1672
No description provided.