shader: resolve and cache RTV variant requests in compile_dxil --requests #2989

Merged
Not-Saii merged 3 commits from upstream-pr/2989 into cpp-migration 2026-11-27 03:48:11 +00:00
Not-Saii commented 2026-11-27 03:27:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-27T03:27:47Z.


Refs #2980

compile_dxil gfx1013-container-pair --requests now also takes each req_<key>.rtv, resolves it against its base request, types the pixel stage's color targets from the ordered formats and publishes the variant under the key the runtime loads.

What changed

  • Reader: read_graphics_request accepts req_<key>.rtv and checks the text as gfx2hlsl.py::request_source does (256 bytes, rtv1 <base key> <format> ... in decimal, one to eight formats, FNV-1a of the text equal to the key in the name). The base parts, with the optional .ia and .psin, are read and checked against the base key by the existing base path.
  • Translation: the formats type each target as mrt_kind does: u32 or i32 for the integer formats, f32 otherwise. Formats 7 and 8 are refused by name when the pixel stage exports to their target. A float32 target keeps the register bits without the mrtbits mechanism.
  • Cache and manifest: the target types are part of the .pairir key; a base request adds nothing to its key. The manifest ends with the request text, which the runtime matches.
  • Tool: .rtv markers are scanned next to .a. A key with both markers is one request, the variant. A variant without a runtime manifest is refused. Refusals use the .fail lifecycle of #2984.
  • The stand-in is not changed.

Two refusals where gfx2hlsl.py translates: a container whose own output signature disagrees with the format, and a variant whose pair has no runtime manifest.

Tested locally at be9a0706 on cpp-migration at 4ff5e36d: Windows 11 build 26300.9974, Debug, Windows SDK 10.0.26100 DXC, D3D12 debug layer enabled with no error message.

cmake --build --preset dev
ctest --preset dev --no-tests=error -V -R '^native_rtv_variant_'
Test Adapter, driver Result
native_rtv_variant_controls none PASS
native_rtv_variant_hardware NVIDIA GeForce RTX 4090, 32.0.16.1088 PASS
native_rtv_variant_warp Microsoft Basic Render Driver, 10.0.26100.9818 PASS

Readback after the fence, for the exported words ffff7ffe, 15, eb, 68, on both adapters:

Format SV_Target0 MRT0 bytes
R16G16B16A16_UINT (12) uint ffff 1500 eb00 6800
R16G16B16A16_SINT (14) int 0080 1500 eb00 6800
R32G32B32A32_FLOAT (2) float fe7fffff 15000000 eb000000 68000000

