[PR #1308] runtime: a pipeline cache from the runtime's own device (RT-RUNTIME-PIPELINE-CACHE) #1338

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

📋 Pull Request Information

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

Base: main ← Head: rt-runtime-pipeline-cache


📝 Commits (1)

  • 8fb2bde runtime: a pipeline cache from the runtime's own device (RT-RUNTIME-PIPELINE-CACHE)

📊 Changes

6 files changed (+168 additions, -5 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+15 -1)
📝 runtime/CMakeLists.txt (+7 -0)
📝 runtime/shims/d3d12_com.h (+5 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+61 -3)
📝 runtime/src/vulkan_backend.h (+1 -1)
➕ runtime/test/pso_warmup.cpp (+79 -0)

📄 Description

Item: RT-RUNTIME-PIPELINE-CACHE (claimed in #14). Complements #218, which persists the cache at device teardown.

Why

The pipelines stage's pipeline_cache.bin passes the runtime's header check, but it misses for the runtime's
pipelines
. A driver keys its cache on the device's enabled extensions and features, and vk_pipeline_check
creates a different device. The runtime enables 17 extensions the checker doesn't (mesh shader,
maintenance5/8, shader FMA and clock, fragment barycentrics and interlock among them), and the two build their
feature lists differently: the checker sets every core feature through Features2 and the 1.1/1.2/1.3 structs,
the runtime a subset through per-extension structs. I diffed both VkDeviceCreateInfos with a local dump.

Measured on an RTX 3070, driver 32.0.16.1692, with the retail 1.0.2.1 BVH builder's 52 compute programs:

Largest program (LoadInstances) All 52
vk_pipeline_check, cold 28.5 s 63 s total compile
vk_pipeline_check, re-run on its own cache 0.01 s (hit)
runtime, the checker's cache loaded ~28 s (miss)
pso_warmup (runtime device), cold 27.8 s 63 s
pso_warmup, re-run on its own cache under 1 s (hit) 5.7 s

This matters for booting. The title creates the BVH builder's pipelines on its graphics-init thread, and its own
watchdog ends the process after about 26 s, so the cold 28 s compile kills every launch the same way, with nothing
in the log. With a pso_warmup cache beside gta6rt.exe, the #432 stack on native Windows gets past graphics init
and into its frame loop (details in #14).

Change

  • DeviceState::save_pipeline_cache(path): vkGetPipelineCacheData written through a temporary file and renamed.
    rt::d3d12::save_pipeline_cache(ID3D12Device*, path) exposes it for a device from create_vulkan_device*.
    vkGetPipelineCacheData is added to the backend's function table.
  • pso_warmup <dir of .dxbc compute programs> <out file> (runtime/test/pso_warmup.cpp, built with the other
    Windows tools): builds every program through CreateComputePipelineState on create_vulkan_device_standalone,
    then writes that device's cache. It needs LEONIDA_SHADERS and the user's carved programs; nothing of the game is
    in the source.
  • LEONIDA_PIPELINE_CACHE_OUT=<file>: the runtime saves after every compute compile of 250 ms or more, so a run
    that ends without a teardown (a watchdog, a crash) keeps what it compiled.
  • A compute compile of 1 s or more is logged with the shader's name.
  • docs/d3d12_vulkan.md section 4: replaces the sentence implying the checker's cache serves the runtime with the
    measurement and both new paths.

Not in this PR: wiring pso_warmup into make_game.py's pipelines stage, and the graphics PSO path. Both are
follow-ups once this shape is agreed.

Tested

  • Windows 11, VS 2022 RelWithDebInfo, NVIDIA RTX 3070, driver 32.0.16.1692.
  • The measurements above, on the user's own 1.0.2.1 copy.
  • gta6rt and pso_warmup build without new warnings. tests/test_docs_env_vars.py and
    tests/test_text_write_line_endings.py pass. check_no_game_data.py on every changed file passes.

AI-assisted (Claude Code).

🤖 Generated with Claude Code


🔄 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/1308 **Author:** [@Daolyap](https://github.com/Daolyap) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `rt-runtime-pipeline-cache` --- ### 📝 Commits (1) - [`8fb2bde`](https://github.com/ubiquitarianism/leonida/commit/8fb2bdea47beada1098407dd08e5ffff6c3098f3) runtime: a pipeline cache from the runtime's own device (RT-RUNTIME-PIPELINE-CACHE) ### 📊 Changes **6 files changed** (+168 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+15 -1) 📝 `runtime/CMakeLists.txt` (+7 -0) 📝 `runtime/shims/d3d12_com.h` (+5 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+61 -3) 📝 `runtime/src/vulkan_backend.h` (+1 -1) ➕ `runtime/test/pso_warmup.cpp` (+79 -0) </details> ### 📄 Description Item: **RT-RUNTIME-PIPELINE-CACHE** (claimed in #14). Complements #218, which persists the cache at device teardown. ## Why The `pipelines` stage's `pipeline_cache.bin` passes the runtime's header check, but it **misses for the runtime's pipelines**. A driver keys its cache on the device's enabled extensions and features, and `vk_pipeline_check` creates a different device. The runtime enables 17 extensions the checker doesn't (mesh shader, maintenance5/8, shader FMA and clock, fragment barycentrics and interlock among them), and the two build their feature lists differently: the checker sets every core feature through `Features2` and the 1.1/1.2/1.3 structs, the runtime a subset through per-extension structs. I diffed both `VkDeviceCreateInfo`s with a local dump. Measured on an RTX 3070, driver 32.0.16.1692, with the retail 1.0.2.1 BVH builder's 52 compute programs: | | Largest program (`LoadInstances`) | All 52 | |---|---|---| | `vk_pipeline_check`, cold | 28.5 s | 63 s total compile | | `vk_pipeline_check`, re-run on its own cache | **0.01 s (hit)** | | | runtime, the checker's cache loaded | **~28 s (miss)** | | | `pso_warmup` (runtime device), cold | 27.8 s | 63 s | | `pso_warmup`, re-run on its own cache | under 1 s (hit) | **5.7 s** | This matters for booting. The title creates the BVH builder's pipelines on its graphics-init thread, and its own watchdog ends the process after about 26 s, so the cold 28 s compile kills every launch the same way, with nothing in the log. With a `pso_warmup` cache beside `gta6rt.exe`, the #432 stack on native Windows gets past graphics init and into its frame loop (details in #14). ## Change - `DeviceState::save_pipeline_cache(path)`: `vkGetPipelineCacheData` written through a temporary file and renamed. `rt::d3d12::save_pipeline_cache(ID3D12Device*, path)` exposes it for a device from `create_vulkan_device*`. `vkGetPipelineCacheData` is added to the backend's function table. - `pso_warmup <dir of .dxbc compute programs> <out file>` (`runtime/test/pso_warmup.cpp`, built with the other Windows tools): builds every program through `CreateComputePipelineState` on `create_vulkan_device_standalone`, then writes that device's cache. It needs `LEONIDA_SHADERS` and the user's carved programs; nothing of the game is in the source. - `LEONIDA_PIPELINE_CACHE_OUT=<file>`: the runtime saves after every compute compile of 250 ms or more, so a run that ends without a teardown (a watchdog, a crash) keeps what it compiled. - A compute compile of 1 s or more is logged with the shader's name. - `docs/d3d12_vulkan.md` section 4: replaces the sentence implying the checker's cache serves the runtime with the measurement and both new paths. Not in this PR: wiring `pso_warmup` into `make_game.py`'s `pipelines` stage, and the graphics PSO path. Both are follow-ups once this shape is agreed. ## Tested - Windows 11, VS 2022 RelWithDebInfo, NVIDIA RTX 3070, driver 32.0.16.1692. - The measurements above, on the user's own 1.0.2.1 copy. - `gta6rt` and `pso_warmup` build without new warnings. `tests/test_docs_env_vars.py` and `tests/test_text_write_line_endings.py` pass. `check_no_game_data.py` on every changed file passes. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <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#1338
No description provided.