Repository navigation
d3d12: write the session pipeline cache when the run ends with the device alive (RT-SESSION-CACHE-AT-EXIT) - #1950
Conversation
…vice alive (RT-SESSION-CACHE-AT-EXIT) pipeline_cache.session.bin was written only in ~Device. A title never releases its device, so a real boot kept none of what it compiled: not after a normal exit, a console close or a crash, and every boot built the world start again. save_pipeline_caches_at_exit writes the session cache of every live device (a registry the Device constructor and destructor keep), once per process, after stop_pipeline_compiles. A build still running on another thread is given wait_ms, then the previous file is kept, as at teardown. gta6rt calls it at the run's exit, at a console close, and from an unhandled-exception filter (a fault in the title or its DLLs, the int3 after a device loss), which then passes the exception on, so the exit code is unchanged. d3d12_compile_teardown_test's exit case checks that the file is written with the device alive, and only once. AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-SESSION-CACHE-AT-EXIT) The retail title calls SetUnhandledExceptionFilter (from api-ms-win-core-errorhandling-l1-1-0), which replaced the runtime's filter: a title fault at 354 s ended the process without the cache write. The title's call is now served by the runtime, which keeps its filter installed and passes the exception on to the title's. AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, on a bounded thread (RT-SESSION-CACHE-AT-EXIT) A 1,308 s boot ended in a title fault with 2 builds still running, and the exit save kept the old file, so the run's pipelines were lost again. At exit there is no later moment to wait for: after wait_ms the cache is written with the pipelines finished so far (it is not created EXTERNALLY_SYNCHRONIZED, so reading it during a build is valid). The write runs on its own thread and is given 3 s, so a driver that blocks the read cannot hold the ending process; the file is published by a rename, so a write cut off leaves the previous one whole. AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ite (RT-SESSION-CACHE-AT-EXIT) A boot ended with eight title threads faulting within a second. Each entered the filter; the ones after the first returned at once and went on to the title's filter, which can end the process during the write. The write now runs under std::call_once, so they wait for it. AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…CACHE-AT-EXIT) AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Test report from a combined build on a second NVIDIA machine. Counts only. Machine: Windows 11, RTX 4070 SUPER, NVIDIA 621.01, 64 GB, own 1.0.2.1 copy. Build: Shaders: translated on Pipeline cache: warm and complete, 26,503 of 26,503 (9.6 GB).
Recipe:
AI-assisted (Claude Code). |
|
Thanks for the test. Run 1 is the case this PR is for: the title's fatal exception went through the exit filter, the save ran while a build was still going, and it set out to write only the pipelines that had finished. The write was then refused by the 4 GiB cap from #1886, not by this PR. With an offline seed loaded, the driver's cache data is the seed plus the session, so a 9.7 GB seed is over the cap before the session adds anything. That is the seeded case already raised on #1886, so I will leave the fix there and not change it here. AI-assisted (Claude Code, Claude Opus 5.5). |
|
Intel integration verification (AI-assisted: OpenAI Codex): Windows 11, MSVC RelWithDebInfo, Intel UHD Graphics / i5-1334U, driver 32.0.101.6314. Applied the four implementation commits through 98c457e plus the documentation commit, onto main 73cc1a2 and an existing private integration tree. 14/14 targeted tests passed: d3d12_compile_teardown (including the once-only live-device session-cache write), list_value_wait_budget, all nine xs_proxy_mock modes, d3d12_xmem_placed, d3d12_m2_textured, replay_copy_offset. Also checked the actual gta6rt import/filter path with two synthetic, CRT-free guest PEs, one importing SetUnhandledExceptionFilter from KERNEL32.dll and one through api-ms-win-core-errorhandling-l1-1-0.dll. Each registers two filters, verifies the previous guest filter is returned, then raises a deliberate noncontinuable exception; the final guest filter exits with code 42. Both fixed-runtime runs log the cache-exit filter and then exit 42. The preceding runtime failed the filter-chain check (exit 43). These tiny fixtures create no graphics device; actual cache publication is covered by d3d12_compile_teardown, not by the PE fixtures. This is a combined-tree, targeted result, not a full-suite or playability claim. No title data is included. |
|
Merged, thanks! Reviewed at
AI-assisted (Claude Code, Claude Opus 5.5). |
|
Additional Intel diagnostic finding after the positive targeted tests above: with Khronos GPU-assisted validation enabled, a fatal shutdown while compute compilation was still active was followed by a driver access violation inside vkGetPipelineCacheData. Host symbols resolve the caller to save_session_pipeline_cache (d3d12_vulkan_device.cpp, the data query) from the bounded save_pipeline_caches_at_exit worker. The initial fatal exception occurred before this secondary driver failure; this does not explain or fix the initial shutdown. Windows 11, Intel UHD Graphics / i5-1334U, driver 32.0.101.6314, Vulkan SDK 1.4.363.1, current-main integration including #1950. An earlier non-GPUAV run successfully saved the session cache at exit. No minimal standalone concurrency reproducer yet, so this is an observed GPUAV/driver interaction, not a confirmed general cache synchronization bug. A useful follow-up would be a synthetic active-compilation plus exit-cache-query stress test on Intel with GPUAV. No game logs or data included. AI-assisted with OpenAI Codex. |
|
Thanks, that's useful, and the caller you resolved is the expected one. Notes from the code at
If the first exception turns out to be inside a pipeline create, a narrow follow-up would be to skip the exit write when the faulting thread is in a build (a thread-local mark set by |
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; d3d12: the session pipeline cache is saved up to 4 GiB, checkpoints included (RT-SESSION-CACHE-LIMIT) #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