upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/docs/d3d12_vulkan.md
diff options
context:
space:
mode:
authorOreoFR <29048345+OreoFR@users.noreply.github.com>2026-11-27 13:24:49 +0100
committerOreoFR <29048345+OreoFR@users.noreply.github.com>2026-11-27 13:24:49 +0100
commit1d7c662b4bf2870d600da56452d53fbaff295a52 (patch)
treefa362ee20ebc471516641d9285263f305efcede7 /docs/d3d12_vulkan.md
parentf75b2b4258cf25e360bd6d59f554ca4ebdf30bf4 (diff)
compile gate: `auto` default, calibrated at device creation
With LEONIDA_COMPILE_GATE unset or `auto`, the device measures the driver once before the VulkanContext exists: a worker creates a synthetic compute pipeline (SPIR-V written in code, new specialization seed each run, no pipeline cache) while the queue gets empty submissions waited on a fence. Quick submissions with the create still in the driver give the adaptive gate; a held one, a create too fast to tell, an unexplained slow submission or any failure give classic. The verdict is cached per vendor/device/driver/pipelineCacheUUID in compile_gate_calibration.txt beside the pipeline cache; LEONIDA_COMPILE_GATE_RECALIBRATE=1 measures again. Only the title process calibrates; build hosts and tests keep classic. `classic`, `adaptive`, `1`, `0` still force a mode. Tests: compile_gate_policy_test (no GPU: settings, NVIDIA version decode, verdicts, cache file, SPIR-V shape) and vk_compile_gate_calibration_test (GPU: a verdict within 20 s, adaptive on NVIDIA 621.40). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'docs/d3d12_vulkan.md')
-rw-r--r--docs/d3d12_vulkan.md38
1 files changed, 34 insertions, 4 deletions
diff --git a/docs/d3d12_vulkan.md b/docs/d3d12_vulkan.md
index a368c77b4..bc32c505a 100644
--- a/docs/d3d12_vulkan.md
+++ b/docs/d3d12_vulkan.md
@@ -2899,10 +2899,12 @@ submitting thread; at the maintainers' decision it was replaced by this one when
2899 title submits (a submission in the last second, `src/pipeline_wait.h`); the pipeline is built at its first use 2899 title submits (a submission in the last second, `src/pipeline_wait.h`); the pipeline is built at its first use
2900 instead. Opt-in: unset or 0, every warm-up runs, as on `main`, and `LargeModuleGate` (#1889) orders them behind a 2900 instead. Opt-in: unset or 0, every warm-up runs, as on `main`, and `LargeModuleGate` (#1889) orders them behind a
2901 submission's compiles. Smaller warm-ups, and every warm-up before the first submission, run as before. 2901 submission's compiles. Smaller warm-ups, and every warm-up before the first submission, run as before.
2902- **A bounded, adaptive compile gate, opt-in** (`SubmitMutex::enter_submit`, `src/vulkan_device_fault.h`, 2902- **A bounded, adaptive compile gate, where the driver was measured for it** (`SubmitMutex::enter_submit`,
2903 `LEONIDA_COMPILE_GATE=adaptive`). Unset, the gate stays the classic one: compute creates only, each waited for 2903 `src/vulkan_device_fault.h`; `LEONIDA_COMPILE_GATE=adaptive` forces it, `classic` forces the classic one). The
2904 however long it takes, no probes, as before. The adaptive gate is opt-in because of what it costs on a driver that 2904 classic gate: compute creates only, each waited for however long it takes, no probes, as before. Unset or `auto`,
2905 does hold submissions behind a create (630.20, below): no run of it there has been reported yet. The gate keeps a 2905 the device measures which one this driver gets before the title runs (the next item). The adaptive gate is not on
2906 everywhere because of what it costs on a driver that does hold submissions behind a create (630.20, below): no run
2907 of it there has been reported yet. The gate keeps a
2906 `vkQueueSubmit` out of the driver while a create is in it, since on NVIDIA 630.20 one that entered during a long 2908 `vkQueueSubmit` out of the driver while a create is in it, since on NVIDIA 630.20 one that entered during a long
2907 `vkCreateComputePipelines` waited 10 s and lost the device. The waiting submission holds the submit lock, so all 2909 `vkCreateComputePipelines` waited 10 s and lost the device. The waiting submission holds the submit lock, so all
2908 queues stop: on an RTX 4070 Laptop (NVIDIA 621.40) one compute create of a 2.3 MB module stayed in the driver for 2910 queues stop: on an RTX 4070 Laptop (NVIDIA 621.40) one compute create of a 2.3 MB module stayed in the driver for
@@ -2966,6 +2968,34 @@ submitting thread; at the maintainers' decision it was replaced by this one when
2966 create in the driver (kind, program, SPIR-V size, thread, how long it had been there, whether submissions waited 2968 create in the driver (kind, program, SPIR-V size, thread, how long it had been there, whether submissions waited
2967 for it) and each kind's gate. Long graphics creates would leave the title's process only through the compile 2969 for it) and each kind's gate. Long graphics creates would leave the title's process only through the compile
2968 helper, which builds compute pipelines alone today. 2970 helper, which builds compute pipelines alone today.
2971- **`LEONIDA_COMPILE_GATE=auto`, the default: a calibration at device creation** (`src/compile_gate_policy.h`,
2972 `src/compile_gate_calibration.h`, `decide_auto_compile_gate` in `shims/d3d12_vulkan_device.cpp`). Before the
2973 `VulkanContext` (and its `SubmitMutex`) exists, so nothing is gated before the decision, a worker thread creates a
2974 compute pipeline written in code (a chain of `fract(sin(...))` steps and branches over a storage buffer, its
2975 constants from specialization constant 0 with a new seed each run, so neither a pipeline cache nor the driver's
2976 shader cache answers it; no game data) while this thread submits an empty command buffer to the device's queue and
2977 waits for its fence, over and over, until the create returns. At least 3 submissions back in 50 ms or less, before
2978 the create left and some in its second half, with none slower: adaptive. One of 250 ms or more that came back
2979 within 200 ms of the create leaving: the driver holds submissions, classic. A create under 300 ms is tried again
2980 larger (up to 4 trials, none started after 6 s); a slow submission the create does not explain, too few samples
2981 or any failed call: classic. The verdict is kept per vendor, device, driver version and pipeline cache UUID in
2982 `compile_gate_calibration.txt` beside the pipeline cache (failures are not kept), so it runs once per driver;
2983 `LEONIDA_COMPILE_GATE_RECALIBRATE=1` measures again. It is logged once, `[rt] compile-gate: auto: adaptive
2984 (calibrated on NVIDIA 621.40 in 0.7 s: 115 submissions came back in <= 0.5 ms beside a 722 ms create; cached in
2985 ...)` (`classic` and the reason otherwise). Only gta6rt's title process calibrates; `--precompile-pipelines`,
2986 `--compile-server` and the tests keep the classic gate, and a forced value never waits for it.
2987 Why a calibration can ask what an in-game probe cannot: the adaptive gate learns by letting a submission into the
2988 driver beside a create of the title's, which can take 30-60 s, and on a driver that holds submissions such a probe
2989 loses the device once it waits 10 s more. The calibration's create takes about a second and its submissions are
2990 empty, so on such a driver one is held about a second and comes back with the create; that cannot reach the 10 s
2991 the driver allows. What is known for the verdict to agree with, `MEASURED` but small (#2412,
2992 [comment 7217585003](https://github.com/ubiquitarianism/leonida/pull/2412#issuecomment-7217585003)): on an RTX 4070
2993 Laptop with NVIDIA 621.40 a synthetic probe never held a submission past 80 ms beside 8-10 s graphics creates and
2994 retail adaptive runs had no gate hang after #2418, and this calibration gives adaptive there (in 6 runs of
2995 `vk_compile_gate_calibration_test`, 53-125 submissions each, none over 0.9 ms, beside creates of 354-783 ms); an RTX 4060 with 610.88 turned the adaptive gate off with no
2996 regression reported; other 621.x users report fewer crashes with it; one freeze at about 231 s on an RTX 5070
2997 (621.x) was at a head without #2418 and is being rechecked. On 630.20 the calibration has not run yet: the
2998 expected verdict there is classic, from the 10 s hold measured beside a long compute create.
2969 2999
2970**Open:** whether the game uses `D3D12_PIPELINE_STATE_STREAM_DESC` for mesh/RT and which subobject types appear. 3000**Open:** whether the game uses `D3D12_PIPELINE_STATE_STREAM_DESC` for mesh/RT and which subobject types appear.
2971The trace will enumerate them. 3001The trace will enumerate them.