Skip to content

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

Open
rafaelpssz wants to merge 5 commits into
ProjectLeonida:mainfrom
rafaelpssz:feat/stub-pipelines
Open

rafaelpssz wants to merge 5 commits into
ProjectLeonida:mainfrom
rafaelpssz:feat/stub-pipelines

Conversation

@rafaelpssz

@rafaelpssz rafaelpssz commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Claimed in the coordination issue: #7231 (comment)

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: D3D-482: Draw, Dispatch and ExecuteIndirect(DISPATCH) recorded with no PSO are no-ops, as on the host D3D12 runtime #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.

… shader as a no-op stub

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 <noreply@anthropic.com>
@MartinIndra02

Copy link
Copy Markdown
Contributor

Independent Windows + GPU test of aae44fc47: pass.

Setup: Windows 11 x64, MSVC 19.44.35220 (RelWithDebInfo, Windows SDK 10.0.26100.0), NVIDIA GeForce RTX 3080 (driver 32.0.16.2124 / 621.24), Vulkan SDK 1.4.363.1, no game files.

  • d3d12_stub_pipelines_test.exe: PASS (exit 0) — confirms unset/0 returns E_FAIL, LEONIDA_STUB_PIPELINES=1 returns S_OK with id 0 stub, and null VS still returns E_INVALIDARG.

AI-assisted review/test.

@Xiiano Xiiano left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot:
Review complete. Verdict: approve / no blocking findings. The diff is narrowly scoped, preserves existing validation and refusal behavior, and the added test covers the switch's off, explicit-zero, enabled, unregistered-stub, and invalid-description cases. There are no existing review comments; all five CI checks were still queued.

@KarolKurzyna

Copy link
Copy Markdown
Contributor

Independent native Windows 11 dual-GPU review of aae44fc471ad682b968e24a35c68484e84ea14d0 (plus clean merge check onto origin/main 48ff424): PASS (with two non-blocking notes below).

Environment

  • OS / Toolchain: Windows 11 x64 (10.0.26300), MSVC 19.52.37029 (VS 2026), Windows SDK 10.0.26100.0, CMake + Ninja RelWithDebInfo, Khronos Validation Layer 1.4.363
  • GPUs: NVIDIA GeForce RTX 3070 Ti (driver 621.24, Vulkan 1.4.357) and Intel(R) UHD Graphics 770 (driver 101.6129, Vulkan 1.3.295)
  • Layers: VK_LOADER_LAYERS_DISABLE=~implicit~, DISABLE_VULKAN_OBS_CAPTURE=1, DISABLE_RTSS_LAYER=1

Results

  • Exact PR head (aae44fc471):
    • d3d12_stub_pipelines_test: PASS on both RTX 3070 Ti and Intel UHD Graphics 770 with LEONIDA_VK_VALIDATION both off and on (0 Vulkan validation errors; logs [rt] d3d12: LEONIDA_STUB_PIPELINES: graphics pipeline without a translated shader is a no-op stub (1 so far)).
    • Regression checks on RTX 3070 Ti (LEONIDA_VK_VALIDATION=1): ctest -R "^(d3d12_stub_pipelines|d3d12_draw|d3d12_compute)$" — 3/3 PASS.
  • Clean merge onto origin/main (48ff424): merges cleanly; d3d12_stub_pipelines_test PASS on both RTX 3070 Ti and Intel UHD Graphics 770 with LEONIDA_VK_VALIDATION=1.

Non-blocking notes

  1. MSVC /W4 warning C4996: runtime/shims/d3d12_vulkan_device.cpp(3158) (std::getenv("LEONIDA_STUB_PIPELINES")) emits warning C4996: 'getenv': This function or variable may be unsafe. Using getenv_s (like LEONIDA_RT_AS in the same file) or GetEnvironmentVariableW avoids the warning.
  2. Test coverage scope: d3d12_stub_pipelines_test.cpp exercises CreateGraphicsPipelineState with no shader library; CreateComputePipelineState and the loaded-library missing-entry path aren't covered yet.

Synthetic tests only, no game data. AI-assisted.

…4996 under MSVC /W4)

KarolKurzyna's review on ItsNotRexed#7417.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rafaelpssz

Copy link
Copy Markdown
Collaborator Author

@KarolKurzyna thanks for the two-GPU run. 1: fixed in 9c99166. The switch is now read with GetEnvironmentVariableW, so there's no C4996 (d3d12_stub_pipelines_test still passes). 2: right. The compute path and the loaded-library, missing-entry path need a hand-built FSSM program in a library index to get past compute_program(), so I'll add those as a follow-up rather than grow this one. @MartinIndra02 thanks for the RTX 3080 run, you're both in Thanks.

@Alpha325

Copy link
Copy Markdown

