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

Open
github-bot wants to merge 5 commits from github-bot/gh-42 into main AGit
Owner

@⁠Andretuta on GitHub · 2026-11-24 02:06 UTC · original
ubiquitarianism:old-pr/7417 → main · +199 −10 · 7 files · 5 commits · draft

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.
**@⁠Andretuta** on GitHub · 2026-11-24 02:06 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/42) `ubiquitarianism:old-pr/7417` → `main` · +199 −10 · 7 files · 5 commits · draft > 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.
A diagnostic switch for following a boot without translated shaders. When a
graphics or compute pipeline has no shader library, or no library entry for
its program, CreateGraphicsPipelineState / CreateComputePipelineState return
S_OK with a pipeline that is never registered: SetPipelineState then binds
no PSO and the draws and dispatches recorded with it are no-ops (D3D-482).
Off by default; every other refusal is unchanged.

d3d12_stub_pipelines_test: with no library, a graphics PSO is E_FAIL with
the switch off or "0", S_OK and unregistered with it on, and a bad
description is still E_INVALIDARG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
KarolKurzyna's review on #7417.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A bare kind-6 program whose translations differ has translations; it is
refused with E_INVALIDARG even with the switch on, as the description
says. Only a missing translation becomes a stub. d3d12_fspx_compute_test
checks both with a loaded library: an unknown kind-0 state is stubbed,
the ambiguous bare program is still refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
LEONIDA_STUB_PIPELINES documented a stub's draws and dispatches as no-ops, but SetPipelineState on a stub left no
pipeline bound, so record_draw, record_dispatch and DispatchMesh marked the list invalid and Close returned
E_INVALIDARG: the whole list was dropped at ExecuteCommandLists. Reported by AAyberkU and TanmaySatyam on #7417.

The command list now knows when the bound pipeline state is a stub (pipeline_is_stub: this device's pipeline state
holding no pipeline) and records nothing for DrawInstanced, DrawIndexedInstanced, Dispatch, DispatchMesh and
ExecuteIndirect while it is bound. With no pipeline state at all the same calls still make Close fail.

d3d12_stub_pipelines_test: red before the change (Close == S_OK fails at the two stub lists), green after; the
control (no pipeline state) stays E_INVALIDARG. 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
on main f5bcc679d (clang-cl, RTX 3060 610.88).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Two conflicts in runtime/shims/d3d12_com.cpp, both additive:
- ExecuteIndirect: main's new argument validation is kept, and the stub return stays after it.
- command list members: stub_pipeline_ next to main's descriptor heap members.

d3d12_com.cpp and d3d12_stub_pipelines_test.cpp compile on the merged tree. The D3D12 library as a whole does not
link here: d3d12_vulkan_device.cpp has main's own two errors in create_console_descriptor_heap.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:42:02 +00:00
This pull request has changes conflicting with the target branch.
  • docs/boot.md
  • runtime/CMakeLists.txt
  • runtime/shims/d3d12_com.cpp
  • runtime/shims/d3d12_com.h
  • runtime/shims/d3d12_vulkan_device.cpp
  • runtime/test/d3d12_stub_pipelines_test.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/42/head:github-bot/gh-42'
git switch 'github-bot/gh-42'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-42'
git switch 'github-bot/gh-42'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-42'
git switch 'github-bot/gh-42'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-42'
git switch 'main'
git merge --squash 'github-bot/gh-42'
git switch 'main'
git merge --ff-only 'github-bot/gh-42'
git switch 'main'
git merge 'github-bot/gh-42'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.