startup: check the packed stand-in tag round trip #1546

Merged
Asimmimx merged 1 commit from upstream-pr/1553 into main 2026-11-24 16:22:02 +00:00
Asimmimx commented 2026-11-24 13:52:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T13:52:53Z.


Change

Refs #1149. This extends startup_packed_target, the device-free check for src/startup_stubs/packed_target_format.h. When an adapter cannot create a B5G5R5A1, B4G4R4A4 or B5G6R5 render target, the stand-in creates an R8G8B8A8 texture instead. mark_packed_stand_in then tags that texture with the requested format through SetPrivateData, and packed_stand_in_of reads the tag back so that packed_view can accept the packed view on the stand-in.

The selection rule (packed_target_stand_in) and the view verdicts (packed_view) are well covered. The tag round trip is not covered at all:

  • startup_packed_target calls the helpers only with literal arguments.
  • The draw tests never reach a stand-in on this machine. WARP and an RX 6600 both create all three packed formats as described (output below).

So three single-point mutants left every existing test passing:

  • storing the created format (28) instead of the requested one;
  • writing half the tag size;
  • packed_stand_in_of always returning DXGI_FORMAT_UNKNOWN.

This adds a fake ID3D12Resource that holds one private-data entry. Its GetPrivateData answers like a D3D12 object: the stored size, DXGI_ERROR_NOT_FOUND or DXGI_ERROR_MORE_DATA. It also adds 15 hand-worked rows. For each packed format:

  • a tagged R8G8B8A8 stand-in must read back 86, 115 or 85, and its view must be stand_in;
  • a texture created in the packed format must carry no tag and keep its view (unchanged);
  • an untagged R8G8B8A8 texture, and the other format's stand-in, must refuse the view.

tag joins the existing foreach(mutation ...) list as startup_packed_target_tag_control. That control reads every tag back as none and must fail (WILL_FAIL). There is no new executable. The rest of the change is two sentences in the existing "Checks" bullet of docs/startup-runtime.md.

Verification

