Skip to content

d3d12: LEONIDA_STUB_COMPUTE_WORDS stubs compute pipelines over n SPIR-V words - #9250

Closed
AAyberkU wants to merge 1 commit into
ProjectLeonida:mainfrom
AAyberkU:stub-compute-words
Closed

AAyberkU wants to merge 1 commit into
ProjectLeonida:mainfrom
AAyberkU:stub-compute-words

Conversation

@AAyberkU

Copy link
Copy Markdown
Contributor

Claimed in #9065 (comment) (first posted in #8868).

What

  • LEONIDA_STUB_COMPUTE_WORDS=<n> is a diagnostic, off by default. A compute pipeline whose translated SPIR-V module is larger than n 32-bit words is created as a no-op stub instead of being compiled, the same way LEONIDA_STUB_PIPELINES (d3d12: LEONIDA_STUB_PIPELINES, a pipeline without a translated shader is a no-op stub (boot past stop 18) #7417) stubs a pipeline without a translated shader:

    • it returns S_OK and makes no shader module, layout or Vulkan pipeline;
    • the stub is never registered, so SetPipelineState binds no compute pipeline.

    Unset, 0 or a value that isn't a number means off. Refusals that happen before the module is read are unchanged: unknown program, LDS over the device limit, missing set 0.

  • Every compute pipeline compile over 2 s is logged once, with its duration, word count, program SHA-256 and VkResult. That log is where a value for n comes from. d3d12: checkpoint slow compute pipeline compiles #7535 times compiles for its cache checkpoint but logs nothing. Both PRs touch the same call, so whichever lands second needs a trivial rebase.

  • The switch is documented in docs/boot.md "Useful switches", and the test is listed in runtime/README.md.

Why

Measured on the retail title, RTX 5060 Ti, with a cold pipeline cache (#8851):

  • About 10 title job threads sit in the NVIDIA compiler for minutes. Single compute pipelines take 16 to 137 s.
  • 71 translated compute modules are over 100k words, and the largest are 2.0 to 2.3M words.
  • Only about 180 compute pipelines are created in 3 min, and file loading stalls behind them.
  • With LEONIDA_STUB_COMPUTE_WORDS=100000, loading continues: about 9.6 GB read, about 2,700 compute pipelines, and per-frame draws.

Note: a dispatch with a stub behaves like any dispatch without a bound compute pipeline. It is dropped and marks its list invalid, so Close returns E_INVALIDARG. The docs say so.

Tested

  • New d3d12_stub_compute_words_test, using a synthetic FSSM program and test/glsl/cs_user_data.comp, with no game data. It skips with 77 without a Vulkan device.
    • The same PSO is registered when the switch is unset, at n equal to its word count (1670), at 0, at "100k" and at a 20-digit value.
    • It is an unregistered stub at n = 1669 and at n = 1.
    • An untranslated program is still E_INVALIDARG.
  • d3d12_compute and d3d12_fspx_compute still pass.
  • scripts/check_no_game_data.py is clean on all changed files.
  • Windows 11, MSVC 2022 RelWithDebInfo, -DLEONIDA_REQUIRE_VULKAN=ON, Vulkan SDK 1.4.363, NVIDIA GeForce RTX 5060 Ti, driver 621.01.

AI-assisted (Claude Code). Reviewed and tested as above.

🤖 Generated with Claude Code

https://claude.ai/code/session_016ABh377Xfov1ZDULWTYvTm

…-V words

A diagnostic switch for cold-cache boots. A compute pipeline whose
translated module is over n 32-bit words is created as a no-op stub, like
a pipeline without a translated shader under LEONIDA_STUB_PIPELINES: S_OK,
no shader module, layout or Vulkan pipeline, never registered, so
SetPipelineState binds no compute pipeline. Unset, 0 or not a number is
off; every refusal before the module is read is unchanged.

Every compute pipeline compile over 2 s is now logged once with its time,
word count, program SHA-256 and VkResult, which is where a value for n
comes from.

d3d12_stub_compute_words_test: the same PSO is registered when unset, at
n equal to its word count, at 0 and at values that are not a word count,
and an unregistered stub below it; an untranslated program is still
E_INVALIDARG.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016ABh377Xfov1ZDULWTYvTm

@Grimkaaah Grimkaaah left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Independent Linux CPU review

Checked: LEONIDA_STUB_COMPUTE_WORDS diagnostic stub for oversized compute SPIR-V; docs/boot.md + README + d3d12_stub_compute_words_test + CMake. Windows/D3D12 path not run here.

Looks correct from review; no game files.

@al3xar al3xar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Independent Windows + GPU + Vulkan validation verification of 1d02e658d (AI-assisted).

  • Environment: Windows 11 x64, MSVC 19.44.35230.0 (Ninja Release), Windows SDK 10.0.26100.0, NVIDIA GeForce RTX 3060 (driver 621.24), Vulkan SDK 1.4.363.0 (LEONIDA_VK_VALIDATION=1), no game files.
  • Test runs (LEONIDA_VK_VALIDATION=1):
    • d3d12_stub_compute_words_test: PASS (PASS: 1670-word module compiled at n=1670 and stubbed at n=1669, exit 0, 0 Vulkan validation errors).
    • d3d12_compute_test: PASS (exit 0, 0 Vulkan validation errors).
  • Negative control: Reverted runtime/shims/d3d12_vulkan_device.cpp to upstream/main (867d922f0) and re-ran d3d12_stub_compute_words_test → FAIL (line 101: create(device.p, desc) == 0, exit 1).
  • Code review:
    • stub_compute_words() safely caps decimal parsing at 19 digits (fits in 64-bit std::size_t without overflow) and treats unset/0/non-numeric/overflow as off.
    • Power-of-two rate-limited stub logging and > 2000 ms slow-compile logging are clean and leak no Vulkan objects; stubbing occurs before vkCreateShaderModule / vkCreateComputePipelines while preserving pre-read refusals (E_INVALIDARG).

LGTM.

@smowlyy

smowlyy commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Verified on native Windows 11 (10.0.26300.9974, MSVC 19.44, RelWithDebInfo, Vulkan SDK 1.4.363.0, NVIDIA GeForce RTX 5060 Ti driver 610.88 / Vulkan 1.4.341), PR head 1d02e658d merged onto main (6312c057f):

  • python -I scripts/check_no_game_data.py ... (all 5 changed files): clean (exit 0).
  • cmake --build runtime/build --target d3d12_stub_compute_words_test --parallel: built cleanly.
  • LEONIDA_VK_VALIDATION=1 ctest --test-dir runtime/build -R d3d12_stub_compute_words --output-on-failure -V: 1/1 passed (PASS: 1670-word module compiled at n=1670 and stubbed at n=1669, 0 validation errors).

AI-assisted.

@MonkeyPython

Copy link
Copy Markdown

Independent Windows check: PASS

Tested 1d02e658 merged onto current main 6312c057 (clean merge) on Windows 11 Pro build 26300, MSVC 14.51.36231 (VS Community 2026), Ninja RelWithDebInfo, -DLEONIDA_REQUIRE_VULKAN=ON, Vulkan SDK 1.4.363.0, NVIDIA GeForce RTX 3080 Ti, driver 621.24 (32.0.16.2124).

AI-assisted: yes

@AAyberkU

Copy link
Copy Markdown
Contributor Author

A retail-boot measurement that shows what this switch buys. Base: GitHub main + the boot PRs + #7021 + #9137 + #9276/#9014 + #7858 (new head) + #9586. RTX 5060 Ti, driver 621.01. AI-assisted.

Same run, without and with LEONIDA_STUB_COMPUTE_WORDS=100000 (12 modules stubbed):

without with
title file I/O by 40 s 3.86 GB 8.3 GB (9.1 GB by 50 s)
CreateCommittedResource3 32 171
slot-133 placed resources 3 226
Dispatch 0 170
longest compute compile 244 s under 2 s

Without the stub, the title waits minutes on a cold cache for each of a few compute modules of about 1M words, and loading stalls about 30 s in. With it, loading runs until the next stop, which I'm reporting on #8851.

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.

6 participants