[PR #42] d3d12: LEONIDA_STUB_PIPELINES, a pipeline without a translated shader is a no-op stub (boot past stop 18) #96

Open
opened 2026-11-26 20:16:47 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/42
Author: @Andretuta
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: old-pr/7417


📝 Commits (5)

  • aae44fc d3d12: LEONIDA_STUB_PIPELINES creates a pipeline without a translated shader as a no-op stub
  • 9c99166 d3d12: read LEONIDA_STUB_PIPELINES with GetEnvironmentVariableW (no C4996 under MSVC /W4)
  • 780d1a4 d3d12: LEONIDA_STUB_PIPELINES does not stub an ambiguous FSPX program
  • f8dad85 d3d12: a stubbed pipeline's draws and dispatches are dropped, and the list stays valid
  • 0ba54d3 Merge main into feat/stub-pipelines

📊 Changes

7 files changed (+199 additions, -10 deletions)

View changed files

📝 docs/boot.md (+8 -0)
📝 runtime/CMakeLists.txt (+7 -0)
📝 runtime/shims/d3d12_com.cpp (+9 -1)
📝 runtime/shims/d3d12_com.h (+3 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+36 -9)
📝 runtime/test/d3d12_fspx_compute_test.cpp (+12 -0)
➕ runtime/test/d3d12_stub_pipelines_test.cpp (+124 -0)

📄 Description

Carried over from old PR 7417 by rafaelpssz in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/7417, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
rafaelpssz: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Claimed in the coordination issue: https://github.com/ItsNotRexed/Leonida/issues/7231#issuecomment-7107135285

No dependency any more: #7007, which made every draw or dispatch with no PSO bound a no-op, was closed. Since f8dad8586 the command list drops a stub's draws and dispatches itself, so the list stays valid on main as it is.

What and why

The retail title creates every pipeline it needs at boot. One of them is XboxBvhBuilder.dll's 52 compute programs (stop 18 of the boot chain). If a single creation fails, the title stops: the builder throws a C++ exception, and other sites assert. To follow the boot past that point, every pipeline currently needs its translated shader in LEONIDA_SHADERS. That means a full translation, and running those shaders on the GPU. On a machine whose GPU also drives the display, a bad shader can hang it.

With LEONIDA_STUB_PIPELINES=1, a pipeline whose translated shader is missing is created as a stub. That covers two cases: no shader library at all, or no library entry for this program. The stub is a PipelineState that create_graphics / create_compute return S_OK for before any Vulkan pipeline is built. It's never registered, so:

  • compute_pipeline_id / graphics_pipeline_id give 0;
  • SetPipelineState binds no PSO;
  • the command list sees that the bound pipeline state is a stub (pipeline_is_stub) and records nothing for DrawInstanced, DrawIndexedInstanced, Dispatch, DispatchMesh and ExecuteIndirect while it is bound. Close succeeds and the list holds none of them. With no pipeline state bound at all, the same calls still make Close fail, as before.

No game shader is translated or run, and nothing the title draws reaches the screen. Like LEONIDA_SKIP_INT3, this is a diagnostic for finding the next boot stop, not a way to play.

  • Off by default; 0 or empty is off too.
  • Every other refusal is unchanged: bad descriptions, set-0 or LDS limits, an ambiguous FSPX program.
  • Each stub is logged with a power-of-two count: [rt] d3d12: LEONIDA_STUB_PIPELINES: compute pipeline without a translated shader is a no-op stub (64 so far).

On the retail executable (my own copy, local integration tree with the open boot PRs), the switch takes the run past stop 18. The builder's programs and the title's 64 compute pipelines are stubbed, and the title gets as far as recording frames and reaching PresentX. Integration report: #7231 comment 7107135285.

Changes

  • runtime/shims/d3d12_vulkan_device.cpp: stub_pipelines() and stub_or() in PipelineState, used at four places:
    • the library check in create_graphics;
    • the library check in create_compute;
    • the missing-entry return in create_graphics;
    • the missing-entry return in create_compute.
  • runtime/test/d3d12_stub_pipelines_test.cpp (new), registered next to d3d12_draw, with skip code 77 when there is no Vulkan device. With LEONIDA_SHADERS unset, it checks a graphics PSO description:
    • switch unset: E_FAIL and no object;
    • 0: the same;
    • 1: S_OK, an object, and graphics_pipeline_id / compute_pipeline_id 0;
    • with a null VS it is still E_INVALIDARG.
  • runtime/test/d3d12_fspx_compute_test.cpp: with a loaded library and the switch on, a compute PSO whose kind-0 state has no translation is stubbed (S_OK), while the bare kind-6 program with two differing translations (ambiguous) is still E_INVALIDARG.
  • runtime/shims/d3d12_com.cpp, d3d12_com.h: pipeline_is_stub, and stub_pipeline_ in the command list, set by SetPipelineState and Reset. A stub no longer logs "pipeline from another device".
  • runtime/test/d3d12_stub_pipelines_test.cpp also binds the stub, draws, draws indexed and dispatches, and checks Close() == S_OK with no recorded command. The control is the same draw with no pipeline state: E_INVALIDARG.
  • docs/boot.md: the switch, next to the other diagnostic switches.

Tested

Windows 11 Pro 26200, RTX 3060, clang-cl/xwin cross build (MSVC 14.44 headers), RelWithDebInfo:

  • d3d12_stub_pipelines_test: PASS.
  • With the d3d12_vulkan_device.cpp change stashed, it FAILs at the S_OK and object checks.
  • d3d12_fspx_compute_test: PASS. With the ambiguity return reverted (ambiguous program stubbed), it FAILs at the ambiguous check.
  • f8dad8586 (the stub's draws and dispatches): with the d3d12_com.cpp change reverted, the test FAILs at both Close() == S_OK checks; with it, PASS. Together with d3d12_draw, d3d12_compute, d3d12_close_parity, d3d12_execute_indirect_validation, d3d12_bundle, d3d12_bundle_forbidden and command_list: 8/8 pass, on this head and with the same change on main f5bcc679d.
  • Not run on current main f48adad76: runtime/ does not compile there with this toolchain (three errors around create_console_descriptor_heap, in files this PR does not touch).
  • The test creates a Vulkan device and one stub PSO. No shader runs on the GPU and no game data is used.

Thanks

  • @lines9686-rgb: #7007, the no-PSO no-op this first relied on.
  • @AAyberkU and @TanmaySatyam: both found that a stub's draws and dispatches made Close fail, against the description. Fixed in f8dad8586 along the lines TanmaySatyam suggested (a stub flag on the list).
  • @KkelebekK and @sennecools: the stop 18 measurements (builder programs, compile time, watchdog) that showed why a boot needs a way past it.
  • @MartinIndra02: tested it on an RTX 3080 with MSVC (pass).
  • @KarolKurzyna: tested it on an RTX 3070 Ti and an Intel UHD 770 with validation on and off. The review also caught the MSVC C4996 on std::getenv, fixed by reading the switch with GetEnvironmentVariableW, and noted that the compute and loaded-library paths had no test.
  • @Alpha325: caught that an ambiguous FSPX program was stubbed in the compute path, against the description; now refused with E_INVALIDARG, with a synthetic loaded-library test.
  • @Kadthicu: tested on an RTX 3060 with MSVC, with a negative control for the ambiguous FSPX program.
  • @sh1shu1: ran it on the retail executable on an RTX 4070 SUPER (stop 18 without the switch, stops 26 and 27 with it) and saw the failing Close on a stubbed list.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/42 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `old-pr/7417` --- ### 📝 Commits (5) - [`aae44fc`](https://github.com/ubiquitarianism/leonida/commit/aae44fc471ad682b968e24a35c68484e84ea14d0) d3d12: LEONIDA_STUB_PIPELINES creates a pipeline without a translated shader as a no-op stub - [`9c99166`](https://github.com/ubiquitarianism/leonida/commit/9c9916696e573bd8049c384a5a42c2ee0036b40c) d3d12: read LEONIDA_STUB_PIPELINES with GetEnvironmentVariableW (no C4996 under MSVC /W4) - [`780d1a4`](https://github.com/ubiquitarianism/leonida/commit/780d1a41b0c8c20212874f723cc9862f7cac679c) d3d12: LEONIDA_STUB_PIPELINES does not stub an ambiguous FSPX program - [`f8dad85`](https://github.com/ubiquitarianism/leonida/commit/f8dad8586a7b97391cef6deeb2bccb7ad8938793) d3d12: a stubbed pipeline's draws and dispatches are dropped, and the list stays valid - [`0ba54d3`](https://github.com/ubiquitarianism/leonida/commit/0ba54d34db1411b4c8f776482a2a98b6b6b8e735) Merge main into feat/stub-pipelines ### 📊 Changes **7 files changed** (+199 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `docs/boot.md` (+8 -0) 📝 `runtime/CMakeLists.txt` (+7 -0) 📝 `runtime/shims/d3d12_com.cpp` (+9 -1) 📝 `runtime/shims/d3d12_com.h` (+3 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+36 -9) 📝 `runtime/test/d3d12_fspx_compute_test.cpp` (+12 -0) ➕ `runtime/test/d3d12_stub_pipelines_test.cpp` (+124 -0) </details> ### 📄 Description > Carried over from **old PR 7417** by `rafaelpssz` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/7417`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `rafaelpssz`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): Claimed in the coordination issue: https://github.com/ItsNotRexed/Leonida/issues/7231#issuecomment-7107135285 No dependency any more: `#7007`, which made every draw or dispatch with no PSO bound a no-op, was closed. Since `f8dad8586` the command list drops a stub's draws and dispatches itself, so the list stays valid on `main` as it is. ### What and why The retail title creates every pipeline it needs at boot. One of them is `XboxBvhBuilder.dll`'s 52 compute programs (stop 18 of the boot chain). If a single creation fails, the title stops: the builder throws a C++ exception, and other sites assert. To follow the boot past that point, every pipeline currently needs its translated shader in `LEONIDA_SHADERS`. That means a full translation, and running those shaders on the GPU. On a machine whose GPU also drives the display, a bad shader can hang it. With `LEONIDA_STUB_PIPELINES=1`, a pipeline whose translated shader is missing is created as a stub. That covers two cases: no shader library at all, or no library entry for this program. The stub is a `PipelineState` that `create_graphics` / `create_compute` return `S_OK` for before any Vulkan pipeline is built. It's never registered, so: - `compute_pipeline_id` / `graphics_pipeline_id` give 0; - `SetPipelineState` binds no PSO; - the command list sees that the bound pipeline state is a stub (`pipeline_is_stub`) and records nothing for `DrawInstanced`, `DrawIndexedInstanced`, `Dispatch`, `DispatchMesh` and `ExecuteIndirect` while it is bound. `Close` succeeds and the list holds none of them. With no pipeline state bound at all, the same calls still make `Close` fail, as before. No game shader is translated or run, and nothing the title draws reaches the screen. Like `LEONIDA_SKIP_INT3`, this is a diagnostic for finding the next boot stop, not a way to play. - Off by default; `0` or empty is off too. - Every other refusal is unchanged: bad descriptions, set-0 or LDS limits, an ambiguous FSPX program. - Each stub is logged with a power-of-two count: `[rt] d3d12: LEONIDA_STUB_PIPELINES: compute pipeline without a translated shader is a no-op stub (64 so far)`. On the retail executable (my own copy, local integration tree with the open boot PRs), the switch takes the run past stop 18. The builder's programs and the title's 64 compute pipelines are stubbed, and the title gets as far as recording frames and reaching `PresentX`. Integration report: `#7231` comment 7107135285. ### Changes - `runtime/shims/d3d12_vulkan_device.cpp`: `stub_pipelines()` and `stub_or()` in `PipelineState`, used at four places: - the library check in `create_graphics`; - the library check in `create_compute`; - the missing-entry return in `create_graphics`; - the missing-entry return in `create_compute`. - `runtime/test/d3d12_stub_pipelines_test.cpp` (new), registered next to `d3d12_draw`, with skip code 77 when there is no Vulkan device. With `LEONIDA_SHADERS` unset, it checks a graphics PSO description: - switch unset: `E_FAIL` and no object; - `0`: the same; - `1`: `S_OK`, an object, and `graphics_pipeline_id` / `compute_pipeline_id` 0; - with a null VS it is still `E_INVALIDARG`. - `runtime/test/d3d12_fspx_compute_test.cpp`: with a loaded library and the switch on, a compute PSO whose kind-0 state has no translation is stubbed (`S_OK`), while the bare kind-6 program with two differing translations (ambiguous) is still `E_INVALIDARG`. - `runtime/shims/d3d12_com.cpp`, `d3d12_com.h`: `pipeline_is_stub`, and `stub_pipeline_` in the command list, set by `SetPipelineState` and `Reset`. A stub no longer logs "pipeline from another device". - `runtime/test/d3d12_stub_pipelines_test.cpp` also binds the stub, draws, draws indexed and dispatches, and checks `Close() == S_OK` with no recorded command. The control is the same draw with no pipeline state: `E_INVALIDARG`. - `docs/boot.md`: the switch, next to the other diagnostic switches. ### Tested Windows 11 Pro 26200, RTX 3060, clang-cl/xwin cross build (MSVC 14.44 headers), RelWithDebInfo: - `d3d12_stub_pipelines_test`: PASS. - With the `d3d12_vulkan_device.cpp` change stashed, it FAILs at the `S_OK` and object checks. - `d3d12_fspx_compute_test`: PASS. With the ambiguity return reverted (ambiguous program stubbed), it FAILs at the ambiguous check. - `f8dad8586` (the stub's draws and dispatches): with the `d3d12_com.cpp` change reverted, the test FAILs at both `Close() == S_OK` checks; with it, PASS. Together with `d3d12_draw`, `d3d12_compute`, `d3d12_close_parity`, `d3d12_execute_indirect_validation`, `d3d12_bundle`, `d3d12_bundle_forbidden` and `command_list`: 8/8 pass, on this head and with the same change on `main` `f5bcc679d`. - Not run on current `main` `f48adad76`: `runtime/` does not compile there with this toolchain (three errors around `create_console_descriptor_heap`, in files this PR does not touch). - The test creates a Vulkan device and one stub PSO. No shader runs on the GPU and no game data is used. ### Thanks - `@lines9686-rgb`: `#7007`, the no-PSO no-op this first relied on. - `@AAyberkU` and `@TanmaySatyam`: both found that a stub's draws and dispatches made `Close` fail, against the description. Fixed in `f8dad8586` along the lines TanmaySatyam suggested (a stub flag on the list). - `@KkelebekK` and `@sennecools`: the stop 18 measurements (builder programs, compile time, watchdog) that showed why a boot needs a way past it. - `@MartinIndra02`: tested it on an RTX 3080 with MSVC (pass). - `@KarolKurzyna`: tested it on an RTX 3070 Ti and an Intel UHD 770 with validation on and off. The review also caught the MSVC `C4996` on `std::getenv`, fixed by reading the switch with `GetEnvironmentVariableW`, and noted that the compute and loaded-library paths had no test. - `@Alpha325`: caught that an ambiguous FSPX program was stubbed in the compute path, against the description; now refused with `E_INVALIDARG`, with a synthetic loaded-library test. - `@Kadthicu`: tested on an RTX 3060 with MSVC, with a negative control for the ambiguous FSPX program. - `@sh1shu1`: ran it on the retail executable on an RTX 4070 SUPER (stop 18 without the switch, stops 26 and 27 with it) and saw the failing `Close` on a stubbed list. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#96
No description provided.