Commit 309cfede (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_packed_target(_(stand-in|array|b565|view|tag)_control)?$|^startup_packed_target_draw_warp$' -V
#   7/7 passed; startup_packed_target PASS (77 rows); the tag control prints 6 FAILs, as intended

On an AMD Radeon RX 6600 (driver 32.0.21045.29003, run serially), the hardware draw also never reaches the stand-in:

hardware B5G5R5A1 render target with unordered access: texture format 86 (as described), read (115, 0, 206, 255)
hardware B4G4R4A4 render target: texture format 115 (as described), read (119, 0, 204, 255)
hardware B5G6R5 render target: texture format 85 (as described), read (115, 0, 206, 255)
startup_packed_target_draw_hardware ... Passed

WARP 10.0.26100.9818 also logs all three formats as described. 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, ran the tests, then reverted. None of this is committed.

Mutant Existing (startup_packed_target, 4 controls, draw_warp) With the new rows
control: the stand-in returns desc.Format killed killed
tag stores the created format (28) survived killed (6 rows)
tag any packed texture, not only R8G8B8A8 killed (draw_warp) killed
SetPrivateData size sizeof / 2 survived killed (6 rows)
packed_stand_in_of always UNKNOWN survived killed (6 rows)
packed_view drops resource_format == R8G8B8A8 survived survived (not pinned)
UAV requirement dropped killed killed
packed_target_format drops B4G4R4A4 killed killed
mark drops the packed_target_format(requested) check survived survived (not pinned)
packed_stand_in_of drops the size check survived survived (not pinned)

The three survivors cannot be reached by a real caller:

  • mark only tags R8G8B8A8 textures, so a tagged texture in another format never exists.
  • A tag of R8G8B8A8 never matches a packed view format, so the verdict is the same as with no tag.
  • Nothing else stores data under this GUID.

The fake's GetPrivateData follows the documented D3D12 behaviour. I did not compare it against a real resource.

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:6583336911 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1553). Originally posted by [Asimmimx](https://github.com/Asimmimx) on 2026-11-24T13:52:53Z. --- ## Change Refs #1149. This extends `startup_packed_target`, the device-free check for `src/startup_stubs/packed_target_format.h`. When an adapter cannot create a B5G5R5A1, B4G4R4A4 or B5G6R5 render target, the stand-in creates an R8G8B8A8 texture instead. `mark_packed_stand_in` then tags that texture with the requested format through `SetPrivateData`, and `packed_stand_in_of` reads the tag back so that `packed_view` can accept the packed view on the stand-in. The selection rule (`packed_target_stand_in`) and the view verdicts (`packed_view`) are well covered. The tag round trip is not covered at all: - `startup_packed_target` calls the helpers only with literal arguments. - The draw tests never reach a stand-in on this machine. WARP and an RX 6600 both create all three packed formats as described (output below). So three single-point mutants left every existing test passing: - storing the created format (28) instead of the requested one; - writing half the tag size; - `packed_stand_in_of` always returning `DXGI_FORMAT_UNKNOWN`. This adds a fake `ID3D12Resource` that holds one private-data entry. Its `GetPrivateData` answers like a D3D12 object: the stored size, `DXGI_ERROR_NOT_FOUND` or `DXGI_ERROR_MORE_DATA`. It also adds 15 hand-worked rows. For each packed format: - a tagged R8G8B8A8 stand-in must read back 86, 115 or 85, and its view must be `stand_in`; - a texture created in the packed format must carry no tag and keep its view (`unchanged`); - an untagged R8G8B8A8 texture, and the other format's stand-in, must refuse the view. `tag` joins the existing `foreach(mutation ...)` list as `startup_packed_target_tag_control`. That control reads every tag back as none and must fail (`WILL_FAIL`). There is no new executable. The rest of the change is two sentences in the existing "Checks" bullet of `docs/startup-runtime.md`. ## Verification Commit `309cfede` (`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_packed_target(_(stand-in|array|b565|view|tag)_control)?$|^startup_packed_target_draw_warp$' -V # 7/7 passed; startup_packed_target PASS (77 rows); the tag control prints 6 FAILs, as intended ``` On an AMD Radeon RX 6600 (driver 32.0.21045.29003, run serially), the hardware draw also never reaches the stand-in: ```text hardware B5G5R5A1 render target with unordered access: texture format 86 (as described), read (115, 0, 206, 255) hardware B4G4R4A4 render target: texture format 115 (as described), read (119, 0, 204, 255) hardware B5G6R5 render target: texture format 85 (as described), read (115, 0, 206, 255) startup_packed_target_draw_hardware ... Passed ``` WARP 10.0.26100.9818 also logs all three formats as described. `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, ran the tests, then reverted. None of this is committed. | Mutant | Existing (`startup_packed_target`, 4 controls, `draw_warp`) | With the new rows | |---|---|---| | control: the stand-in returns `desc.Format` | killed | killed | | tag stores the created format (28) | **survived** | killed (6 rows) | | tag any packed texture, not only R8G8B8A8 | killed (`draw_warp`) | killed | | `SetPrivateData` size `sizeof / 2` | **survived** | killed (6 rows) | | `packed_stand_in_of` always UNKNOWN | **survived** | killed (6 rows) | | `packed_view` drops `resource_format == R8G8B8A8` | survived | survived (not pinned) | | UAV requirement dropped | killed | killed | | `packed_target_format` drops B4G4R4A4 | killed | killed | | `mark` drops the `packed_target_format(requested)` check | survived | survived (not pinned) | | `packed_stand_in_of` drops the size check | survived | survived (not pinned) | The three survivors cannot be reached by a real caller: - `mark` only tags R8G8B8A8 textures, so a tagged texture in another format never exists. - A tag of R8G8B8A8 never matches a packed view format, so the verdict is the same as with no tag. - Nothing else stores data under this GUID. The fake's `GetPrivateData` follows the documented D3D12 behaviour. I did not compare it against a real resource. ## 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).
tedin7 commented 2026-11-24 16:03:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T15:54:21Z.

Review: COMMENTED


Technical review (Linux only: the test is Windows-flavoured C++, so it was built with MinGW and run under Wine; no Windows or GPU run was done).

Checked out the PR head (b50dfca3) in a clean tree. MinGW's d3d12.h declares ID3D12Resource::GetDesc as D3D12_RESOURCE_DESC* GetDesc(D3D12_RESOURCE_DESC*), not the by-value form the MSVC headers have, so startup_packed_target_check.cpp does not compile as is with MinGW. I verified on a ported copy (the fake resource's GetDesc signature and the one created->GetDesc().Format call in the header changed to the out-parameter form; nothing else). The logic under test is unchanged by the port.

