D3D12-PIPELINE-CREATE-LOCK-AMD: serialize driver PSO creation on AMD #2694
Closed
github-bot
wants to merge 5 commits from
github-bot/gh-2694 into main
AGit
pull from: github-bot/gh-2694
merge into: github:main
github:main
github:perf/darner-title-priority-ceiling
github:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
github:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
github:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
github:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
github:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
github:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
github:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
github:fix/runtime-test-conservative-fixtures
github:ci/shard-semantic-linux
github:docs/fg-limit-fps-switch
github:fix/runtime-test-fixture-paths
github:fix/runtime-test-fixture-readers
github:fix/read-file-hard-link
github:fix/book-slot-heap-never-read
github:fix/depth-resolve-spv-path
github:fix/indirect-unused-batched
github:gh-pr/3358/base
github:fix/xmem-refusal-diagnostics
github:gh-pr/3357/base
github:ci/shorten-ci-time
github:fix/alias-later-queued-submissions
github:claude/gallant-sagan-aamatr
github:gh-pr/3342/base
github:gh-pr/3341/base
github:d3d12/agility-sdk-621
github:gh-pr/3293/base
github:gh-pr/3319/base
github:gh-pr/3318/base
github:gh-pr/3315/base
github:gh-pr/3313/base
github:gh-pr/3314/base
github:claude/fervent-curie-m19lnr
github:gh-pr/3216/base
github:gh-pr/3272/base
github:gh-pr/3276/base
github:gh-pr/3279/base
github:gh-pr/3257/base
github:gh-pr/3258/base
github:gh-pr/3271/base
github:codex/skip-no-hit-ray-passes
github:gh-pr/3230/base
github:gh-pr/3266/base
github:gh-pr/3247/base
github:gh-pr/3246/base
github:gh-pr/3244/base
github:claude/sharp-sagan-1jqnp3
github:t3/preserve-fsr-sdk-restart-path
github:t3/propagate-host-failure-hresult
github:t3/launcher-custom-parameters
github:t3/series-x-2160-startup
github:codex/d3d12-uncapped-simulation
github:ci/less-to-run
github:perf/native-compute-shader-forms
github:claude/blissful-franklin-ukp7ag
github:codex/full-precompile-default
github:gh-pr/3166/base
github:gh-pr/3148/base
github:gh-pr/3138/base
github:gh-pr/3106/base
github:gh-pr/3057/base
github:gh-pr/2756/base
github:gh-pr/2812/base
github:gh-pr/3032/base
github:gh-pr/2992/base
github:notes/card-time-and-plant-flicker
github:gh-pr/2986/base
github:gh-pr/3000/base
github:gh-pr/2966/base
github:gh-pr/2924/base
github:gh-pr/726/base
github:gh-pr/2761/base
github:gh-pr/2663/base
github:gh-pr/2861/base
github:gh-pr/2862/base
github:gh-pr/2820/base
github:gh-pr/2811/base
github:gh-pr/2803/base
github:rt-call-trace
github:gh-pr/2802/base
github:gh-pr/2766/base
github:perf/ahead-split
github:gh-pr/2589/base
github:gh-pr/2699/base
github:gh-pr/2696/base
github:docs/readme-runtime-proposal
github:gh-pr/1346/base
github:codex/coord-claim-check-20261124-7e48
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
area: ci
.github/ workflows and settings
area: d3d12
The D3D12 runtime in d3d12/ (Rust: leonida.exe and its crates)
area: docs
Documentation
area: launcher
The launcher (launcher/)
area: runtime (legacy)
The earlier Vulkan runtime in runtime/
area: shader translator
The shader translator (leonida-shader, tools/rdna2spirv) and its tests
area: tools
tools/ and scripts/
area: viewer
The map viewer (viewer/)
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs in-game run
Changes the code a frame runs through: needs the 300 s in-game gate (docs/game_gate.md)
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
wontfix
This will not be worked on
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
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
github/ubiquitarianism--leonida!2694
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2694"
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?
@bobcatchris on GitHub · 2026-11-30 04:53 UTC · original
bobcatchris:fix/d3d12-pipeline-create-lock-amd→main· +288 −5 · 3 files · 5 commits · closed without mergingProblem
On AMD RDNA 3 (RX 7900 XTX,
amdxc64.dll32.0.32029.2010, Windows 11), default 10-thread early pipeline compilation hits a deterministic driver crash (0xc0000005insideamdxc64.dllor0x887A0020DXGI_ERROR_DRIVER_INTERNAL_ERROR) when multiple pipeline worker threads callCreateGraphicsPipelineState/CreateComputePipelineState/CreatePipelineStateconcurrently:LEONIDA_LIBRARY_LOCK=1(which only locksLoad*Pipeline/StorePipeline, notcreate()).LEONIDA_PIPELINE_LIBRARY=0(bypassing the pipeline library completely).LEONIDA_PIPELINE_WORKERS=1avoids the crash, but sacrifices all parallel DXIL shader translation across CPU cores.In addition, an unprioritized global
Mutex<()>can cause priority inversion during cutscenes / new camera angles: backgroundEarlyorSlowdriver compiles (1-73 s on AMD) hold the create lock while draw-criticalScreen/Requestedpipelines wait behind them.Fix
In
d3d12/crates/leonida-gpu/src/pipeline/library.rsandd3d12/crates/leonida-gpu/src/pipeline/make.rs:should_serialize_create(env, vendor_id)+CreatePriority::{Screen, Requested, Early, Slow}+CreateGate(serialized adapters only; non-AMD adapters keep concurrentcreate()unlessLEONIDA_PIPELINE_CREATE_LOCK=1is set).Pending::make()scopeswith_create_priority(CreatePriority)soScreen>Requested>Early>Slowstrictly wins the AMD create lock once the active call finishes.create()call holds the serialized lock (create_busy()),Queue::pop_with(..., slow_blocked)avoids popping speculativeSlowjobs so worker threads stay free forScreen/Requested/Earlywork andworkers()re-wakes when the gate clears.Verification
10.0.26200), Ryzen 7 7800X3D, AMD Radeon RX 7900 XTX (gfx1100, driver32.0.32029.2010), pinnedrustc 1.98.1.cargo test -p leonida-gpu --lib pipeline: 36 passed, 0 failed, 7 ignored (ind3d12, covering priority ordering and concurrent serialization tests).python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/pipeline/library.rs d3d12/crates/leonida-gpu/src/pipeline/make.rs: PASS.serializing host pipeline state creation (LEONIDA_PIPELINE_CREATE_LOCK) vendor=Some("0x1002")and runs cleanly with 0 refused pipelines.Claimed in #2570 as
D3D12-PIPELINE-CREATE-LOCK-AMD.AI-assisted: Antigravity (Gemini 4 Neon)
On AMD RDNA 3 (RX 7900 XTX, amdxc64.dll 32.0.32029.2010), calling ID3D12Device::Create{Graphics,Compute}PipelineState / CreatePipelineState concurrently across the default 10 pipeline worker threads triggers an access violation in amdxc64.dll (0xc0000005) or DXGI_ERROR_DRIVER_INTERNAL_ERROR (0x887A0020) even when LEONIDA_LIBRARY_LOCK=1 or LEONIDA_PIPELINE_LIBRARY=0. Serialize only the final driver Create*PipelineState call under an AMD-only mutex (VendorId == 0x1002, overridable via LEONIDA_PIPELINE_CREATE_LOCK=0|1) while keeping all worker threads translating DXIL shaders in parallel. Other GPU vendors (NVIDIA, Intel, WARP) remain unlocked by default. AI-assisted: Antigravity (Gemini 4 Neon)@ecox982745 on GitHub · 2026-11-30 04:59 UTC · original · edited 2026-11-30 06:02 UTC
Independent native Windows NVIDIA check of
29288a754on1d22590b9(tree1cb8f3801). Windows 11 build 26300, MSVC, Rust 1.98.1, RTX 4090 (NVIDIA 616.64). The exactpipeline::librarysubset passed 8/8.I added a local probe that sends eight concurrent requests through
pipeline(), each creating a real D3D12 compute PSO from a tiny synthetic Shader Model 6.0 shader. DXGI confirmed the adapter. I tested both no library key and eight fresh library keys (eight observed load attempts and eight subsequent creates).LEONIDA_PIPELINE_CREATE_LOCK=1Each condition passed in three repeat processes. Peak counts measure entry into the application's creation callbacks. This verifies the NVIDIA path and override with synthetic PSOs. AMD driver reproduction, GPU dispatch, and gameplay were outside this check.
AI-assisted with OpenAI Codex (GPT-6.2 Sol).
Retest on
05c327bf3after the priority update. This merges cleanly with0ae217ceb(tree10728e5a5), which includes merged #2662. The exact library filter passed 9/9, including the new gate priority test. The pipeline worker filter passed 8/8, and the paired shader filter passed 22/22 with host coverage. On the RTX 4090 the same synthetic PSO probe completed 8/8 creates per path, with peak application callback concurrency 8 under the default setting and 1 with the lock forced. Both the no-key and fresh library-miss paths were exercised.05c327bf3atoe201dcd902@merzleckeier on GitHub · 2026-11-30 11:20 UTC · original
Independent Wine PSO check.
05c327bf3merged ontod367675c7(treef0308e20). CachyOS, Wine 11.22, VKD3D-Proton 3.1.0 (0bb64c56c8f0dcc), Rust 1.98.1, x64 MSVC target. Four workers created real D3D12 compute PSOs from a synthetic shader. The counts are peak entries into the application's create callback.0x1002=00x1002=0dxgi.hideNvidiaGpu = False0x10de=1The same peak held with no library key and after fresh library misses. Each path created 4/4 PSOs and all four stored keys reloaded. In this Wine setup the default follows the vendor DXGI reports, so it can serialize on physical NVIDIA hardware. DXVK option.
The test used a seeded empty library on #2694 alone. On AMD, the existing empty-library test failed on both
mainand #2694. The direct API check returned0x80070057for the empty slice andS_OKfor a null pointer with zero length. Combining #2654 at55ac5d337(tree82711e462) passed all 18 checked-in library and worker tests on AMD and reproduced the same peaks and reloads with a fresh library, without the seed. VKD3D-Proton input check.Synthetic PSO creation only. AI-assisted with OpenAI Codex.
@ecox982745 on GitHub · 2026-11-30 13:10 UTC · original
Native Windows cache persistence check on
e201dcd90(#2694) with55ac5d337(#2654) onf9f3ec4c6(combined treedf841387d). MSVC x64, Rust 1.98.1, RTX 4090 on NVIDIA 616.64, Windows 11 build 26300. The ten stockpipeline::library::testsall passed.I used an isolated cache directory per run and a tiny synthetic compute shader. Eight threads looked up distinct names through the production pipeline library. I ran three cold processes per lock setting. Each made all eight PSOs and saved a nonempty
host-pipelines.bin. For each cold cache, two fresh processes reopened it, one with the lock unset and one withLEONIDA_PIPELINE_CREATE_LOCK=1. All 12 warm processes found all eight keys, ran zero creation callbacks, and left the library file byte-identical. DXGI confirmed the RTX 4090, and the probe checked the effective lock setting in each process.This adds native Windows save and cross-process reload coverage to the earlier concurrency and Wine tests. Synthetic compute PSOs only. AI-assisted with OpenAI Codex (GPT-6.2 Sol).
@merzleckeier on GitHub · 2026-11-30 13:27 UTC · original
AMD Wine cache round-trip for #2694 + #2654. I tested
e201dcd90with55ac5d337onf9f3ec4c6(combined treedf841387d, same tree as the native RTX 4090 check). Windows x64 MSVC-target Rust 1.98.1, Wine 11.22, VKD3D-Proton 3.1.0 (0bb64c56c8f0dcc), Radeon 610M on RADV 26.3.1. DXGI reported0x1002. The VKD3D and Mesa shader disk caches were disabled.MEASURED. All 10 stock library tests passed. In the synthetic probe, eight threads requested distinct named compute PSOs through the production pipeline library. Every cold run started with an empty cache directory. I reopened each saved cache in two fresh Wine processes, one per lock policy.
LEONIDA_PIPELINE_CREATE_LOCK=05047d6a1)Each combined cold run saved a 3,176-byte
host-pipelines.bin. Its SHA-256 stayed identical after both warm runs, across all six caches. Peak measures application callback entries. The unlocked probe synchronizes callbacks before the driver call. The first Wine prefix initialization timed out before tests. The results above are from the complete run with a newly initialized prefix. A second agent checked the raw logs and file hashes. Synthetic compute only, AI-assisted.e201dcd902to1e0e249ffc@merzleckeier on GitHub · 2026-12-01 12:56 UTC · original
Offscreen driver-call check of the pipeline creation gate at
1e0e249f+c95183fd8. Four threads entered the production pipeline helper and each created a real synthetic compute PSO. On AMD RADV the peak inside the create callback was 1 by default and 4 with the lock forced off. With DXGI reporting the RTX 4070 SUPER as NVIDIA, the peak was 4 by default and 1 with the lock forced on. In an extra default DXVK run the same NVIDIA hardware appeared to the application as vendor0x1002, so the AMD default took effect and the peak was 1. The three gate unit tests passed on both GPUs. The existing rejected-library-blob check failed identically on base and PR under this Wine/vkd3d setup. This run measures the gate around offscreen compute creation. Native Windows AMD and gameplay remain open.AI-assisted with OpenAI Codex.
@KelboLive on GitHub · 2026-12-01 15:21 UTC · original · reviewed
Reviewed at
1e0e249f, and also merged onto today's main (the branch is 402 commits behind):merge-treeis clean, the merged tree passescargo test -p leonida-gpu --lib pipeline(41 passed / 0 failed / 8 ignored), and neither touched file adds a clippy warning. The gate, the AMD-only vendor policy and the Screen > Requested > Early > Slow ordering all match the claim (library.rs:482,:532,:728,make.rs:198,:729), and both title-PSO create sites are inside the gate — the two otherCreate*PipelineStatecalls are device-init/offline, not worker-concurrent.Mutations: the vendor guard and the
!slow_blockeddeferral are both caught. Replacingcreate_busy()withfalseinnext()(make.rs:775) survives all 40 tests — the deferral wiring is untested, because the unit tests never have a host, socreate_is_serialized()is always false. A stub-gate test (or a seam that lets the test pretend a create is in flight) would cover it; the same applies to the re-wake branch at:830.Two more things:
now()/masked_forcan runp.make()synchronously on the draw thread, but onlymake.rs:765and:836callAVAILABLE.notify_all(), so workers parked on a slow-only queue can sleep until the next enqueue. Notifying on gate release would close that.python -I tools/d3d12_switches.py --check d3d12/docs/switches.mdpasses on main alone but fails after merging this branch, missingLEONIDA_PIPELINE_CREATE_LOCK. The PR adds the switch and its row is absent from the merged tree.The AMD crash itself cannot be reproduced here (no AMD GPU and no title data), so that half rests on the reporters' hardware logs — the code-level evidence above is what this box can check.
@bobcatchris on GitHub · 2026-12-01 18:25 UTC · original
@KelboLive Addressed in
163660640(after mergingmain, no rebase/force-push):d3d12/docs/switches.mdviapython -I tools/d3d12_switches.py --out d3d12/docs/switches.md(--checkpasses;LEONIDA_PIPELINE_CREATE_LOCKis now documented).notify_create_idle()invoked fromCreateGuard::drop()wheneverCREATINGis released (after droppingCREATING.stateso lock order staysQUEUE->CREATING.state), waking parked workers even after synchronous draw-thread creates (now()/masked_for).create_busy()to checkCREATING.is_busy()directly (avoiding callinghost()while holdingQUEUE.lock()), removed the now-redundant worker-loop wakeup branch, and addednext_defers_slow_while_create_gate_held_and_wakes_on_releaseto pin both deferral and gate-release wakeup.cargo test --locked -p leonida-gpu --lib pipeline(42 passed, 0 failed, 8 ignored),tools/d3d12_switches.py --check, andpython -I scripts/check_no_game_data.py(clean).AI-assisted: Gemini 4 Neon (including an independent read-only reviewer pass).
@imShangLi on GitHub · 2026-12-02 00:35 UTC · original
VERIFY-2694 — Linux, Fedora 45, Rust 1.98.1 (the pinned toolchain), Wine 11.21, no GPU device, no game files
Verdict: PASS. The gate's logic is right, nothing that passed before fails now, and the new tests pass. Two properties of the design are worth the author's attention, though neither is a defect.
Head
16366064, base the currentmain85ec1d33, merge base27613ab6, 3 files, +288/−5:d3d12/crates/leonida-gpu/src/pipeline/library.rs,d3d12/crates/leonida-gpu/src/pipeline/make.rs,d3d12/docs/switches.md.1. What it changes
Concurrent
Create*PipelineStatecalls crash AMD's driver compiler (0xc0000005/0x887A0020insideamdxc64.dll), while the DXIL translation itself can stay parallel. The pull request puts the driver's calls behind a priority-ordered mutex, so an activeScreenorRequesteddraw does not sit in line behind queued backgroundEarlyorSlowprecompiles:A waiter goes in only when the gate is free and no waiter of a higher priority is queued; the priority itself is a thread-local with a reset guard (
with_create_priority), so the code that makes a pipeline says which kind it is. The gate is used only whenshould_serialize_createsays so — by default on AMD (VendorId == 0x1002), overridable withLEONIDA_PIPELINE_CREATE_LOCK=0|1.2. What I checked
CreateGuard'sDropsetsbusy = false, notifies all, and — when the guard is the globalCREATINGgate — callssuper::make::notify_create_idle(), so the "creation in progress" bookkeeping is cleared on the same path that frees the gate.state.waiting[..p]is the higher priorities (the enum ordersScreen = 0as most urgent), so aScreenwaiter ignores lower ones ✓ and aSlowwaiter yields to any queuedScreen/Requested/Early✓.should_serialize_createreadsLEONIDA_PIPELINE_CREATE_LOCKfirst ("0"→ off,"1"→ on), and otherwise serializes only on AMD's vendor id ✓.create_is_serialized()reads it once into aOnceLockand logs which adapter it saw ✓.create_busy()reads the gate directly rather than askingcrate::host::host(), because the callers holdQUEUE— the comment says so and the code does it ✓.3. Two properties worth stating in the pull request
Neither is a defect, and the author may well have them in mind:
Slowwaiter proceeds only when noScreen/Requested/Earlywaiter is queued, so a steady stream of screen-priority creations can keep the background precompiles waiting indefinitely. That is the point of the change ("active draws never sit in line behind queued background precompiles"), but the other side of it is that the background work may never finish while the game is busy. Whether that matters is a property of a run with the game.notify_allplus a priority-only test, so among waiters of the same priority the order is not FIFO — a late arrival can take the gate before an earlier one.4. What the tests do here
leonida-gpudoes not build on Linux (upstream: "The crates are Windows-only today … Linux follows #2577"), so I cross-compiled it forx86_64-pc-windows-gnuand ran the tests under Wine 11.21.The red side (the merge base with only this pull request's tests) does not compile — the new test uses
CreatePriority, which the change introduces — so the base and the head were compared:watchtests that need Microsoft'sVirtualAlloc/VirtualQuerybehaviour, which Wine does not have5. What I did not check
Create*PipelineStatefaults insideamdxc64.dllon AMD; that needs an AMD card, and the fault and its fix are not reproducible here.AI-assisted: MiniMax M3.1 Flash.
@MoonEyes on GitHub · 2026-12-02 12:18 UTC · original
Closing: this pull request no longer applies to current
main(merge conflict ind3d12/docs/switches.md), and open pull requests that have fallen out of step withmainare being closed so the list stays workable. If you still want this change, rebase it on currentmainand reopen it (or open a new pull request); it will be looked at again.AI-assisted (Claude Code).
Pull request closed