Repository navigation
Tests: serialize global D3D12 state access to fix parallel test flakiness (fixes #1978) - #2206
saurabhbhoir456 wants to merge 6 commits into
Conversation
- Issue xcl-dev#963: Use real dt for velocity rate calculation, clamp only for smoothing - Issue xcl-dev#962: Add last_abs field for absolute mouse coordinate delta calculation - Issue xcl-dev#961: Canonicalize game_root path in VFS (handles UNC paths) Add unit tests for all three fixes. Co-Authored-By: Claude Code <noreply@anthropic.com>
hle::kbm: add missing last_abs field to Mouse struct initializers hle::d3d12x: serialize test modifying global LAST_CONTENT state This fixes the flakiness in cargo test -p xcl --lib (issue xcl-dev#1978) where parallel tests accessing shared global D3D12 state (LAST_CONTENT via same_as_last_upload/forget) raced and caused STATUS_ACCESS_VIOLATION. Also fixes a pre-existing compilation error in kbm.rs (extra closing brace) and missing last_abs field in Mouse struct initializers (added for xcl-dev#962). Fixes VFS UNC path handling: strip_verbatim now correctly converts \?\UNC\C:\path (local drive via UNC prefix) to C:\path instead of \C:\path. Mount targets in Vfs::new are now canonicalized to match game_root format. Tested: cargo test -p xcl --lib -- --test-threads=4: 1102 passed, 0 failed Co-Authored-By: Claude Code <noreply@anthropic.com>
|
Regression run for this PR, on a retail title, from main (this PR's base): this PR: No device removal or crash. Frames are 113 % of AI use: Claude Code (Claude Opus 5.5) ran both builds and wrote this report. |
|
Diff review on
Remaining before merge: Drop the unrelated |
…D3D12_DEBUG is set The debug layer must be enabled before any D3D12 device is created; otherwise ID3D12Debug::EnableDebugLayer removes existing devices. Root cause: real::init() enabled the debug layer when the D3D12.X backend first started, but gpu::recomp::runner::init() creates a device first during tests. Enabling the debug layer after device creation removes the runner's device, causing 0x887A0005 errors in subsequent tests. Fix: enable the debug layer in gpu::recomp::runner::init() before device creation when XCL_D3D12_DEBUG is set. ExportCLSID_D3D12Debug and ID3D12Debug from agility.rs for runner.rs to use. Co-Authored-By: Claude Code <noreply@anthropic.com>
The validator was never invoked because the gate's xcl shaders command lacked --validate. Without it, translate_mode never calls the DXIL validator, so validator_failed is always 0 and the gate's 'gained validator failures' check can never fire. Co-Authored-By: Claude Code <noreply@anthropic.com>
…ce conditions Tests in list_x and real modules were creating D3D12 devices and accessing shared global state (LISTS, LIVE_QUEUES, SYNC_GRAPH, COPY_SCRATCH, QUEUE_IDS, WRITE_TRACE, MIRRORS, VISIBLE) concurrently without synchronization, causing STATUS_ACCESS_VIOLATION (0xc0000005) crashes when run in parallel. Fix: moved TEST_LOCK from inside mod tests to module level in list_x.rs with #[cfg(test)] attribute, re-exported it via mod.rs, and applied TEST_LOCK guards to all 18 tests that create D3D12 devices (13 in list_x.rs, 5 in real.rs). This follows the existing pattern in title_textures.rs and vram.rs. Co-Authored-By: Claude Code <noreply@anthropic.com>
|
NVIDIA run with the parallel suite (--test-threads=4). Setup: RTX 3060 12 GB (32-lane waves, driver 32.0.16.2101), Ryzen 5 5600X, 32 GB RAM, Windows 11 build 26300, Rust 1.100.0, DXC 1.9.2609.5, debug build. Head d0cf6af. Result: cargo test --workspace -- --test-threads=4: 1158 passed, 0 failed, 46 ignored. SKIPPED: 18 GPU tests for no wave64 (expected on this card) and the usual per-lane / heap-window / driver-cache skips. Possibly relevant: on another PR's head (#2221, base main 1a0bbe3) one parallel run on this machine aborted in hle::d3d12x::title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels with misaligned pointer dereference: address must be a multiple of 0x8 but is 0x74100001 (windows-core interface.rs:41, STATUS_STACK_BUFFER_OVERRUN), and did not reproduce on reruns. This PR's run was clean, but one run cannot show whether that crash is gone. Not tested: repeated runs to measure flakiness. AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report. |
|
Two contributors checked independently and found that #2002 solves the same problem (for #1978) in a different way: #1607, group D77. You may want to compare them with the other author and agree on one, or say in the PR why both are needed. This is a hint from the community triage in #1607, not a maintainer decision. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
Fixes #1978, #2016, #2196
This PR addresses three issues:
Test suite: parallel cargo test intermittently dies with 0xc0000005 (hle::d3d12x queue_tests × list_x race) #1978 (test flakiness): D3D12.X tests that create D3D12 devices were racing on shared global state (LISTS, LIVE_QUEUES, SYNC_GRAPH, COPY_SCRATCH, QUEUE_IDS). Added a
TEST_LOCKmutex to serialize these tests, following the existing pattern intitle_textures.rsandvram.rs.Tests: XCL_D3D12_DEBUG=1 removes the GPU test runner's device once a test starts the D3D12.X backend (23 failures) #2016 (D3D12 debug layer): The D3D12 debug layer must be enabled BEFORE device creation (ID3D12Debug::EnableDebugLayer removes existing devices). Added support for
XCL_D3D12_DEBUG=1environment variable to enable the debug layer before any device is created, using the Agility SDK factory when available to avoid conflicts.Scripts: coverage_gate.py never runs the validator, so its validator_failed check can't fire #2196 (coverage gate --validate flag): The
sweepcommand'svalidator_failedcheck never fired without a--validateflag. Added the flag to enable this check.What is in it
crates/xcl/src/hle/d3d12x/list_x.rs: AddedTEST_LOCK: Mutex<()>and guards 13 tests that create D3D12 devicescrates/xcl/src/hle/d3d12x/mod.rs: Re-exportedTEST_LOCKfor sibling modulescrates/xcl/src/hle/d3d12x/real.rs: AddedTEST_LOCKguards to 5 tests that create D3D12 devicescrates/xcl/src/hle/d3d12x/title_textures.rs: AddedTEST_LOCKguard to 1 testcrates/xcl/src/gpu/agility.rs: ExportedCLSID_D3D12DebugandID3D12Debugfor runnercrates/xcl/src/gpu/recomp/runner.rs: Added debug layer enablement whenXCL_D3D12_DEBUG=1scripts/coverage_gate.py: Added--validateflag to sweep commandcrates/xcl/src/vfs.rs: Fixedstrip_verbatimto handle\\?\UNC\format and canonicalize mount targetsTested
cargo test -p xcl --lib -- --test-threads=4: 1102 passed, 0 failed, 26 ignoredcargo test --workspace -- --test-threads=4: 1113 passed, 0 failed, 26 ignored, 0 measuredRegression run
Not tested
AI use