Controls (no device): the base and four variants compile cold and warm with --jobs 4 and identical bytes; 13 refusals leave only <key>.fail (forged variant key, changed base, no format, nine formats, a format above 32 bits, trailing newline, missing base, formats 7 and 8, a forged file under the base's own key, a cached-entry refusal, a base with an input layout, a changed layout); a changed base withdraws every manifest; a signature conflict is refused. The unmodified base pair compiles in each directory where it is intact.

Baseline: at 05438d65 the tool does not scan .rtv (requests=1 compiled=1 refused=0 for a base plus one variant). Mutation: with the format ignored where the target is typed, the controls and the WARP test fail.

Regression at the same commit: 45 of 48 neighbouring tests pass, and 36 of 40 in the pr preset. Capability skips, not passes: native_comparison_pso_warp, native_global_srv_heap_replay_warp, startup_compute_dispatch_native_warp and the four spirv_minlod_*_warp tests.

Not run: a Release build, the Linux Python checks, and any adapter other than the two above. Limits are in docs/experiments/native-rtv-variant-requests.md.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5520661895 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2989). Originally posted by [Not-Saii](https://github.com/Not-Saii) on 2026-11-27T03:27:47Z. --- Refs #2980 `compile_dxil gfx1013-container-pair --requests` now also takes each `req_<key>.rtv`, resolves it against its base request, types the pixel stage's color targets from the ordered formats and publishes the variant under the key the runtime loads. **What changed** - **Reader:** `read_graphics_request` accepts `req_<key>.rtv` and checks the text as `gfx2hlsl.py::request_source` does (256 bytes, `rtv1 <base key> <format> ...` in decimal, one to eight formats, FNV-1a of the text equal to the key in the name). The base parts, with the optional `.ia` and `.psin`, are read and checked against the base key by the existing base path. - **Translation:** the formats type each target as `mrt_kind` does: `u32` or `i32` for the integer formats, `f32` otherwise. Formats 7 and 8 are refused by name when the pixel stage exports to their target. A float32 target keeps the register bits without the `mrtbits` mechanism. - **Cache and manifest:** the target types are part of the `.pairir` key; a base request adds nothing to its key. The manifest ends with the request text, which the runtime matches. - **Tool:** `.rtv` markers are scanned next to `.a`. A key with both markers is one request, the variant. A variant without a runtime manifest is refused. Refusals use the `.fail` lifecycle of #2984. - The stand-in is not changed. Two refusals where `gfx2hlsl.py` translates: a container whose own output signature disagrees with the format, and a variant whose pair has no runtime manifest. **Tested locally** at `be9a0706` on `cpp-migration` at `4ff5e36d`: Windows 11 build 26300.9974, Debug, Windows SDK 10.0.26100 DXC, D3D12 debug layer enabled with no error message. ```powershell cmake --build --preset dev ctest --preset dev --no-tests=error -V -R '^native_rtv_variant_' ``` | Test | Adapter, driver | Result | |---|---|---| | `native_rtv_variant_controls` | none | PASS | | `native_rtv_variant_hardware` | NVIDIA GeForce RTX 4090, 32.0.16.1088 | PASS | | `native_rtv_variant_warp` | Microsoft Basic Render Driver, 10.0.26100.9818 | PASS | Readback after the fence, for the exported words `ffff7ffe`, `15`, `eb`, `68`, on both adapters: | Format | `SV_Target0` | MRT0 bytes | |---|---|---| | `R16G16B16A16_UINT` (12) | `uint` | `ffff 1500 eb00 6800` | | `R16G16B16A16_SINT` (14) | `int` | `0080 1500 eb00 6800` | | `R32G32B32A32_FLOAT` (2) | `float` | `fe7fffff 15000000 eb000000 68000000` | Controls (no device): the base and four variants compile cold and warm with `--jobs 4` and identical bytes; 13 refusals leave only `<key>.fail` (forged variant key, changed base, no format, nine formats, a format above 32 bits, trailing newline, missing base, formats 7 and 8, a forged file under the base's own key, a cached-entry refusal, a base with an input layout, a changed layout); a changed base withdraws every manifest; a signature conflict is refused. The unmodified base pair compiles in each directory where it is intact. Baseline: at `05438d65` the tool does not scan `.rtv` (`requests=1 compiled=1 refused=0` for a base plus one variant). Mutation: with the format ignored where the target is typed, the controls and the WARP test fail. Regression at the same commit: 45 of 48 neighbouring tests pass, and 36 of 40 in the `pr` preset. Capability skips, not passes: `native_comparison_pso_warp`, `native_global_srv_heap_replay_warp`, `startup_compute_dispatch_native_warp` and the four `spirv_minlod_*_warp` tests. Not run: a Release build, the Linux Python checks, and any adapter other than the two above. Limits are in `docs/experiments/native-rtv-variant-requests.md`. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MasterDomino commented 2026-11-27 03:48:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-27T03:48:09Z.

Review: APPROVED


Review of head 8d55ce1e. Its last commit only updates docs/experiments/native-rtv-variant-requests.md; the code below was tested at c593bace. CI on the head is green. Approving and merging.

Code read:

  • Reader: read_rtv_variant checks the 256-byte limit, the rtv1 prefix, decimal tokens, one to eight formats and the FNV-1a key before it reads the base parts, which the existing base path checks against the base key.
  • Base pair unchanged: it adds nothing to its .pairir key, its target types stay 0, and format_graphics_runtime_manifest still returns nothing for any non-float target of a base.
  • Variants: a variant adds its target types to the key, so formats of one type share an entry. Formats 7 and 8 are refused by name only when the target is exported, also on a cache hit. A signature that disagrees with the asked type is refused rather than reinterpreted.
  • Tool: .rtv is scanned only for gfx1013-container-pair, not for the rectangle mode. A key with both markers is the variant, and a variant without a runtime manifest is refused through the #2984 .fail lifecycle.

Run on AMD: Windows 11 26300.9974, AMD Radeon RX 9070 XT (driver 32.0.32029.2010), plus WARP, release. This was tested together with #2990, #2992 and #2994 merged onto cpp-migration 4ff5e36d; all four merge cleanly with each other. ctest --preset release --no-tests=error -R '^(native_.*|startup_compute_dispatch(_.*)?_(warp|hardware)|startup_slot67_indirect_dispatch_warp|startup_compute_translate_e2e_warp|startup_stream_draw.*|startup_native_graphics.*)$' gives 88 tests, 84 passed and 4 skipped (77, WARP has no 32-lane waves).

  • native_rtv_variant_hardware passed on the RX 9070 XT with the debug layer enabled and no message. The MRT0 bytes are ffff1500eb006800 (format 12), 00801500eb006800 (format 14) and fe7fffff15000000eb00000068000000 (format 2), the same as on your RTX 4090.
  • native_rtv_variant_warp and native_rtv_variant_controls passed, as did the stream draw and native graphics tests.

Mutation here: dropping the rtv1 line from the variant manifest fails both native_rtv_variant_controls and native_rtv_variant_hardware. With it restored, both pass.

Note: compile_dxil --watch (#2992, merged alongside this) does not scan .rtv, so variants are compiled only by --requests for now. This PR says Refs #2980, so I leave the issue open for you to close when you consider it complete.

AI-assisted; the commands above were run locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6083208246 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2989#pullrequestreview-6083208246). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-27T03:48:09Z. **Review:** APPROVED --- Review of head `8d55ce1e`. Its last commit only updates `docs/experiments/native-rtv-variant-requests.md`; the code below was tested at `c593bace`. CI on the head is green. Approving and merging. **Code read:** - **Reader:** `read_rtv_variant` checks the 256-byte limit, the `rtv1 ` prefix, decimal tokens, one to eight formats and the FNV-1a key before it reads the base parts, which the existing base path checks against the base key. - **Base pair unchanged:** it adds nothing to its `.pairir` key, its target types stay 0, and `format_graphics_runtime_manifest` still returns nothing for any non-float target of a base. - **Variants:** a variant adds its target types to the key, so formats of one type share an entry. Formats 7 and 8 are refused by name only when the target is exported, also on a cache hit. A signature that disagrees with the asked type is refused rather than reinterpreted. - **Tool:** `.rtv` is scanned only for `gfx1013-container-pair`, not for the rectangle mode. A key with both markers is the variant, and a variant without a runtime manifest is refused through the #2984 `.fail` lifecycle. **Run on AMD:** Windows 11 26300.9974, AMD Radeon RX 9070 XT (driver 32.0.32029.2010), plus WARP, release. This was tested together with #2990, #2992 and #2994 merged onto `cpp-migration` `4ff5e36d`; all four merge cleanly with each other. `ctest --preset release --no-tests=error -R '^(native_.*|startup_compute_dispatch(_.*)?_(warp|hardware)|startup_slot67_indirect_dispatch_warp|startup_compute_translate_e2e_warp|startup_stream_draw.*|startup_native_graphics.*)$'` gives 88 tests, 84 passed and 4 skipped (77, WARP has no 32-lane waves). - `native_rtv_variant_hardware` **passed** on the RX 9070 XT with the debug layer enabled and no message. The MRT0 bytes are `ffff1500eb006800` (format 12), `00801500eb006800` (format 14) and `fe7fffff15000000eb00000068000000` (format 2), the same as on your RTX 4090. - `native_rtv_variant_warp` and `native_rtv_variant_controls` passed, as did the stream draw and native graphics tests. **Mutation here:** dropping the `rtv1` line from the variant manifest fails both `native_rtv_variant_controls` and `native_rtv_variant_hardware`. With it restored, both pass. **Note:** `compile_dxil --watch` (#2992, merged alongside this) does not scan `.rtv`, so variants are compiled only by `--requests` for now. This PR says `Refs #2980`, so I leave the issue open for you to close when you consider it complete. AI-assisted; the commands above were run 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!2989
No description provided.