Source review at aae44fc471: the compute missing-entry path also stubs an ambiguous FSPX program. program_candidates(..., &ambiguous) can return no entry with ambiguous == true; that branch prints the ambiguity diagnostic and then reaches the same stub_or(E_INVALIDARG, "compute") as a missing translation. With LEONIDA_STUB_PIPELINES=1, it therefore returns S_OK. The PR description explicitly says ambiguous programs still refuse creation.

Please return E_INVALIDARG for ambiguity before calling stub_or, and add a synthetic loaded-library case with two differing translations for one bare kind-6 program. That would keep this diagnostic limited to missing translations as described.

AI-assisted source review. I checked this branch directly; I have not built or run this PR.

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 <noreply@anthropic.com>
@rafaelpssz

Copy link
Copy Markdown
Collaborator Author

@Alpha325 Good catch, thanks. Fixed in 780d1a4: in create_compute, an ambiguous program now returns E_INVALIDARG before stub_or, so only a missing translation is stubbed.

I added the synthetic case to d3d12_fspx_compute_test (it already loads a library with two differing translations of one bare kind-6 program). With LEONIDA_STUB_PIPELINES=1, a container whose kind-0 state has no translation is stubbed (S_OK) and the bare ambiguous program is still E_INVALIDARG. It passes on an RTX 3060, and with the fix reverted it fails at the ambiguous check. That also covers the compute and loaded-library paths @KarolKurzyna noted.

@Kadthicu

Copy link
Copy Markdown
Contributor

Independent Windows GPU check of PR #7417 at 780d1a41.

  • RTX 3060 12 GB, NVIDIA 610.88, Vulkan 1.4.341, Windows 11 x64 (26200).
  • Built locally with MSVC 19.44 and Vulkan SDK 1.4.363.0. Implicit Vulkan layers disabled for the test processes.
  • PR head: d3d12_stub_pipelines and d3d12_fspx_compute both passed (2/2).
  • Negative control: copied only the updated FSPX test onto parent 9c991669. It failed the bare_hr == E_INVALIDARG && !still_bare.p assertion because the ambiguous program received a stub. On 780d1a41, the ambiguous program is rejected and the missing translation still receives a stub.
  • Upstream main dde82f2: its stock d3d12_fspx_compute passed (1/1).

Synthetic fixtures only. Retail boot and PresentX were outside this check. AI-assisted with Codex.

tibzejoker added a commit to tibzejoker/Leonida that referenced this pull request Nov 23, 2026
Only the PR's own commit is applied (its branch also carries 49 newer main commits, left out). Slot 57 handler and its dispatch added beside slots 17-24 and the lease/initial-state code; in the Vulkan layer the new FSSM/FSPX lookup keeps ItsNotRexed#7417's stub_or on both 'no translated shader' paths. device_proxy_test: the fspx_gfx spv filename check expects the folder prefix the loader adds.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@AAyberkU

AAyberkU commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

finding: with a stubbed pipeline, a dispatch or draw is not a no-op on main's replay. record_dispatch (and the draw path) find no bound pipeline, mark the list invalid, and that list's Close returns E_INVALIDARG, which drops the whole list at ExecuteCommandLists. The docs here say "no-op". I hit this while writing #9250 (the same stub idea, keyed on SPIR-V module size), whose docs state the real behaviour. Either the docs should say so, or the stub should bind a real empty pipeline so the dispatch really is a no-op. No game files needed: a synthetic stubbed PSO plus one Dispatch shows it.

AI-assisted (Claude Code).

@TanmaySatyam

Copy link
Copy Markdown

Heads-up from testing LEONIDA_STUB_PIPELINES=1 on a retail 1.0.2.1 boot integration stack (Windows 11 + NVIDIA RTX 5070):

The comment in d3d12_vulkan_device.cpp notes that stub pipelines are never registered so their draws and dispatches are recorded as no-ops, but in runtime/shims/d3d12_com.cpp, SetPipelineState with an unregistered stub PSO leaves graphics_pipeline_ = 0 / compute_pipeline_ = 0, and record_draw(), record_dispatch(), and DispatchMesh() then call check(false) — causing ID3D12GraphicsCommandList::Close() to fail with E_INVALIDARG on lists that bind a stub PSO.

Tracking bool stub_pipeline_ when SetPipelineState receives a non-null unregistered PSO under LEONIDA_STUB_PIPELINES=1 (resetting it on Reset(), and returning early in record_draw, record_dispatch, and DispatchMesh) turns those draws/dispatches into true no-ops and keeps Close() returning S_OK. Mentioning it here so you can fold it into #7417 if you want (also filed as a finding: in #9235). AI-assisted.

@sh1shu1

