mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:45:54 +01:00
[PR #1950] [MERGED] d3d12: write the session pipeline cache when the run ends with the device alive (RT-SESSION-CACHE-AT-EXIT) #1956
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1956
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1950
Author: @kurrutako
Created: 11/25/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142
Base:
main← Head:rt/session-cache-at-exit📝 Commits (5)
f95b23ed3d12: write the session pipeline cache when the run ends with the device alive (RT-SESSION-CACHE-AT-EXIT)27a861agta6rt: keep the exit-save filter when the title installs its own (RT-SESSION-CACHE-AT-EXIT)a26b127d3d12: the exit save writes the finished pipelines while a build runs, on a bounded thread (RT-SESSION-CACHE-AT-EXIT)98c457egta6rt: threads that fault together wait for the first one's cache write (RT-SESSION-CACHE-AT-EXIT)2e61d40docs: when the session pipeline cache is written at exit (RT-SESSION-CACHE-AT-EXIT)📊 Changes
5 files changed (+155 additions, -13 deletions)
View changed files
📝
docs/d3d12_vulkan.md(+6 -1)📝
runtime/shims/d3d12_compile_exit.h(+7 -0)📝
runtime/shims/d3d12_vulkan_device.cpp(+73 -2)📝
runtime/src/main.cpp(+48 -0)📝
runtime/test/d3d12_compile_teardown_test.cpp(+21 -10)📄 Description
RT-SESSION-CACHE-AT-EXIT, claimed in #1608.
What
pipeline_cache.session.binwas written only in~Device. A title never releases its device, so a real boot kept none of what it compiled, and every boot built the world start again.save_pipeline_caches_at_exit(wait_ms)(shims/d3d12_compile_exit.h) writes the session cache of every live device. The live devices are a list that theDeviceconstructor and destructor maintain. It runs once per process, afterstop_pipeline_compiles.gta6rtcalls it at the run's exit, at a console close (Ctrl+C, Ctrl+Break, close), and from an unhandled-exception filter: a fault in the title or one of its DLLs, or the int3 after a device loss. The filter then passes the exception on, so the exit code is the exception's, as before.SetUnhandledExceptionFilterfromapi-ms-win-core-errorhandling-l1-1-0, which replaced the runtime's filter (measured: a title fault at 354 s wrote nothing). The runtime now serves that call: its own filter stays first and hands the exception to the title's, as Windows would.wait_ms(1 s); then the cache is written with the pipelines finished so far. This is valid because the cache is not createdEXTERNALLY_SYNCHRONIZED. Unlike at teardown, the previous file is not kept: the process is ending, so keeping it would throw away the whole run (measured: a 1,308 s boot ended with 2 builds running).CacheStagingFilepublishes by rename, so a write cut off leaves the previous file whole.std::call_once), so none reaches the title's filter, which may end the process, in the middle of it.~Deviceand the checkpoints are unchanged. The size limit is #1886's subject; see below.Measured
Retail boots on Windows 11, RTX 5070 12 GB, NVIDIA 621.01. Build:
main+ #1851, #1827, #1849, #1862 (shaders retranslated with it: 29/29 FSPX) + #1886, withLEONIDA_HOST_IMAGE_COPY=0 LEONIDA_ASYNC_PIPELINES=1 LEONIDA_DEVICE_TYPE=6 LEONIDA_ARENA_MB=2048 LEONIDA_TITLE_WATCHDOG=0 LEONIDA_DEVICE_FAULT=1, a person at the keyboard pad. Counted: the runtime'stook N s to buildlines.wrote 436563293 bytesloaded 436563293 bytes)wrote 510225527 bytesover the 268435456-byte write limit). This change makes the write happen; #1886 lets it through at this size.Tests
d3d12_compile_teardown_test, exit case: with the device still alive afterstop_pipeline_compiles,save_pipeline_caches_at_exitwrites the session file, and a second call does nothing. It passes on the RTX 5070 (MSVC 2022, RelWithDebInfo); on llvmpipe the file stays absent, as in the existing cache case. The exception-filter path is checked by the boots above. Counts, offsets and program names only; no game data;python -I scripts/check_no_game_data.pypasses.AI-assisted.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.