What I ran:

  • Ported check: startup_packed_target: PASS (77 rows).
  • --mutate stand-in, array, b565, view, tag: each exits non-zero (16, 9, 6, 6 and 6 failing rows), so the new tag control also fails as the CMake WILL_FAIL entry expects.
  • Provenance rows read as intended: a tagged stand-in reads back its packed format and the packed view becomes stand_in; a texture created in the packed format carries no tag and its view stays unchanged; an untagged R8G8B8A8 texture refuses a packed view; a B5G5R5A1 view of a B4G4R4A4 stand-in is refused.

Local mutation check on packed_target_format.h (ported copy, each restored afterwards):

  • drop the GetDesc().Format == R8G8B8A8_UNORM condition in mark_packed_stand_in: caught.
  • store 1 byte instead of sizeof(requested): caught.
  • drop the bytes != sizeof(requested) check in packed_stand_in_of: not caught. No row gives the resource a tag of the wrong size.
  • drop the FAILED(...) check on GetPrivateData: not caught. With the output left at UNKNOWN the result is the same for an untagged texture.
  • drop the packed_target_format(requested) test in mark_packed_stand_in: not caught. No row calls it with a non-packed requested format on an R8G8B8A8 texture.

Suggestions (non-blocking): add a row where the fake resource holds a tag of a different size (for example one byte), and one where mark_packed_stand_in is called with a non-packed requested format on an R8G8B8A8 texture; both must stay untagged. That would pin the three guards above.

Docs: the new text in docs/startup-runtime.md matches what the test checks. It is worth keeping the wording that the behaviour was measured on the adapter tested, since this review could not confirm it on hardware.

No defects found.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6042694444 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1553#pullrequestreview-6042694444). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T15:54:21Z. **Review:** COMMENTED --- Technical review (Linux only: the test is Windows-flavoured C++, so it was built with MinGW and run under Wine; no Windows or GPU run was done). Checked out the PR head (b50dfca3) in a clean tree. MinGW's d3d12.h declares `ID3D12Resource::GetDesc` as `D3D12_RESOURCE_DESC* GetDesc(D3D12_RESOURCE_DESC*)`, not the by-value form the MSVC headers have, so `startup_packed_target_check.cpp` does not compile as is with MinGW. I verified on a ported copy (the fake resource's GetDesc signature and the one `created->GetDesc().Format` call in the header changed to the out-parameter form; nothing else). The logic under test is unchanged by the port. What I ran: - Ported check: `startup_packed_target: PASS (77 rows)`. - `--mutate stand-in`, `array`, `b565`, `view`, `tag`: each exits non-zero (16, 9, 6, 6 and 6 failing rows), so the new `tag` control also fails as the CMake WILL_FAIL entry expects. - Provenance rows read as intended: a tagged stand-in reads back its packed format and the packed view becomes `stand_in`; a texture created in the packed format carries no tag and its view stays `unchanged`; an untagged R8G8B8A8 texture refuses a packed view; a B5G5R5A1 view of a B4G4R4A4 stand-in is refused. Local mutation check on `packed_target_format.h` (ported copy, each restored afterwards): - drop the `GetDesc().Format == R8G8B8A8_UNORM` condition in `mark_packed_stand_in`: caught. - store 1 byte instead of `sizeof(requested)`: caught. - drop the `bytes != sizeof(requested)` check in `packed_stand_in_of`: **not caught**. No row gives the resource a tag of the wrong size. - drop the `FAILED(...)` check on `GetPrivateData`: **not caught**. With the output left at UNKNOWN the result is the same for an untagged texture. - drop the `packed_target_format(requested)` test in `mark_packed_stand_in`: **not caught**. No row calls it with a non-packed requested format on an R8G8B8A8 texture. Suggestions (non-blocking): add a row where the fake resource holds a tag of a different size (for example one byte), and one where `mark_packed_stand_in` is called with a non-packed requested format on an R8G8B8A8 texture; both must stay untagged. That would pin the three guards above. Docs: the new text in `docs/startup-runtime.md` matches what the test checks. It is worth keeping the wording that the behaviour was measured on the adapter tested, since this review could not confirm it on hardware. No defects found. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-24 17:01:34 +00:00
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!1546
No description provided.