cpu: test XG swizzle mode selection and texture computer layout #1027

Merged
Holastor merged 1 commit from upstream-pr/1034 into main 2026-11-23 22:51:32 +00:00
Holastor commented 2026-11-23 22:18:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-23T22:18:26Z.


Refs #870.
Refs #1032.

This fixture provides the PE loader, refusal sentinel, and import-withholding test angle for the swizzle mode selection and texture computer layout integration in xg_xs.dll, alongside #1032 (whose full 8-mip 21,845-texel layout reference uses pinned PC AddrLib from #979):

  • XGSuggestSwizzleMode(desc, flags, out_layout): evaluates resource descriptors and suggests swizzle layouts.
  • XGCreateTextureComputer(desc, out_computer): instantiates an address computer (IXGTextureComputer) for subresource layout, texel address calculation, and tiling/detiling copy operations.

Scope & Call Sequence

Public call shape follows DirectXTex usage and public GDK issue references (DirectXTex #498):

  1. XGSuggestSwizzleMode evaluates a D3D12_RESOURCE_DESC with an unknown input layout (D3D12_TEXTURE_LAYOUT_UNKNOWN = 0) and selector flag 0.
  2. The caller exercises both a separate output pointer and an output pointer aliased to the descriptor's own Layout field (&desc.Layout), verifying both produce matching layout results (0x105 per fixture policy).
  3. The resulting descriptor is passed to XGCreateTextureComputer.
  4. CopyIntoSubresource uploads a generated 3-mip RGBA8 texture (28x4, 14x2, 7x1 = 147 texels) into tiled memory.
  5. CopyFromSubresource detiles all 147 texels back to linear memory with 100% round-trip fidelity.
  6. The small 147-texel Morton round-trip serves as an additional synthetic caller/provider check (disagreeing on 139 of 147 texels under Morton bit-interleaving and agreeing on 8). It is a caller/provider handshake check only, not an independent match to #979 and not evidence of console layout encoding.
  7. A linear control with Layout = 1 (ROW_MAJOR) verifies 0 disagreements against linear layout.

Contract boundaries & Qualifications

  • Established call shape: XGSuggestSwizzleMode(desc, 0, &out) with separate and aliased output pointers, feeding the resulting layout into XGCreateTextureComputer(desc, &comp) for subresource copying.
  • Fixture choices (explicitly labeled as fixture policy):
    • Exposing these methods as PE imports from xg_xs.dll is a fixture choice.
    • The hand-written layout values (0x105, 0x100) and the Morton bit-order oracle are fixture policy for testing caller/provider interaction; see #1032 for the full texel reference using pinned PC AddrLib. Console-specific hardware encoding and non-zero flags require independent evidence before binding a production export.
    • Invalid descriptor refusal: Width == 0 returns E_INVALIDARG (0x80070057) leaving the output pointer/sentinel intact.
    • Separate fault controls: cpu_xg_swizzle_provider_clobber tests refusal sentinel overwrite (specific exit 0xE01), and cpu_xg_swizzle_provider_linear tests dummy linear fallback where tiled texels are copied without swizzling (specific exit 0xE04).
  • Loaders and withholding: The fixture runs under native Windows (with and without a live worker thread) and under pe_map. Withholding xg_xs.dll halts pe_map at import resolution with STATUS["unresolved"].

Evidence

  • Environment: Windows 11 x64, MSVC 19.51 / 14.51.36263.0.
  • Test execution:
    • dev preset: ctest --preset dev --no-tests=error -R '^cpu_native_xg_swizzle$' --repeat until-fail:30 passed 30/30 runs (~0.19s per run).
    • release preset: ctest --preset release --no-tests=error -R '^cpu_native_xg_swizzle$' --repeat until-fail:30 passed 30/30 runs (~0.19s per run).
    • Native execution exit: 0x870.
    • Live worker execution exit: 0x870.
    • Mapped execution exit: 0x870.
    • Sentinel clobber mutant exit: caught specifically at step 1 with exit 0xE01.
    • Linear fallback mutant exit: caught specifically at step 4 with exit 0xE04.
    • Withholding xg_xs.dll: verified STATUS["unresolved"] with diagnostic unresolved import xg_xs.dll!.
    • Lint & documentation checks: docs_links_check.py, bidi_controls_check.py, hardware_reports_check.py, form_coverage_check.py all passed.

AI-assisted (Antigravity).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6569982918 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1034). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-23T22:18:26Z. --- Refs #870. Refs #1032. This fixture provides the PE loader, refusal sentinel, and import-withholding test angle for the swizzle mode selection and texture computer layout integration in `xg_xs.dll`, alongside #1032 (whose full 8-mip 21,845-texel layout reference uses pinned PC AddrLib from #979): - `XGSuggestSwizzleMode(desc, flags, out_layout)`: evaluates resource descriptors and suggests swizzle layouts. - `XGCreateTextureComputer(desc, out_computer)`: instantiates an address computer (`IXGTextureComputer`) for subresource layout, texel address calculation, and tiling/detiling copy operations. ### Scope & Call Sequence Public call shape follows DirectXTex usage and public GDK issue references ([DirectXTex #498](https://github.com/microsoft/DirectXTex/issues/498)): 1. `XGSuggestSwizzleMode` evaluates a `D3D12_RESOURCE_DESC` with an unknown input layout (`D3D12_TEXTURE_LAYOUT_UNKNOWN = 0`) and selector flag `0`. 2. The caller exercises both a separate output pointer and an output pointer aliased to the descriptor's own `Layout` field (`&desc.Layout`), verifying both produce matching layout results (`0x105` per fixture policy). 3. The resulting descriptor is passed to `XGCreateTextureComputer`. 4. `CopyIntoSubresource` uploads a generated 3-mip RGBA8 texture (28x4, 14x2, 7x1 = 147 texels) into tiled memory. 5. `CopyFromSubresource` detiles all 147 texels back to linear memory with 100% round-trip fidelity. 6. The small 147-texel Morton round-trip serves as an additional synthetic caller/provider check (disagreeing on 139 of 147 texels under Morton bit-interleaving and agreeing on 8). It is a caller/provider handshake check only, not an independent match to #979 and not evidence of console layout encoding. 7. A linear control with `Layout = 1` (`ROW_MAJOR`) verifies 0 disagreements against linear layout. ### Contract boundaries & Qualifications - **Established call shape**: `XGSuggestSwizzleMode(desc, 0, &out)` with separate and aliased output pointers, feeding the resulting layout into `XGCreateTextureComputer(desc, &comp)` for subresource copying. - **Fixture choices (explicitly labeled as fixture policy)**: - Exposing these methods as PE imports from `xg_xs.dll` is a fixture choice. - The hand-written layout values (`0x105`, `0x100`) and the Morton bit-order oracle are fixture policy for testing caller/provider interaction; see #1032 for the full texel reference using pinned PC AddrLib. Console-specific hardware encoding and non-zero flags require independent evidence before binding a production export. - Invalid descriptor refusal: `Width == 0` returns `E_INVALIDARG` (`0x80070057`) leaving the output pointer/sentinel intact. - Separate fault controls: `cpu_xg_swizzle_provider_clobber` tests refusal sentinel overwrite (specific exit `0xE01`), and `cpu_xg_swizzle_provider_linear` tests dummy linear fallback where tiled texels are copied without swizzling (specific exit `0xE04`). - **Loaders and withholding**: The fixture runs under native Windows (with and without a live worker thread) and under `pe_map`. Withholding `xg_xs.dll` halts `pe_map` at import resolution with `STATUS["unresolved"]`. ### Evidence - **Environment**: Windows 11 x64, MSVC 19.51 / 14.51.36263.0. - **Test execution**: - `dev` preset: `ctest --preset dev --no-tests=error -R '^cpu_native_xg_swizzle$' --repeat until-fail:30` passed 30/30 runs (~0.19s per run). - `release` preset: `ctest --preset release --no-tests=error -R '^cpu_native_xg_swizzle$' --repeat until-fail:30` passed 30/30 runs (~0.19s per run). - Native execution exit: `0x870`. - Live worker execution exit: `0x870`. - Mapped execution exit: `0x870`. - Sentinel clobber mutant exit: caught specifically at step 1 with exit `0xE01`. - Linear fallback mutant exit: caught specifically at step 4 with exit `0xE04`. - Withholding `xg_xs.dll`: verified `STATUS["unresolved"]` with diagnostic `unresolved import xg_xs.dll!`. - Lint & documentation checks: `docs_links_check.py`, `bidi_controls_check.py`, `hardware_reports_check.py`, `form_coverage_check.py` all passed. _AI-assisted (Antigravity)._
upstream-sync closed this pull request 2026-11-24 06:45:57 +00:00
R0Y00 commented 2026-11-24 06:49:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T22:26:43Z.


