startup: check the slice footprint plan and re-read rules #1479

Merged
Asimmimx merged 1 commit from upstream-pr/1486 into main 2026-11-24 13:06:53 +00:00
Asimmimx commented 2026-11-24 12:45:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T12:45:58Z.


Change

Refs #1149. This adds a device-free check for src/startup_stubs/slice_footprints.h. The header is used by:

  • the XG stand-in (xg_xs.cpp): layout, copy-into, and supports() in XGCreateTextureComputer;
  • the draw uploader in d3d12_draw.inl.

It is reached today through startup_nv12_draw, startup_plane_refresh, the startup_xg_bc* checks and the stream-consumer WARP draws. I probed it against 20 CPU and WARP tests (listed below). 10 of 14 single-point mutants left all 20 passing. The survivors were all in the re-read checks, supports(), the constructor's mip limit and null-device guard, and the byte span of the last row. The upload() mutants were all caught, so this check leaves upload() out.

startup_slice_footprints includes only the header and has 51 cases with hand-worked expected values. For example:

  • R8 17x3 at pitch 256 spans 529 bytes;
  • 4 slices of 2 rows at pitch 512 span 3,904 bytes;
  • 16,384 rows of 256 KiB span exactly 2^32 bytes.

GetCopyableFootprints comes from a stand-in device: a method table whose slot 38 records the call. Slot 38 is the position of GetCopyableFootprints in ID3D12DeviceVtbl; d3d12_xs_device.cpp names it "Device slot 38". Every other slot fails the test. This keeps the constructor cases independent of the adapter. A null device is also checked, because XG's copy-into builds a plan before it tests the device.

startup_slice_footprints_padded_control runs --mutate padded-last-row, which expects the full row pitch for the last row, and must fail (WILL_FAIL).

The change is test, CMake and docs/startup-runtime.md only. The CMake block follows the startup_plane_refresh/startup_nv12_draw registrations, apart from the other open #1149 PRs.

Verification

Commit 93672b99 (main) plus this change, dev preset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260, Windows SDK 10.0.26100.0.

ctest --preset dev --no-tests=error -R '^startup_slice_footprints' -V
#   startup_slice_footprints ... Passed (PASS (51 cases))
#   startup_slice_footprints_padded_control ... Passed (5 cases fail, as the control intends)

tests/docs_links_check.py, tests/bidi_controls_check.py and git diff --check passed.

Mutation probe

I applied each mutation to the header alone, rebuilt the affected binaries, ran the tests, then reverted. None of this is committed. "Existing" means these 20 tests:

  • startup_{plane_refresh,nv12_draw,stream_request,stream_draw,mrt_fxc,mrt_dxc,logical_view,xg_bc7_draw,slot57_blend_draw,packed_target_draw,address_srv,placed_vertex,address_bc_view,xg_bc_chain,xg_bc_array}_warp;
  • startup_xg_bc_tiling and startup_xg_bc7_layout;
  • cpu_shim_{draw,texture_reuse,upload_texture}_warp.

On the unmodified header 19 pass and startup_logical_view_warp skips (77).

