OLD-9773: d3d12: refuse a pipeline whose shader needs VK_KHR_maintenance8 on a device without it #1775

Merged
potatoe0100 merged 1 commit from upstream-pr/1775 into main 2026-11-29 15:42:29 +00:00
potatoe0100 commented 2026-11-25 11:50:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by potatoe0100 on 2026-11-25T11:50:26Z.


Claimed in the coordination issue as: OLD-9773 (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7161566908)

What and why

Carries on old PR 9773 by @Joaco9020 (draft #51, branch old-pr/9773, listed in #17), rebased on current main with the author's commit kept.

The translator writes needs_maintenance8 into index.json for a shader that samples with a texel offset outside a gather (the SPIR-V Offset image operand, valid only with VK_KHR_maintenance8), and vk_pipeline_check already reads it, but the D3D12 layer never did: on a device without the extension such a pipeline went to the driver as invalid SPIR-V. ShaderLibrary now reads the flag into ShaderEntry::needs_maintenance8, and graphics and compute pipeline creation refuse such a shader with E_NOTIMPL and a one-line reason, as they already do for mesh limits and workgroup memory. It is not routed through LEONIDA_STUB_PIPELINES, which is for shaders with no translation.

Rebase notes: shader_library.h keeps main's code_base_known handling and adds the new field and read next to it; shader_library_test.cpp adds "needs_maintenance8": true to main's extended ps_out entry; d3d12_mesh_test.cpp keeps main's DISPATCH_MESH command-signature check and adds the author's refused/created pipeline pair after it.

Tested

  • Linux (portable subset, GCC, no GPU): runtime builds; ctest: 84 of 85 pass or skip, including shader_library (which checks the flag is read, and absent means false). The one failure, vk_xdxr_postbuild_readback, is the no-GPU skip returning 77 without SKIP_RETURN_CODE, the same on main and already fixed by #1418.
  • Windows, RTX 4060 (VS 2022, MSVC 19.44, RelWithDebInfo, Vulkan SDK 1.4.363.0): builds cleanly. ctest -R "d3d12_mesh|shader_library": shader_library and d3d12_mesh pass, shader_library_corpus skips (needs game files). Full ctest -j 6: 385 of 385 passed. Two earlier full runs each had one or two failures in tests this change does not touch, which then passed when run alone: d3d12_multithread ran out of device memory once under -j 6, d3d12_depth_stencil_uav crashed once under -j 3 (3 of 3 passes alone), and xmem_write_watch's commit-charge check failed once (1 of 3 alone; known flaky, claimed as TEST-XMEM-COMMIT-CHECK).

GPUs tested: NVIDIA GeForce RTX 4060, driver 621.14, Windows 11 Pro build 26300 (d3d12_mesh_test)

AI-assisted: yes (Claude rebased and tested; the change is Joaco9020's)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: runtime only; the index field is already documented there)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5490763860 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1775). Originally posted by [potatoe0100](https://github.com/potatoe0100) on 2026-11-25T11:50:26Z. --- Claimed in the coordination issue as: OLD-9773 (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7161566908) ### What and why Carries on old PR 9773 by @Joaco9020 (draft #51, branch `old-pr/9773`, listed in #17), rebased on current `main` with the author's commit kept. The translator writes `needs_maintenance8` into `index.json` for a shader that samples with a texel offset outside a gather (the SPIR-V `Offset` image operand, valid only with `VK_KHR_maintenance8`), and `vk_pipeline_check` already reads it, but the D3D12 layer never did: on a device without the extension such a pipeline went to the driver as invalid SPIR-V. `ShaderLibrary` now reads the flag into `ShaderEntry::needs_maintenance8`, and graphics and compute pipeline creation refuse such a shader with `E_NOTIMPL` and a one-line reason, as they already do for mesh limits and workgroup memory. It is not routed through `LEONIDA_STUB_PIPELINES`, which is for shaders with no translation. Rebase notes: `shader_library.h` keeps `main`'s `code_base_known` handling and adds the new field and read next to it; `shader_library_test.cpp` adds `"needs_maintenance8": true` to `main`'s extended `ps_out` entry; `d3d12_mesh_test.cpp` keeps `main`'s DISPATCH_MESH command-signature check and adds the author's refused/created pipeline pair after it. ### Tested - Linux (portable subset, GCC, no GPU): runtime builds; `ctest`: 84 of 85 pass or skip, including `shader_library` (which checks the flag is read, and absent means false). The one failure, `vk_xdxr_postbuild_readback`, is the no-GPU skip returning 77 without `SKIP_RETURN_CODE`, the same on `main` and already fixed by #1418. - Windows, RTX 4060 (VS 2022, MSVC 19.44, RelWithDebInfo, Vulkan SDK 1.4.363.0): builds cleanly. `ctest -R "d3d12_mesh|shader_library"`: `shader_library` and `d3d12_mesh` pass, `shader_library_corpus` skips (needs game files). Full `ctest -j 6`: 385 of 385 passed. Two earlier full runs each had one or two failures in tests this change does not touch, which then passed when run alone: `d3d12_multithread` ran out of device memory once under `-j 6`, `d3d12_depth_stencil_uav` crashed once under `-j 3` (3 of 3 passes alone), and `xmem_write_watch`'s commit-charge check failed once (1 of 3 alone; known flaky, claimed as TEST-XMEM-COMMIT-CHECK). GPUs tested: NVIDIA GeForce RTX 4060, driver 621.14, Windows 11 Pro build 26300 (d3d12_mesh_test) AI-assisted: yes (Claude rebased and tested; the change is Joaco9020's) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: runtime only; the index field is already documented there) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
PierreEbele commented 2026-11-25 18:52:41 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-25T18:52:41Z.


Reviewed 88de45bf1: built and ran shader_library_test on the PR (pass) and on main (pass); copying the PR's test file into a main worktree fails to compile at the new CHECK, and a probe over shader_library.h shows the PR reads needs_maintenance8 from the index (true parsed, non-boolean ignored, absent = false) where main has no such field. All translated modules are picked at the two patched spots, so graphics and compute now refuse the shader with E_NOTIMPL on a device without VK_KHR_maintenance8. d3d12_mesh_test is Windows/Vulkan-only and was not run here - please confirm it ran on a Windows device (its device_info() leaves maintenance8 off). Non-blocking: these refusals bypass stream_unsupported(), so a traced refusal logs "-" as its reason. No finding.

AI-assisted review.

Recommendation: Merge

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7171524719 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1775#issuecomment-7171524719). Originally posted by [PierreEbele](https://github.com/PierreEbele) on 2026-11-25T18:52:41Z. --- Reviewed 88de45bf1: built and ran shader_library_test on the PR (pass) and on main (pass); copying the PR's test file into a main worktree fails to compile at the new CHECK, and a probe over shader_library.h shows the PR reads needs_maintenance8 from the index (true parsed, non-boolean ignored, absent = false) where main has no such field. All translated modules are picked at the two patched spots, so graphics and compute now refuse the shader with E_NOTIMPL on a device without VK_KHR_maintenance8. d3d12_mesh_test is Windows/Vulkan-only and was not run here - please confirm it ran on a Windows device (its device_info() leaves maintenance8 off). Non-blocking: these refusals bypass stream_unsupported(), so a traced refusal logs "-" as its reason. No finding. AI-assisted review. **Recommendation:** Merge
Tyrannys commented 2026-11-26 05:33:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-26T05:33:35Z.


Independent verification of head 88de45bf1d76cc2875ae50fa5f2d130d2f0523c9, with current main (a73a57e13) merged in, no conflicts.

Windows 11 Pro, RTX 4070 SUPER (NVIDIA 621.01), MSVC 19.52.37029, RelWithDebInfo.

  • PR's tests: d3d12_mesh and shader_library pass; neighbours vk_pipeline_check_cli, vk_pipeline_check_stack pass.
  • The new d3d12_mesh case against main's runtime fails at line 242: create(device.p, needs8, refused) == E_NOTIMPL && !refused.p (main creates the pipeline), so the test catches what the PR adds. (shader_library_test's new check needs the new ShaderEntry field, so it does not compile against main.)
  • Full suite with the PR: 474/477. xbox_present and d3d12_set_descriptor_heaps fail on plain main too (475/477 there); xmem_no_write_watch failed once under ctest -j 6 and passed 3/3 run alone, and the PR does not touch xmem.

Diff read: both the graphics and compute paths check needs_maintenance8 against device_.info.maintenance8, which main already fills from the device features. No problem found.

No game files used. AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7183596463 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1775#issuecomment-7183596463). Originally posted by [Tyrannys](https://github.com/Tyrannys) on 2026-11-26T05:33:35Z. --- **Independent verification** of head `88de45bf1d76cc2875ae50fa5f2d130d2f0523c9`, with current `main` (`a73a57e13`) merged in, no conflicts. Windows 11 Pro, RTX 4070 SUPER (NVIDIA 621.01), MSVC 19.52.37029, RelWithDebInfo. - PR's tests: `d3d12_mesh` and `shader_library` pass; neighbours `vk_pipeline_check_cli`, `vk_pipeline_check_stack` pass. - The new `d3d12_mesh` case against `main`'s runtime **fails** at `line 242: create(device.p, needs8, refused) == E_NOTIMPL && !refused.p` (main creates the pipeline), so the test catches what the PR adds. (`shader_library_test`'s new check needs the new `ShaderEntry` field, so it does not compile against `main`.) - Full suite with the PR: 474/477. `xbox_present` and `d3d12_set_descriptor_heaps` fail on plain `main` too (475/477 there); `xmem_no_write_watch` failed once under `ctest -j 6` and passed 3/3 run alone, and the PR does not touch xmem. Diff read: both the graphics and compute paths check `needs_maintenance8` against `device_.info.maintenance8`, which `main` already fills from the device features. No problem found. No game files used. AI-assisted (Claude Code).
zmasi commented 2026-11-29 01:39:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T01:39:14Z.


Independently verified head 88de45bf1d76cc2875ae50fa5f2d130d2f0523c9 merged cleanly onto origin/main (5825b02ff89bca1a2d1331d982818e3dbb74d597) on Windows 11 (10.0.26200), MSVC 19.44.35207 (RelWithDebInfo), NVIDIA GeForce RTX 3090 (driver 595.79), with VK_LAYER_KHRONOS_validation 1.4.363.1 (LEONIDA_VK_VALIDATION=1). No game files used.

Red -> Green Verification

  • Red (main's runtime/shims/d3d12_vulkan_device.cpp with PR's d3d12_mesh_test.cpp + shader_library.h):
    • ctest -C RelWithDebInfo -R "^d3d12_mesh$": FAILED (rc=8) at line 248: create(device.p, needs8, refused) == E_NOTIMPL && !refused.p (main accepts the needs_maintenance8 pixel shader when device.info.maintenance8 is false).
  • Green (#1775 merged with origin/main 5825b02ff8, LEONIDA_VK_VALIDATION=1 on RTX 3090):
    • shader_library: Passed (ps->needs_maintenance8 && !vs->needs_maintenance8).
    • d3d12_mesh (eager mode): Passed ([rt] d3d12: ps_offset samples with a texel offset; the device has no VK_KHR_maintenance8, 4096 pixels matched, 0 Khronos validation errors).
    • vk_pipeline_check_cli, vk_pipeline_check_stack, and scripts/check_no_game_data.py: Passed.

Non-Blocking Finding: LEONIDA_PIPELINE_COMPILE=on-demand (Device::prepare_console_stream)

In d3d12_mesh_test.cpp, create(device.p, needs8, refused) calls ID3D12Device2::CreatePipelineState (PC vtable slot 47, which always builds eagerly via PipelineState::build). However, Xbox titles create stream PSOs via Xbox DeviceProxy slot 86 (create_pso_from_stream), which routes through Device::prepare_console_stream (runtime/shims/d3d12_vulkan_device.cpp) when LEONIDA_PIPELINE_COMPILE=on-demand (the boot profile's compilation mode):

  • Empirically tested on RTX 3090 by calling Xbox device slot 86 on needs8.desc():
    • Default eager mode: slot86_fn(device.p, &needs8_desc, IID_PPV_ARGS(&refused.p)) returns 0x80004001 (E_NOTIMPL) with pso = nullptr.
    • LEONIDA_PIPELINE_COMPILE=on-demand: slot86_fn(device.p, &needs8_desc, IID_PPV_ARGS(&refused.p)) returns 0x00000000 (S_OK) with a non-null deferred ID3D12PipelineState* (and caches identity in verified_programs_), because Device::prepare_console_stream's verify(name, code) checks library->program_candidates(...) without checking entry->needs_maintenance8 && !state_.info.maintenance8 (so the E_NOTIMPL only happens later at bind/draw realization rather than at slot-86 creation).
  • Also note a minor rebase heads-up with open PR #1818 (RT-ONDEMAND-CONSOLE-STREAM): d3d12_mesh_test.cpp has a 2-line adjacent conflict where #1818 wraps LEONIDA_TEST_PS_SPV in vktest::shader_fixture_path(...). Adding the needs_maintenance8 check in Device::prepare_console_stream (either here or alongside #1818) and asserting slot 86 in d3d12_mesh_test.cpp will cover both eager and on-demand modes.

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248926159 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1775#issuecomment-7248926159). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-29T01:39:14Z. --- Independently verified head `88de45bf1d76cc2875ae50fa5f2d130d2f0523c9` merged cleanly onto `origin/main` (`5825b02ff89bca1a2d1331d982818e3dbb74d597`) on Windows 11 (`10.0.26200`), MSVC `19.44.35207` (`RelWithDebInfo`), **NVIDIA GeForce RTX 3090** (driver `595.79`), with `VK_LAYER_KHRONOS_validation` `1.4.363.1` (`LEONIDA_VK_VALIDATION=1`). No game files used. ### Red -> Green Verification - **Red (`main`'s `runtime/shims/d3d12_vulkan_device.cpp` with PR's `d3d12_mesh_test.cpp` + `shader_library.h`)**: - `ctest -C RelWithDebInfo -R "^d3d12_mesh$"`: **FAILED (`rc=8`)** at `line 248: create(device.p, needs8, refused) == E_NOTIMPL && !refused.p` (`main` accepts the `needs_maintenance8` pixel shader when `device.info.maintenance8` is false). - **Green (`#1775` merged with `origin/main` `5825b02ff8`, `LEONIDA_VK_VALIDATION=1` on RTX 3090)**: - `shader_library`: **Passed** (`ps->needs_maintenance8 && !vs->needs_maintenance8`). - `d3d12_mesh` (eager mode): **Passed** (`[rt] d3d12: ps_offset samples with a texel offset; the device has no VK_KHR_maintenance8`, `4096 pixels matched`, `0` Khronos validation errors). - `vk_pipeline_check_cli`, `vk_pipeline_check_stack`, and `scripts/check_no_game_data.py`: **Passed**. ### Non-Blocking Finding: `LEONIDA_PIPELINE_COMPILE=on-demand` (`Device::prepare_console_stream`) In `d3d12_mesh_test.cpp`, `create(device.p, needs8, refused)` calls `ID3D12Device2::CreatePipelineState` (PC vtable slot 47, which always builds eagerly via `PipelineState::build`). However, Xbox titles create stream PSOs via **Xbox `DeviceProxy` slot 86** (`create_pso_from_stream`), which routes through `Device::prepare_console_stream` (`runtime/shims/d3d12_vulkan_device.cpp`) when `LEONIDA_PIPELINE_COMPILE=on-demand` (the boot profile's compilation mode): - Empirically tested on RTX 3090 by calling Xbox device slot 86 on `needs8.desc()`: - Default eager mode: `slot86_fn(device.p, &needs8_desc, IID_PPV_ARGS(&refused.p))` returns **`0x80004001` (`E_NOTIMPL`)** with `pso = nullptr`. - `LEONIDA_PIPELINE_COMPILE=on-demand`: `slot86_fn(device.p, &needs8_desc, IID_PPV_ARGS(&refused.p))` returns **`0x00000000` (`S_OK`)** with a non-null deferred `ID3D12PipelineState*` (and caches `identity` in `verified_programs_`), because `Device::prepare_console_stream`'s `verify(name, code)` checks `library->program_candidates(...)` without checking `entry->needs_maintenance8 && !state_.info.maintenance8` (so the `E_NOTIMPL` only happens later at bind/draw realization rather than at slot-86 creation). - Also note a minor rebase heads-up with open PR `#1818` (`RT-ONDEMAND-CONSOLE-STREAM`): `d3d12_mesh_test.cpp` has a 2-line adjacent conflict where `#1818` wraps `LEONIDA_TEST_PS_SPV` in `vktest::shader_fixture_path(...)`. Adding the `needs_maintenance8` check in `Device::prepare_console_stream` (either here or alongside `#1818`) and asserting slot 86 in `d3d12_mesh_test.cpp` will cover both eager and on-demand modes. AI-assisted: yes
OreoFR commented 2026-11-29 05:47:32 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T05:47:32Z.


Verified by OreoFR — READY

  • Base: main c8bf0e7b6 + this PR (head 88de45bf1) merged with --no-ff
  • Red (main + only this PR's tests): d3d12_mesh and d3d12_mesh_heavy_cache fail on main at line 248 (create(device.p, needs8, refused) == E_NOTIMPL). shader_library_test does not compile on main, because needs_maintenance8 is a field the PR adds.
  • Green (merge): d3d12_mesh, d3d12_mesh_heavy_cache and shader_library pass; ctest (Ninja RelWithDebInfo, all targets, gta6rt launchers excluded) in package p3 = main + #2478 + #1775 (no shared files): 495 tests, new failures vs main: none (main alone: 494 tests, 5 failures: loader, xs_proxy_mock, xmem_no_write_watch, api_ref_state timeout, xbox_present; xbox_present fails in every package as on main)
  • gta6rt.exe links without the XMA decoder (LEONIDA_CARGO=OFF, LEONIDA_XMA2_DECODER_LIB empty), main + this PR alone; imports unchanged vs main (25 DLLs, 655 functions, no WS2_32)
  • Diff read: no issue (both refusals come after the entry is resolved). Note: it touches d3d12_mesh_test.cpp, as #1818 does; each merges cleanly on its own.
  • Other runs: Consistent with zmasi's and Tyrannys' runs.
  • Machine: Windows 11, Intel Core Ultra 7 155H, RTX 4070 Laptop 8 GB, NVIDIA 621.40, Python 3.12.10, MSVC 19.44

AI-assisted (Claude Code, Claude Opus 5.5), run for OreoFR.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7251462286 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1775#issuecomment-7251462286). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T05:47:32Z. --- **Verified by OreoFR** — READY - Base: main c8bf0e7b6 + this PR (head 88de45bf1) merged with --no-ff - Red (main + only this PR's tests): `d3d12_mesh` and `d3d12_mesh_heavy_cache` fail on main at line 248 (`create(device.p, needs8, refused) == E_NOTIMPL`). `shader_library_test` does not compile on main, because `needs_maintenance8` is a field the PR adds. - Green (merge): `d3d12_mesh`, `d3d12_mesh_heavy_cache` and `shader_library` pass; ctest (Ninja RelWithDebInfo, all targets, gta6rt launchers excluded) in package p3 = main + #2478 + #1775 (no shared files): 495 tests, new failures vs main: none (main alone: 494 tests, 5 failures: loader, xs_proxy_mock, xmem_no_write_watch, api_ref_state timeout, xbox_present; xbox_present fails in every package as on main) - gta6rt.exe links without the XMA decoder (`LEONIDA_CARGO=OFF`, `LEONIDA_XMA2_DECODER_LIB` empty), main + this PR alone; imports unchanged vs main (25 DLLs, 655 functions, no WS2_32) - Diff read: no issue (both refusals come after the entry is resolved). Note: it touches `d3d12_mesh_test.cpp`, as #1818 does; each merges cleanly on its own. - Other runs: Consistent with zmasi's and Tyrannys' runs. - Machine: Windows 11, Intel Core Ultra 7 155H, RTX 4070 Laptop 8 GB, NVIDIA 621.40, Python 3.12.10, MSVC 19.44 AI-assisted (Claude Code, Claude Opus 5.5), run for OreoFR.
MoonEyes commented 2026-11-29 15:42:32 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T15:42:32Z.


Merged. Tested by @OreoFR on head 88de45bf1 (RTX 4070 Laptop 8 GB, Windows 11): red: d3d12_mesh/_heavy_cache fail line 248, shader_library_test does not compile; green pass (zmasi, Tyrannys agree). Correction: no CI check run or commit status exists for this head, so CI did not validate it. My earlier sentence about red jobs was wrong. Thanks @potatoe0100!

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7258303095 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1775#issuecomment-7258303095). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T15:42:32Z. --- Merged. Tested by @OreoFR on head 88de45bf1 (RTX 4070 Laptop 8 GB, Windows 11): red: d3d12_mesh/_heavy_cache fail line 248, shader_library_test does not compile; green pass (zmasi, Tyrannys agree). Correction: no CI check run or commit status exists for this head, so CI did not validate it. My earlier sentence about red jobs was wrong. Thanks @potatoe0100! AI-assisted: yes
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
ProjectLeonida/mandy!1775
No description provided.