Repository navigation
Shaders: share and serialize WARP host operations across threads - #244
Conversation
Fixes Marvisak#181. Concurrent WARP (d3d10warp.dll) usage across threads crashes with 0xC0000005 on Windows 11, both when creating/tearing down separate WARP devices and when compiling pipelines or executing work concurrently on a single shared WARP device. Keep one process-wide WARP ID3D12Device in Host::new (for explicit warp = true, VICTORY_WARP=1, and systems whose default DXGI adapter has DXGI_ADAPTER_FLAG_SOFTWARE) and serialize WARP root signature creation, pipeline compilation, draws, and dispatches behind a process-wide mutex. Hardware D3D12 devices remain unserialized. Route diff_tests's direct CreateRootSignature calls through Host::root_signature_bytes so they share the same serialization, and add a multi-threaded WARP regression test (parallel_warp_pipelines_and_draws).
|
Verified the fix for #181 with the same runs that reproduced it.
AI use
|
|
Tested 7f95b87 on an NVIDIA RTX 3060 Ti (driver 32.0.16.1088), Windows 11 build 26300,
No hangs (each run under a 180 s timeout). Not covered here: a default adapter that is itself WARP, and AI use: Claude Code ran the commands and drafted this from the logs; I checked it before posting. |
|
Test report on NVIDIA (#181 lists NVIDIA as not tested). Tested
Not tested
AI use
|
|
One more NVIDIA data point: RTX 4060 (driver 617.42), Windows 11 26200, Rust 1.98.1, debug. Same result as above. With One thing not mentioned above: twice the test binary hung instead of finishing, once on main and once with this PR (1 of 55 runs). It kept a core busy until my 120 s limit. I couldn't catch which test it was in 30 more runs, so it's probably a separate, rarer race and not caused by this PR. I'm mentioning it in case someone else hits a run that never ends. AI-assisted: yes |
|
Windows 10 data point (the reports so far are Windows 11). Short version: #181 cannot happen on Windows 10, because WARP there has no SM 6.6 device; #244 is harmless there, but it conflicts with #175. Setup: Windows 10 22H2 19045.7846,
No game data used. AI-assisted (Claude Code); I ran everything above on my machine. |
|
AI-assisted. Tested
Verified clean on Windows 11 26200 + Intel Xe / WARP. |
|
A data point on the hang mentioned above as probably separate: it reproduces here, and it is separate. Tested
In a hung run none of the seven tests finishes and one core stays busy. With So on this machine the hang survives serialising WARP alone. Taking a lock around The one crash in 60 runs on this PR I cannot explain and did not see again; I did not run No game data used. AI-assisted. |
mercuryVM
left a comment
There was a problem hiding this comment.
Tested 7f95b87 on Windows 11, RTX 5070, MSVC: cargo test -p victory-shader -- --test-threads=1 70 passed. VICTORY_WARP=1 cargo test -p victory-shader --lib, run in parallel (the #181 repro), also passed (70 tests, no 0xC0000005), as did a default parallel run on the hardware adapter. cargo clippy -p victory-shader --all-targets is clean.
- One shared device per adapter kind, kept for the process, plus a mutex around WARP operations only (
default_adapter_is_warp()decides when the default device is WARP), fixes the cross-thread race without serialising hardware runs. - Caveat on attribution: on mercuryVM/VIctory main, without this change, a parallel
cargo test -p victory-shader --libon the hardware adapter now also passes (the serialisation from #433 is there). So I could only confirm the WARP part of #181 as fixed by this PR, not the hardware one.
AI-assisted (Claude Code).
…t operations across threads Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… across threads
…visak#244) Fixes Marvisak#181. Concurrent WARP (d3d10warp.dll) usage across threads crashes with 0xC0000005 on Windows 11, both when creating/tearing down separate WARP devices and when compiling pipelines or executing work concurrently on a single shared WARP device. Keep one process-wide WARP ID3D12Device in Host::new (for explicit warp = true, VICTORY_WARP=1, and systems whose default DXGI adapter has DXGI_ADAPTER_FLAG_SOFTWARE) and serialize WARP root signature creation, pipeline compilation, draws, and dispatches behind a process-wide mutex. Hardware D3D12 devices remain unserialized. Route diff_tests's direct CreateRootSignature calls through Host::root_signature_bytes so they share the same serialization, and add a multi-threaded WARP regression test (parallel_warp_pipelines_and_draws). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The integration has a different lowering input layout and only permits direct title-address fallback for compute shaders. Exercise that fallback in the same SSA regression and use the available input fields for the permute test. Make the cached sums copyable and close the device creation block after retaining the fork’s adapter selection. Based-on: Marvisak#139 Based-on: Marvisak#244 Based-on: Marvisak#573 Tested-on: Intel Xeon E5-2670 v3, Fedora Linux 45, five shader regressions and Windows-target Cargo checks Assisted-by: gpt-6.2 sol xhigh
…visak#244) Fixes Marvisak#181. Concurrent WARP (d3d10warp.dll) usage across threads crashes with 0xC0000005 on Windows 11, both when creating/tearing down separate WARP devices and when compiling pipelines or executing work concurrently on a single shared WARP device. Keep one process-wide WARP ID3D12Device in Host::new (for explicit warp = true, VICTORY_WARP=1, and systems whose default DXGI adapter has DXGI_ADAPTER_FLAG_SOFTWARE) and serialize WARP root signature creation, pipeline compilation, draws, and dispatches behind a process-wide mutex. Hardware D3D12 devices remain unserialized. Route diff_tests's direct CreateRootSignature calls through Host::root_signature_bytes so they share the same serialization, and add a multi-threaded WARP regression test (parallel_warp_pipelines_and_draws). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The integration has a different lowering input layout and only permits direct title-address fallback for compute shaders. Exercise that fallback in the same SSA regression and use the available input fields for the permute test. Make the cached sums copyable and close the device creation block after retaining the fork’s adapter selection. Based-on: Marvisak#139 Based-on: Marvisak#244 Based-on: Marvisak#573 Tested-on: Intel Xeon E5-2670 v3, Fedora Linux 45, five shader regressions and Windows-target Cargo checks Assisted-by: gpt-6.2 sol xhigh
…visak#244) Fixes Marvisak#181. Concurrent WARP (d3d10warp.dll) usage across threads crashes with 0xC0000005 on Windows 11, both when creating/tearing down separate WARP devices and when compiling pipelines or executing work concurrently on a single shared WARP device. Keep one process-wide WARP ID3D12Device in Host::new (for explicit warp = true, VICTORY_WARP=1, and systems whose default DXGI adapter has DXGI_ADAPTER_FLAG_SOFTWARE) and serialize WARP root signature creation, pipeline compilation, draws, and dispatches behind a process-wide mutex. Hardware D3D12 devices remain unserialized. Route diff_tests's direct CreateRootSignature calls through Host::root_signature_bytes so they share the same serialization, and add a multi-threaded WARP regression test (parallel_warp_pipelines_and_draws). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The integration has a different lowering input layout and only permits direct title-address fallback for compute shaders. Exercise that fallback in the same SSA regression and use the available input fields for the permute test. Make the cached sums copyable and close the device creation block after retaining the fork’s adapter selection. Based-on: Marvisak#139 Based-on: Marvisak#244 Based-on: Marvisak#573 Tested-on: Intel Xeon E5-2670 v3, Fedora Linux 45, five shader regressions and Windows-target Cargo checks Assisted-by: gpt-6.2 sol xhigh
…visak#244) Fixes Marvisak#181. Concurrent WARP (d3d10warp.dll) usage across threads crashes with 0xC0000005 on Windows 11, both when creating/tearing down separate WARP devices and when compiling pipelines or executing work concurrently on a single shared WARP device. Keep one process-wide WARP ID3D12Device in Host::new (for explicit warp = true, VICTORY_WARP=1, and systems whose default DXGI adapter has DXGI_ADAPTER_FLAG_SOFTWARE) and serialize WARP root signature creation, pipeline compilation, draws, and dispatches behind a process-wide mutex. Hardware D3D12 devices remain unserialized. Route diff_tests's direct CreateRootSignature calls through Host::root_signature_bytes so they share the same serialization, and add a multi-threaded WARP regression test (parallel_warp_pipelines_and_draws). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The integration has a different lowering input layout and only permits direct title-address fallback for compute shaders. Exercise that fallback in the same SSA regression and use the available input fields for the permute test. Make the cached sums copyable and close the device creation block after retaining the fork’s adapter selection. Based-on: Marvisak#139 Based-on: Marvisak#244 Based-on: Marvisak#573 Tested-on: Intel Xeon E5-2670 v3, Fedora Linux 45, five shader regressions and Windows-target Cargo checks Assisted-by: gpt-6.2 sol xhigh
…visak#244) Fixes Marvisak#181. Concurrent WARP (d3d10warp.dll) usage across threads crashes with 0xC0000005 on Windows 11, both when creating/tearing down separate WARP devices and when compiling pipelines or executing work concurrently on a single shared WARP device. Keep one process-wide WARP ID3D12Device in Host::new (for explicit warp = true, VICTORY_WARP=1, and systems whose default DXGI adapter has DXGI_ADAPTER_FLAG_SOFTWARE) and serialize WARP root signature creation, pipeline compilation, draws, and dispatches behind a process-wide mutex. Hardware D3D12 devices remain unserialized. Route diff_tests's direct CreateRootSignature calls through Host::root_signature_bytes so they share the same serialization, and add a multi-threaded WARP regression test (parallel_warp_pipelines_and_draws). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The integration has a different lowering input layout and only permits direct title-address fallback for compute shaders. Exercise that fallback in the same SSA regression and use the available input fields for the permute test. Make the cached sums copyable and close the device creation block after retaining the fork’s adapter selection. Based-on: Marvisak#139 Based-on: Marvisak#244 Based-on: Marvisak#573 Tested-on: Intel Xeon E5-2670 v3, Fedora Linux 45, five shader regressions and Windows-target Cargo checks Assisted-by: gpt-6.2 sol xhigh
…visak#244) Fixes Marvisak#181. Concurrent WARP (d3d10warp.dll) usage across threads crashes with 0xC0000005 on Windows 11, both when creating/tearing down separate WARP devices and when compiling pipelines or executing work concurrently on a single shared WARP device. Keep one process-wide WARP ID3D12Device in Host::new (for explicit warp = true, VICTORY_WARP=1, and systems whose default DXGI adapter has DXGI_ADAPTER_FLAG_SOFTWARE) and serialize WARP root signature creation, pipeline compilation, draws, and dispatches behind a process-wide mutex. Hardware D3D12 devices remain unserialized. Route diff_tests's direct CreateRootSignature calls through Host::root_signature_bytes so they share the same serialization, and add a multi-threaded WARP regression test (parallel_warp_pipelines_and_draws). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The integration has a different lowering input layout and only permits direct title-address fallback for compute shaders. Exercise that fallback in the same SSA regression and use the available input fields for the permute test. Make the cached sums copyable and close the device creation block after retaining the fork’s adapter selection. Based-on: Marvisak#139 Based-on: Marvisak#244 Based-on: Marvisak#573 Tested-on: Intel Xeon E5-2670 v3, Fedora Linux 45, five shader regressions and Windows-target Cargo checks Assisted-by: gpt-6.2 sol xhigh
…visak#244) Fixes Marvisak#181. Concurrent WARP (d3d10warp.dll) usage across threads crashes with 0xC0000005 on Windows 11, both when creating/tearing down separate WARP devices and when compiling pipelines or executing work concurrently on a single shared WARP device. Keep one process-wide WARP ID3D12Device in Host::new (for explicit warp = true, VICTORY_WARP=1, and systems whose default DXGI adapter has DXGI_ADAPTER_FLAG_SOFTWARE) and serialize WARP root signature creation, pipeline compilation, draws, and dispatches behind a process-wide mutex. Hardware D3D12 devices remain unserialized. Route diff_tests's direct CreateRootSignature calls through Host::root_signature_bytes so they share the same serialization, and add a multi-threaded WARP regression test (parallel_warp_pipelines_and_draws). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The integration has a different lowering input layout and only permits direct title-address fallback for compute shaders. Exercise that fallback in the same SSA regression and use the available input fields for the permute test. Make the cached sums copyable and close the device creation block after retaining the fork’s adapter selection. Based-on: Marvisak#139 Based-on: Marvisak#244 Based-on: Marvisak#573 Tested-on: Intel Xeon E5-2670 v3, Fedora Linux 45, five shader regressions and Windows-target Cargo checks Assisted-by: gpt-6.2 sol xhigh
Upstream model everywhere, our additive diagnostics kept. 15 files conflicted, all resolved file-by-file: - README: our fuzz_tests/ship-profile/VICTORY_DIFF_ONLY/VICTORY_NAME_SHADERS notes beside upstream's status/blake3-paths/translate-jobs wording. - descriptor/host.rs: upstream Marvisak#2462 (no typed UAV in a format the host cannot store to) lands untouched through the merge; keeps its device-removal fix, no behavior change on capable hosts. - descriptor.rs: our monotonic heap-id guard + upstream Marvisak#2234 (released view heap takes its page table with it). - pipeline/library.rs: upstream Marvisak#2179 (lock-free loads via Shared) + our best-effort periodic save (try_lock on state). - capture.rs: our Marvisak#2607 signed-32 decode + test beside upstream's r32_integer_to_rgba. - draw.rs: our buffer_state tracking + root-signature test beside upstream's marked page-range refresh (Marvisak#2172) + sampler-heap test. - pipeline/host.rs: upstream vertex/depth-bounds/integer-blend model (stream_pipeline, host_blend, depth_with_bounds) + our padding-zeroing clean_* and Stream zeroing; both test batches kept. - pipeline/make.rs: keep lost/screen fields + upstream skipped_shader. - pipeline.rs: keep bytes()/pipelines_waiting() beside for_test. - host.rs: multi-plane present (Marvisak#1997, Compositor) + our previous-frame wait, presented/probed frame tracking, keep-textures, drain-before-save; both test modules (submissions + present_plane_tests). - queue.rs: upstream blinks (Option<bool>) supersedes ours. - shadow.rs: upstream update_tracked/update + merge_writeback (Marvisak#2054) + our stale/submission_done/Part snapshots/buffer_states; update_free and update_busy retired as subsumed (no callers left). - xmem.rs: upstream shared system_commit() supersedes our inline version. - emit/host.rs: our fence-event wait() + upstream SharedDevice/Marvisak#244 (shared/serialized WARP device). - emit/lower.rs: upstream i64 dword ordering (Marvisak#1599) + our f/t lane path and RDNA2 opcode names; tests moved verbatim to lower_tests.rs via #[path] (lower.rs exceeded the 512 KiB asset-policy limit after the merge; module path unchanged, content byte-identical). - emit/valu_tests.rs: our s_load_dwordx4_at + upstream sopk helper. - gfx10/opcodes.rs: upstream pub(crate) + our RDNA2 names. - fuzz_tests.rs: Host::from_device() for upstream's new warp field. Test adaptations (same execution-model class as the 13f91ca merge): 8 upstream tests written for synchronous execute() drain explicitly on our async-completion queue (marked-UAV/placed-view/rebind tests); Host::from_device() port; words() accessor for privatized field. Gates: cargo test --workspace --locked green, clippy --workspace --all-targets --all-features -D warnings clean, xtask policy 197 ok.
…visak#244) Fixes Marvisak#181. Concurrent WARP (d3d10warp.dll) usage across threads crashes with 0xC0000005 on Windows 11, both when creating/tearing down separate WARP devices and when compiling pipelines or executing work concurrently on a single shared WARP device. Keep one process-wide WARP ID3D12Device in Host::new (for explicit warp = true, VICTORY_WARP=1, and systems whose default DXGI adapter has DXGI_ADAPTER_FLAG_SOFTWARE) and serialize WARP root signature creation, pipeline compilation, draws, and dispatches behind a process-wide mutex. Hardware D3D12 devices remain unserialized. Route diff_tests's direct CreateRootSignature calls through Host::root_signature_bytes so they share the same serialization, and add a multi-threaded WARP regression test (parallel_warp_pipelines_and_draws). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The integration has a different lowering input layout and only permits direct title-address fallback for compute shaders. Exercise that fallback in the same SSA regression and use the available input fields for the permute test. Make the cached sums copyable and close the device creation block after retaining the fork’s adapter selection. Based-on: Marvisak#139 Based-on: Marvisak#244 Based-on: Marvisak#573 Tested-on: Intel Xeon E5-2670 v3, Fedora Linux 45, five shader regressions and Windows-target Cargo checks Assisted-by: gpt-6.2 sol xhigh
Upstream main merged Marvisak#2143, Marvisak#2162, Marvisak#158, Marvisak#1906 and Marvisak#1152 and took up what Marvisak#1769 (LDS bounds, Marvisak#1949) and Marvisak#1763 (typed UAV formats, Marvisak#2462) did; main's code is kept for those. - emit/lower.rs: ds_bpermute within each half (main's Marvisak#573, same as Marvisak#439's); LDS bounds as main's Marvisak#1949 (Marvisak#1769's test-only counter kept, its and_guard dropped); title-memory marks: main's straddling-write lookup (Marvisak#2484) with Marvisak#2167's current head (3cb308d, rebased on 63bcca4): guarded dirty atomics, raw_dword2, memory_null, synthetic_mark_dxil in lower/mark_tests.rs; the old Marvisak#2167 head taken out first. - emit/host.rs: main's shared WARP device and lock (Marvisak#244) with Marvisak#439's adapter list and Host::on (create_device takes an optional adapter). - descriptor/host.rs: main's Marvisak#2462 format checks; Marvisak#1763's tests kept. - gpu host.rs: main's multi-plane present with Marvisak#2310's crumbed copy. - pipeline.rs: Marvisak#2118/Marvisak#2311's builder and BVH checks with main's skip hashes (Marvisak#1320); draw.rs, shadow.rs, main.rs: both sides. - Tests main added since get Marvisak#439's Parts fields and emit's Target. - README: base 63bcca4; rows of PRs merged upstream, superseded or closed taken out, with a note. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…visak#244) Fixes Marvisak#181. Concurrent WARP (d3d10warp.dll) usage across threads crashes with 0xC0000005 on Windows 11, both when creating/tearing down separate WARP devices and when compiling pipelines or executing work concurrently on a single shared WARP device. Keep one process-wide WARP ID3D12Device in Host::new (for explicit warp = true, VICTORY_WARP=1, and systems whose default DXGI adapter has DXGI_ADAPTER_FLAG_SOFTWARE) and serialize WARP root signature creation, pipeline compilation, draws, and dispatches behind a process-wide mutex. Hardware D3D12 devices remain unserialized. Route diff_tests's direct CreateRootSignature calls through Host::root_signature_bytes so they share the same serialization, and add a multi-threaded WARP regression test (parallel_warp_pipelines_and_draws). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The integration has a different lowering input layout and only permits direct title-address fallback for compute shaders. Exercise that fallback in the same SSA regression and use the available input fields for the permute test. Make the cached sums copyable and close the device creation block after retaining the fork’s adapter selection. Based-on: Marvisak#139 Based-on: Marvisak#244 Based-on: Marvisak#573 Tested-on: Intel Xeon E5-2670 v3, Fedora Linux 45, five shader regressions and Windows-target Cargo checks Assisted-by: gpt-6.2 sol xhigh
…visak#244) Fixes Marvisak#181. Concurrent WARP (d3d10warp.dll) usage across threads crashes with 0xC0000005 on Windows 11, both when creating/tearing down separate WARP devices and when compiling pipelines or executing work concurrently on a single shared WARP device. Keep one process-wide WARP ID3D12Device in Host::new (for explicit warp = true, VICTORY_WARP=1, and systems whose default DXGI adapter has DXGI_ADAPTER_FLAG_SOFTWARE) and serialize WARP root signature creation, pipeline compilation, draws, and dispatches behind a process-wide mutex. Hardware D3D12 devices remain unserialized. Route diff_tests's direct CreateRootSignature calls through Host::root_signature_bytes so they share the same serialization, and add a multi-threaded WARP regression test (parallel_warp_pipelines_and_draws). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The integration has a different lowering input layout and only permits direct title-address fallback for compute shaders. Exercise that fallback in the same SSA regression and use the available input fields for the permute test. Make the cached sums copyable and close the device creation block after retaining the fork’s adapter selection. Based-on: Marvisak#139 Based-on: Marvisak#244 Based-on: Marvisak#573 Tested-on: Intel Xeon E5-2670 v3, Fedora Linux 45, five shader regressions and Windows-target Cargo checks Assisted-by: gpt-6.2 sol xhigh
Fixes #181.
Cause
On Windows 11, concurrent
d3d10warp.dllactivity across threads crashes with0xC0000005(STATUS_ACCESS_VIOLATION). Sharing a single process-wide WARPID3D12DeviceviaOnceLockalone was not enough —VICTORY_WARP=1 cargo test -q -p victory-shader --libstill crashed on the first run — showing that concurrent WARP pipeline compilation / execution itself races insided3d10warp.dll.Change
crates/victory-shader/src/emit/host.rs:ID3D12DeviceinHost::newwhenever WARP is used (warp == true,VICTORY_WARP=1, or when DXGI's default adapter carriesDXGI_ADAPTER_FLAG_SOFTWARE).Host::newinitialization,root_signature_bytes/root_signature_for,compute_pipeline_with,pipeline_with,mesh_pipeline_with,draw, anddispatch) behind a process-wideMutex.Host's lifetime) keepsHost's public API intact and preserves multi-threaded IR/lowering/validation parallelism inapps/victory/src/translate.rs(--jobs N), while leaving hardware D3D12 devices completely unserialized.emit::host::tests::parallel_warp_pipelines_and_draws) that launches 8 threads behind aBarrierto create WARP hosts, compile graphics pipelines, and draw concurrently.crates/victory-shader/src/emit/diff_tests.rs:host.device.CreateRootSignature(...)calls withhost.root_signature_bytes(...)so differential tests also serialize underVICTORY_WARP=1.Verification
Tested on Windows 11 (debug build, synthetic tests only — no game data or console SDK used):
d2a4bae)7f95b87)VICTORY_WARP=1 cargo test -q -p victory-shader --lib0xC0000005)VICTORY_WARP=1 cargo test -q -p victory-shader --lib -- --test-threads=16cargo test -q -p victory-shader --lib(default: hardware + WARP)cargo test -p victory-shadercargo clippy -p victory-shader --all-targets -- -D warningscargo clippy -p victory --all-targetsvictory/victory-shaderrustfmt --edition 2024 --check(touched files)cargo xtask policy151 files ok(Sharing one WARP
ID3D12Devicewithout the mutex was also tested and crashed on run 1 with0xC0000005.)AI assistance
Assisted by Google Antigravity in reproducing the crash, isolating that a shared WARP device without serialization still faults, implementing the fix and regression test, and running the stress and verification checks above.