d3d12: LEONIDA_ASYNC_MIN_BYTES, only large pipelines asynchronous (RT-ASYNC-LARGE-ONLY) #2440
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2440"
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?
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-27T08:05:19Z.
Claimed in the coordination issue as: RT-ASYNC-LARGE-ONLY
What and why
LEONIDA_ASYNC_PIPELINESis all or nothing (runtime/shims/d3d12_pipeline_compile.h). On an RTX 4070 Laptop (NVIDIA 621.40), retail, wave64-emulated pack:=1: the world phase is reached but the screen stays black. Every draw or dispatch whose pipeline is not built yet is skipped, including the small lighting and post programs. The Linux/Proton NVIDIA report indocs/running.mdsays the same.=0: a submission waits for each of the ~700 ray-tracing compute programs (2-26 MB of SPIR-V, 2-3 minutes each in the driver). We measured 17 builds in 30 minutes, so the world start would take hours.This adds
LEONIDA_ASYNC_MIN_BYTES=<n>, used withLEONIDA_ASYNC_PIPELINES=1:PipelineCompilesbuilds it at prepare, and a compile-helper build waits for its file.async_build. The decision lives inruntime/src/async_pipeline_size.h, which is pure stdlib.0, or text that isn't a decimal number (logged): every pipeline is asynchronous. The code path is the same as today.What changed in
d3d12_vulkan_device.cpp:graphics_.async_buildandpipeline_.async_buildtake the size into account.build_compute, the worker's publication inqueue_build, andrequest_early.Graphics follows the same threshold, measured by the total size of all its stages. The NVIDIA report's black stretch was graphics pipelines of 1-2.6 MB compiling one at a time, so a threshold above that leaves them blocking as with
=0, and one below makes them asynchronous.Not changed: a large asynchronous build still goes through the compile gate and
LargeModuleGate, so a mid-size build that a submission waits for can queue behind it there. The docs paragraph says so.Tested
async_pipeline_size_test(new): parsing (unset, empty, 0, max, overflow, suffixes, signs, spaces, hex) and the decision (off, on with no threshold, below/at/above 2 MiB, 1 byte, 2^64-1).d3d12_m4_compute --async-small-waits(new ctestd3d12_m4_compute_async_small_waits): async on, threshold over both modules, warm-up off, and every compile-worker job held by a job probe until the results are read. Both dispatches must run in place (all words match) and no build may reach the worker.LEONIDA_ASYNC_MIN_BYTES=0forced into the test, a build went to the compile worker.LEONIDA_ASYNC_MIN_BYTESunset,1,2097152and1073741824:d3d12_compile_teardown,d3d12_m4_compute,d3d12_m4_compute --async-small-waitsandd3d12_m4_compute --check-async-journal(withLEONIDA_ASYNC_PIPELINES=1). All pass.=2MiBlogs that it is ignored.ctest(RelWithDebInfo, Ninja, MSVC): 490 of 492 pass.xbox_presentandd3d12_set_descriptor_heapsalso fail on plainmaind1dff7949on this machine (both rebuilt frommainand rerun).tests/test_docs_*.pypass.scripts/check_no_game_data.pyis clean on every changed file.LEONIDA_ASYNC_PIPELINES=1 LEONIDA_ASYNC_MIN_BYTES=2097152; the result will be posted in #1608.GPUs tested: NVIDIA GeForce RTX 4070 Laptop 8 GB, driver 621.40, Windows 11.
AI-assisted: yes (Claude Code, Claude Opus 5.5)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: runtime only)🤖 Generated with Claude Code
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-27T08:23:42Z.
First retail result with this PR (RTX 4070 Laptop 8 GB, NVIDIA 621.40, Windows 11). Build:
maind1dff7949+ #2412, #2418, #2260 (#2220, #2233), #2020, #2166, #1851, #2432 and this PR. Shaders: the current pack with DadaCap's one-lane-fold library. Settings:LEONIDA_ASYNC_PIPELINES=1+LEONIDA_ASYNC_MIN_BYTES=2097152,LEONIDA_VALUE_WAIT_TIMEOUT_MS=30000,LEONIDA_MAP_READBACK=1,LEONIDA_HOST_IMAGE_COPY=0,LEONIDA_DEVICE_TYPE=6,LEONIDA_SERIAL_BIG_COMPILES=0, the recorded prewarm, no Aftermath, default title windows, 24 GB page file.MEASURED (n=1). AI-assisted (Claude Code, Claude Opus 5.5).Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-27T08:48:30Z.
Repeat, same build and recipe: the opening scene renders again, from about 9 min in, and stays up to the end of the 20-minute run, with no device loss. Peak private bytes were 52 GB.
MEASURED (n=2). AI-assisted (Claude Code, Claude Opus 5.5).Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-27T09:09:54Z.
Threshold comparison, same build and recipe, 20 min each, world drawn in both:
LEONIDA_ASYNC_MIN_BYTESOn this 8 GB laptop, 1 MiB looks better: shorter stalls when a mid-size pipeline is built in place, and less host memory. The frame rate is the same, because that comes from per-submission costs (
textures150-270 ms,heaps), not from compiles.MEASURED (n=1 each). AI-assisted (Claude Code, Claude Opus 5.5).Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-27T10:41:07Z.
Independently checked head
76099a22fon Windows 11 Pro 26200, MSVC 2022 (19.44.35230.0, RelWithDebInfo, Ninja), Vulkan SDK1.4.363.0, WSLllvm-mc 21.1.8, no game files.Local build & dual-GPU verification:
async_pipeline_size_testandd3d12_m4_compute_testwith zero new warnings in the PR-modified files.async_pipeline_size_test: PASS (async_pipeline_size_test: ok).d3d12_m4_compute_test(both default and--async-small-waits) withLEONIDA_VK_VALIDATION=1:616.64, subgroup32..32): default 1924/1924 words matched (error 0);--async-small-waits1924/1924 words matched (error 0), 0 validation errors.25.10.30.02, subgroup32..64): default 1924/1924 words matched (error 0);--async-small-waits1924/1924 words matched (error 0), 0 validation errors.Code review notes:
parse_min_bytes(runtime/src/async_pipeline_size.h) handles exactUINT64_MAXoverflow guarding and cleanly rejects signs, whitespace, suffixes, hex, and non-ASCII bytes; function-local static init is thread-safe, graphics sums all stages' post-patch SPIR-V sizes, and every former global async check now reads the per-PSOasync_buildflag.d3d12_m4_compute_async_small_waitsverifiesworker_jobs == 0when the threshold is above both modules, without a positive control proving the held job probe intercepts a queued job when a module is at/above the threshold. SettingLEONIDA_ASYNC_MIN_BYTESbetween the two modules' sizes (or adding a--async-held-controlcase without the threshold expecting>= 1held job) would exercise both sides of the gate.Overall looks sound and clean. AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-27T10:47:55Z.
Merging.
LEONIDA_ASYNC_MIN_BYTESlets small compute pipelines build on the calling thread instead of going to the compile worker. Nothing changes while the variable is unset.d3d12_m4_compute_async_small_waitsfails onmain(one build reached the compile worker) and passes with this change.main2859d0c9b+ #2418, #2440, #2432 and #2439, integrated RDNA2 GPU (RADV, Mesa 26.3.1):xdxr_build_check(a timeout under load) andxmem_no_write_watch, both flaky here.ctest: 115 of 116, the same timeout.Thanks @OreoFR.
AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)
Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-27T20:48:19Z.
Profile M data point for
LEONIDA_ASYNC_PIPELINES=1+LEONIDA_ASYNC_MIN_BYTES=2097152(RTX 4070 SUPER 12 GB desktop, NVIDIA 621.01, Windows 11, 64 GB), in OreoFR's world recipe from #1608. Counts only. AI-assisted (Claude Code).With this setting, the library precompiled (
gta6rt --precompile-pipelines --big-threads 1 --skip-listed --filter library/: 1,674 programs, 0 failed; the largest, 13.7 MB of SPIR-V, took 1,356 s alone) and the 1,009 ray-hit programs on the skip list, four runs on the same stack got: c3-G1b and c3-G1b-ctl stayed on the story load (a stale local DirectStorage predictor profile, see #2502), c3-G1c reached the opening sequence, and c3-G1d (below) reached gameplay control. No draw or dispatch was lost to a pending build in a way that kept the screen black: the remaining problem is a near-white picture in gameplay, not a black one.Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-27T20:48:28Z.
CORRECTION to my comment above: "No draw or dispatch was lost to a pending build in a way that kept the screen black" is not measured: I did not count draws or dispatches skipped while their pipelines were pending. MEASURED is only that the screen was not black in gameplay (near-white, mean RGB 252-254 in the captures). Nothing else in that comment changes.
AI-assisted (Claude Code)