Mutant Existing startup_slice_footprints
control: SubresourceIndex = 0 killed (nv12_draw, xg_bc_chain, xg_bc_array) n/a
re-read: 32 MiB cap <= → < survived fails
re-read: MipLevels == 1 dropped survived fails
re-read: DepthOrArraySize == 1 dropped survived fails
supports: odd-width check dropped survived fails
supports: NV12 MipLevels == 1 dropped survived fails
supports: SampleDesc.Count == 1 dropped survived fails
supports: Width && Height dropped survived fails
constructor: mips <= max_mips → < (refuses 15 mips) survived fails
constructor: device && guard dropped survived fails (access violation)
bytes: full row pitch for the last row (over-read) survived fails
bytes: + row_bytes dropped (short last row) killed (5 WARP draws) fails
upload: placed offset instead of the ring offset killed (address_srv, address_bc_view, xg_bc_array) not covered
upload: slice stride slice * slices killed (xg_bc_array) not covered
upload: mip and plane swapped killed (xg_bc_chain, xg_bc_array) not covered

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:6582093211 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1486). Originally posted by [Asimmimx](https://github.com/Asimmimx) on 2026-11-24T12:45:58Z. --- ## Change Refs #1149. This adds a device-free check for `src/startup_stubs/slice_footprints.h`. The header is used by: - the XG stand-in (`xg_xs.cpp`): layout, copy-into, and `supports()` in `XGCreateTextureComputer`; - the draw uploader in `d3d12_draw.inl`. It is reached today through `startup_nv12_draw`, `startup_plane_refresh`, the `startup_xg_bc*` checks and the stream-consumer WARP draws. I probed it against 20 CPU and WARP tests (listed below). 10 of 14 single-point mutants left all 20 passing. The survivors were all in the re-read checks, `supports()`, the constructor's mip limit and null-device guard, and the byte span of the last row. The `upload()` mutants were all caught, so this check leaves `upload()` out. `startup_slice_footprints` includes only the header and has 51 cases with hand-worked expected values. For example: - R8 17x3 at pitch 256 spans 529 bytes; - 4 slices of 2 rows at pitch 512 span 3,904 bytes; - 16,384 rows of 256 KiB span exactly 2^32 bytes. `GetCopyableFootprints` comes from a stand-in device: a method table whose slot 38 records the call. Slot 38 is the position of `GetCopyableFootprints` in `ID3D12DeviceVtbl`; `d3d12_xs_device.cpp` names it "Device slot 38". Every other slot fails the test. This keeps the constructor cases independent of the adapter. A null device is also checked, because XG's copy-into builds a plan before it tests the device. `startup_slice_footprints_padded_control` runs `--mutate padded-last-row`, which expects the full row pitch for the last row, and must fail (`WILL_FAIL`). The change is test, CMake and `docs/startup-runtime.md` only. The CMake block follows the `startup_plane_refresh`/`startup_nv12_draw` registrations, apart from the other open #1149 PRs. ## Verification Commit `93672b99` (`main`) plus this change, `dev` preset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260, Windows SDK 10.0.26100.0. ```powershell ctest --preset dev --no-tests=error -R '^startup_slice_footprints' -V # startup_slice_footprints ... Passed (PASS (51 cases)) # startup_slice_footprints_padded_control ... Passed (5 cases fail, as the control intends) ``` `tests/docs_links_check.py`, `tests/bidi_controls_check.py` and `git diff --check` passed. ## Mutation probe I applied each mutation to the header alone, rebuilt the affected binaries, ran the tests, then reverted. None of this is committed. "Existing" means these 20 tests: - `startup_{plane_refresh,nv12_draw,stream_request,stream_draw,mrt_fxc,mrt_dxc,logical_view,xg_bc7_draw,slot57_blend_draw,packed_target_draw,address_srv,placed_vertex,address_bc_view,xg_bc_chain,xg_bc_array}_warp`; - `startup_xg_bc_tiling` and `startup_xg_bc7_layout`; - `cpu_shim_{draw,texture_reuse,upload_texture}_warp`. On the unmodified header 19 pass and `startup_logical_view_warp` skips (77). | Mutant | Existing | `startup_slice_footprints` | |---|---|---| | control: `SubresourceIndex = 0` | killed (nv12_draw, xg_bc_chain, xg_bc_array) | n/a | | re-read: 32 MiB cap `<=` → `<` | survived | fails | | re-read: `MipLevels == 1` dropped | survived | fails | | re-read: `DepthOrArraySize == 1` dropped | survived | fails | | `supports`: odd-width check dropped | survived | fails | | `supports`: NV12 `MipLevels == 1` dropped | survived | fails | | `supports`: `SampleDesc.Count == 1` dropped | survived | fails | | `supports`: `Width && Height` dropped | survived | fails | | constructor: `mips <= max_mips` → `<` (refuses 15 mips) | survived | fails | | constructor: `device &&` guard dropped | survived | fails (access violation) | | bytes: full row pitch for the last row (over-read) | survived | fails | | bytes: `+ row_bytes` dropped (short last row) | killed (5 WARP draws) | fails | | `upload`: placed offset instead of the ring offset | killed (address_srv, address_bc_view, xg_bc_array) | not covered | | `upload`: slice stride `slice * slices` | killed (xg_bc_array) | not covered | | `upload`: mip and plane swapped | killed (xg_bc_chain, xg_bc_array) | not covered | ## 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 14:02:52 +00:00
tedin7 commented 2026-11-24 14:02:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T13:04:44Z.

Review: COMMENTED


Peer review of PR #1486 (0468663422ef91cb3c82dc06819eb4325f0281cd).

Code & Diff Audit

  • Scope: Focused to CMakeLists.txt, docs/startup-runtime.md, and tests/startup_slice_footprints_check.cpp; src/startup_stubs/slice_footprints.h is untouched.
  • Correctness & Edge Cases:
    • SliceFootprints::supports(): tests odd 3D/array non-NV12 textures, valid even 2D single-mip/single-layer/single-sample NV12 sizes, and 12 rejected NV12 variants (odd/zero dimensions, >1/0 mips, >1/0 layers, >1 samples, 3D/1D/buffer).
    • recheck_cpu_texture(): tests 1-frame vs 15-frame thresholds (R8 single-plane vs multi-mip/array/R8G8/RGBA8) and the inclusive 32 MiB byte cap.
    • Constructor & fake ID3D12Device: traps all vtable slots except slot 38 (GetCopyableFootprints), verifies exact first=0, base=0, count=mips*planes, output pointer wiring, mip limit (1..15, rejecting 0 and 16), invalid NV12 rejection, and null-device safety.
    • bytes(): checks last-row unpadded byte span across 2D, NV12 chroma, index 29, multi-slice 3D, and a 2^32 (4 GiB) 64-bit span.
    • --mutate padded-last-row negative control (startup_slice_footprints_padded_control, WILL_FAIL TRUE) confirms full-pitch last-row expectations fail as intended.
  • Hygiene: tests/docs_links_check.py, tests/bidi_controls_check.py, and git diff --check origin/main...HEAD all pass on Linux. Title-neutral.

Win2025 Verification

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 0468663422ef91cb3c82dc06819eb4325f0281cd:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target startup_slice_footprints_check -- -j 6): 3.94s (configure 1.79s)
    • Test (ctest --preset dev -R '^startup_slice_footprints' --parallel 4 --no-tests=error --output-on-failure): 2/2 passed (0.09s: startup_slice_footprints 0.02s, startup_slice_footprints_padded_control 0.01s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target startup_slice_footprints_check -- -j 6): 1.38s (configure 1.70s)
    • Test (ctest --preset release -R '^startup_slice_footprints' --parallel 4 --no-tests=error --output-on-failure): 2/2 passed (0.08s: startup_slice_footprints 0.01s, startup_slice_footprints_padded_control 0.01s)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6039687660 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1486#pullrequestreview-6039687660). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T13:04:44Z. **Review:** COMMENTED --- Peer review of PR #1486 (`0468663422ef91cb3c82dc06819eb4325f0281cd`). ### Code & Diff Audit - **Scope**: Focused to `CMakeLists.txt`, `docs/startup-runtime.md`, and `tests/startup_slice_footprints_check.cpp`; `src/startup_stubs/slice_footprints.h` is untouched. - **Correctness & Edge Cases**: - `SliceFootprints::supports()`: tests odd 3D/array non-NV12 textures, valid even 2D single-mip/single-layer/single-sample NV12 sizes, and 12 rejected NV12 variants (odd/zero dimensions, >1/0 mips, >1/0 layers, >1 samples, 3D/1D/buffer). - `recheck_cpu_texture()`: tests 1-frame vs 15-frame thresholds (R8 single-plane vs multi-mip/array/R8G8/RGBA8) and the inclusive 32 MiB byte cap. - Constructor & fake `ID3D12Device`: traps all vtable slots except slot 38 (`GetCopyableFootprints`), verifies exact `first=0`, `base=0`, `count=mips*planes`, output pointer wiring, mip limit (`1..15`, rejecting `0` and `16`), invalid NV12 rejection, and null-device safety. - `bytes()`: checks last-row unpadded byte span across 2D, NV12 chroma, index 29, multi-slice 3D, and a `2^32` (4 GiB) 64-bit span. - `--mutate padded-last-row` negative control (`startup_slice_footprints_padded_control`, `WILL_FAIL TRUE`) confirms full-pitch last-row expectations fail as intended. - **Hygiene**: `tests/docs_links_check.py`, `tests/bidi_controls_check.py`, and `git diff --check origin/main...HEAD` all pass on Linux. Title-neutral. ### Win2025 Verification Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `0468663422ef91cb3c82dc06819eb4325f0281cd`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target startup_slice_footprints_check -- -j 6`): `3.94s` (configure `1.79s`) - Test (`ctest --preset dev -R '^startup_slice_footprints' --parallel 4 --no-tests=error --output-on-failure`): **2/2 passed** (`0.09s`: `startup_slice_footprints` `0.02s`, `startup_slice_footprints_padded_control` `0.01s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target startup_slice_footprints_check -- -j 6`): `1.38s` (configure `1.70s`) - Test (`ctest --preset release -R '^startup_slice_footprints' --parallel 4 --no-tests=error --output-on-failure`): **2/2 passed** (`0.08s`: `startup_slice_footprints` `0.01s`, `startup_slice_footprints_padded_control` `0.01s`)
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!1479
No description provided.