This adds a useful loader/import-withholding angle alongside #1032, whose full texel reference uses pinned PC AddrLib. Please keep the PE loader, refusal sentinels and missing-provider checks here, and explicitly call the hand-written layout and Morton oracle fixture policy. The small Morton round-trip is an additional caller/provider check. Do not use it as an independent match to #979 or as evidence of the console layout encoding. Please link #1032 so the swizzle-selection and loader evidence stays easy to follow.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7115760450 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1034#issuecomment-7115760450). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T22:26:43Z. --- This adds a useful loader/import-withholding angle alongside #1032, whose full texel reference uses pinned PC AddrLib. Please keep the PE loader, refusal sentinels and missing-provider checks here, and explicitly call the hand-written layout and Morton oracle fixture policy. The small Morton round-trip is an additional caller/provider check. Do not use it as an independent match to #979 or as evidence of the console layout encoding. Please link #1032 so the swizzle-selection and loader evidence stays easy to follow.
Holastor commented 2026-11-24 06:49:48 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-23T22:34:00Z.


Thanks for the review and guidance! Updated in d0d6f4d3 and updated the PR description:

  • Added explicit cross-links to #1032 (Refs #1032).
  • Kept the PE loader, refusal sentinels (E_INVALIDARG, output pointer preserved), and missing-provider checks (STATUS["unresolved"]) as the primary focus of this fixture under pe_map and Windows loader.
  • Explicitly labeled the hand-written layout values (0x105, 0x100) and the 147-texel Morton bit-order oracle as synthetic fixture policy for the caller/provider handshake check. Noted that the full 8-mip 21,845-texel layout reference using pinned PC AddrLib is in #1032, and clarified that the small Morton round-trip is an additional caller/provider check, not an independent match to #979 and not evidence of console layout encoding.

All 30/30 runs pass in dev and release, and all repo lint/docs checks pass.

AI-assisted (Antigravity).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7115913303 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1034#issuecomment-7115913303). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-23T22:34:00Z. --- Thanks for the review and guidance! Updated in `d0d6f4d3` and updated the PR description: - Added explicit cross-links to #1032 (`Refs #1032`). - Kept the PE loader, refusal sentinels (`E_INVALIDARG`, output pointer preserved), and missing-provider checks (`STATUS["unresolved"]`) as the primary focus of this fixture under `pe_map` and Windows loader. - Explicitly labeled the hand-written layout values (`0x105`, `0x100`) and the 147-texel Morton bit-order oracle as synthetic fixture policy for the caller/provider handshake check. Noted that the full 8-mip 21,845-texel layout reference using pinned PC AddrLib is in #1032, and clarified that the small Morton round-trip is an additional caller/provider check, not an independent match to #979 and not evidence of console layout encoding. All 30/30 runs pass in `dev` and `release`, and all repo lint/docs checks pass. _AI-assisted (Antigravity)._
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!1027
No description provided.