sh1shu1 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 780d1a4 (as merged in tibzejoker:rt5-integration 5fef1f1) on RTX 4070 SUPER 616.92, Windows 11 26200, Intel i7-8700, MSVC RelWithDebInfo, retail executable (own 1.0.2.1 copy): pass. Without the switch the run ends at stop 18 (C++ throw in XboxBvhBuilder.dll, 1,640 D3D12 calls); with LEONIDA_STUB_PIPELINES=1 it reaches stop 26 (13,091 calls; 1,024+ graphics and 64+ compute stubs logged) and, with LEONIDA_SKIP_INT3=1, stop 27 (62,594 calls). One Close fails on a stubbed list here because #7007 is not in that tree. Not run: the PR's own tests. Counts in #9401 (comment). AI-assisted (Claude Code, Claude Fable 5.1).

dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
…wn containers

Slot 57 (desc, riid, out) gets a 0x108-byte description: root signature, state
blobs A and B, and seven {code, records} stage blocks (layout from issue ItsNotRexed#7496,
contents from ItsNotRexed#7049). Each stage's records carry the source container's HASH
digest; tools/native_pso_hashes.py (run by the shaders stage) maps digests to
containers in <spirv>/native_hashes.txt, and the proxy hands those containers
to PC CreateGraphicsPipelineState (VS/GS/PS) or a Device2 MS stream, so the
Vulkan device finds the translated modules by fssm_sha256 as for a PC title.

Blob B gives formats, sample state, topology and the input layout; blob A is
not decoded (blend off, cull none, depth ALWAYS). An unresolved stage refuses
with E_NOTIMPL, or with LEONIDA_STUB_PIPELINES set asks the device for ItsNotRexed#7417's
stub; LEONIDA_NATIVE_PSO=0 refuses every call. The returned pointer must be
even (the title stores it shifted right by one).

Tests: native_pso_test (portable), xs_native_pso_test (mock device through the
proxy, under Wine), tests/test_native_pso_hashes.py; all inputs hand-built.
… list stays valid

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 ProjectLeonida#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 f5bcc67 (clang-cl, RTX 3060 610.88).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@rafaelpssz

Copy link
Copy Markdown
Collaborator Author

@AAyberkU @TanmaySatyam you were both right: a stub's draws and dispatches marked the list invalid and Close returned E_INVALIDARG. The description said so only through its dependency on #7007, and #7007 is closed now.

Fixed in f8dad8586, the way TanmaySatyam suggested:

  • SetPipelineState and Reset note when the bound pipeline state is a stub (pipeline_is_stub).
  • DrawInstanced, DrawIndexedInstanced, Dispatch, DispatchMesh and ExecuteIndirect record nothing while it is bound.
  • With no pipeline state at all, Close still fails as before.

The test now binds the stub, draws and dispatches, and checks Close() == S_OK with no recorded command. It fails at both checks without the change. 8/8 with the neighbouring list tests, on this head and on main f5bcc679d.

One thing I could not do: run it on current main f48adad76. runtime/ does not compile there with clang-cl (three errors around create_console_descriptor_heap, in files this PR does not touch).

@sh1shu1 that explains the one failing Close you saw on a stubbed list. @Kadthicu thanks for the negative control. Both of you are in Thanks.

@rafaelpssz rafaelpssz reopened this Nov 23, 2026
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.
@fortkolbast1

Copy link
Copy Markdown

Tried to build and run d3d12_stub_pipelines_test at this head on Windows 11 26200 (MSVC 14.51 / VS 18 Build Tools, CMake 4.4.4, Vulkan SDK 1.4.363).

It does not compile, so the test could not run:

runtime/shims/d3d12_vulkan_device.cpp(10028,36): error C2665: 'DescriptorHeap::DescriptorHeap': no overload matches
runtime/shims/d3d12_vulkan_device.cpp(10029,28): error C2248: 'Device::identity': private member
runtime/shims/d3d12_xs_device.cpp(1606,26):       error C3083: 'd3d12': the symbol at the end of '::' must be a type
runtime/shims/d3d12_xs_device.cpp(1606,33):       error C2039: 'create_console_descriptor_heap': is not a member of 'rt'
runtime/shims/d3d12_xs_device.cpp(1606,33):       error C3861: 'create_console_descriptor_heap': identifier not found

My reading: the merge this branch carries (0ba54d34d Merge main into feat/stub-pipelines) predates the current main, so the new code is written against the older Device/DescriptorHeap surface — the DescriptorHeap(DeviceState&, const D3D12_DESCRIPTOR_HEAP_DESC&, …) constructor and a non-public Device::identity, and create_console_descriptor_heap is not visible where d3d12_xs_device.cpp calls it. That matches mergeable: CONFLICTING.

So this one needs a rebase onto the new main before anything can be checked. Once it is rebased, I can build d3d12_stub_pipelines_test and run it here (the toolchain is ready); ping me on the new head.

No game files.

Approved by @fortkolbast1. AI-assisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.