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

Manually merged
github merged 3 commits from github-bot/gh-2989 into gh-pr/2989/base 2026-11-27 03:51:41 +00:00 AGit
Owner

@⁠Not-Saii on GitHub · 2026-11-27 03:27 UTC · original
Not-Saii:native/rtv-variant-requests-2980 → cpp-migration · +635 −22 · 13 files · 3 commits · merged 2026-11-27 03:48 UTC

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

**@⁠Not-Saii** on GitHub · 2026-11-27 03:27 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2989) `Not-Saii:native/rtv-variant-requests-2980` → `cpp-migration` · +635 −22 · 13 files · 3 commits · merged 2026-11-27 03:48 UTC 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)
gfx1013-container-pair --requests now also takes each req_<key>.rtv. The
reader checks the "rtv1 <base key> <format> ..." text as
tools/startup/gfx2hlsl.py request_source does (256 bytes, decimal, one
to eight formats, FNV-1a of the text is the key in the name) and reads
the base parts it names, checked against the base key. A key with both
markers is one request, the variant.

The ordered formats type the pixel stage's color targets: u32 or i32 for
the integer formats, f32 otherwise. The two three-channel 32-bit integer
formats are refused by name when the pixel stage exports to their
target, as in gfx2hlsl.py. A container whose own output signature says
otherwise is refused. The target types are part of the pair cache key,
the manifest accepts an integer target only for the variant that asked
for it, and the request is the manifest's last line, which the runtime
matches. A variant without a runtime manifest is refused. A base request
adds nothing to its key and takes the same path as before.

native_rtv_variant_controls compiles a base and four variants cold and
warm with four workers and checks thirteen refusals, a withdrawn stale
directory and a signature conflict. native_rtv_variant_{warp,hardware}
draws three variants through the stand-in and reads the target back.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
What changed, the pair, formats and expected values, the controls, the
results on the RTX 4090 and on WARP for be9a0706, the baseline, a
mutation control, the regression runs and the limits.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 03:28:48 +00:00
The release preset at be9a0706 on the same machine: the three tests on both adapters, twelve repeated control runs and the regression set.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot changed target branch from cpp-migration to gh-pr/2989/base 2026-11-27 03:51:38 +00:00
github manually merged commit 8d55ce1ea6 into gh-pr/2989/base 2026-11-27 03:51:41 +00:00
Author
Owner

@⁠MasterDomino on GitHub · 2026-11-27 03:48 UTC · original · approved these changes

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.

**@⁠MasterDomino** on GitHub · 2026-11-27 03:48 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2989#pullrequestreview-6083208246) · **approved these changes** 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.