Repository navigation
Conversation
With XCL_D3D12_DEBUG=1, the debug layer's messages went to the log only through an ID3D12InfoQueue1 message callback. Windows 10 has no ID3D12InfoQueue1 (the cast fails with E_NOINTERFACE, measured on 19045 with the Agility SDK 1.620.2), the failure was ignored, and the log got no message at all. test_title_draws_with_a_root_signature_under_the_debug_layer passed there without seeing any. Without ID3D12InfoQueue1 the device's ID3D12InfoQueue is kept, and its stored messages are logged (same caps) and cleared at every submission and present, in stop_if_device_removed, before a removal is reported. The test adds an application message to the debug layer's queue and expects it in the log after stop_if_device_removed. It fails on main on Windows 10. On the retail title, the log now shows the debug layer's errors (e.g. ids 538 and 1422) where it showed none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent verification, merged onto current Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti + Radeon iGPU; Rust stable MSVC, debug.
AI use: test runs by Devin (Cognition, SWE-2); no code changes. |
|
Windows 11 callback timing and per-ID cap on head 8dde8ff, RX 9070 XT (32.0.32029.2010), Windows Graphics Tools installed. I extended the integration test locally: required ID3D12InfoQueue1 on the real device, added the same application error 12 times, flushed the XCL log before the first stop_if_device_removed call, then called it twice and flushed again. Matching log lines: 8 before either call, 8 after both. This verifies immediate callback delivery and the 8-per-ID cap on this setup. The cap could also suppress duplicates, so the final count alone cannot establish whether polling was internally attempted. The Windows 10 fallback and concurrent writers were outside this test. AI use: Codex wrote and ran the scratch test and prepared this report. Follow-up below the per-ID cap: I injected three identical application errors in fresh processes using the same scratch binary. Matching log lines before polling / after one poll / after a second poll: native callback 3/3/3; forced fallback 0/3/3. The only runtime instrumentation was a short-circuit around callback registration; the device, queue and polling implementation were real. This verifies deferred delivery and no duplicate on a second empty poll in this single-writer Windows 11 test. It does not simulate concurrent insertion or Windows 10 interface discovery. Concurrent-writer measurement on the forced polling path (same Windows 11 setup): seven distinct text markers sharing one application message ID, below the cap of eight. Each AddApplicationMessage succeeded. In 12 fresh processes where the poller waited for the writer to finish, the log retained 84/84 markers. In 12 fresh processes where the poller called stop_if_device_removed in a tight loop alongside the writer, followed by a final poll after join, it retained 35/84 (per trial: 1,1,1,1,1,7,5,4,1,7,5,1). This measures the snapshot/clear limitation already disclosed in the PR under synthetic contention; it is not an estimate of retail message loss. No game files or device removal involved. Reproducer patch for 8dde8ff (test instrumentation only)Save the diff as queue.patch and run the following in PowerShell from the repository root. Change the adapter selector for other hardware. Run each mode in fresh processes several times because the concurrent case can pass. Count a run only if it prints observed=N/7. Without a real GPU backend or debug queue this integration test can return early and Cargo can still report success. The sequential control should print observed=7/7. git apply queue.patch
$env:XCL_ADAPTER = '9070'
$env:XCL_LOCAL_TEST_POLL = '1'
Remove-Item Env:XCL_LOCAL_RACE -ErrorAction SilentlyContinue
cargo test --locked -p xcl --test debug_layer_log -- --nocapture
$env:XCL_LOCAL_RACE = '1'
cargo test --locked -p xcl --test debug_layer_log -- --nocapture--- a/crates/xcl/src/hle/d3d12x/real.rs
+++ b/crates/xcl/src/hle/d3d12x/real.rs
@@ -529,7 +529,7 @@
// through a callback where the system has ID3D12InfoQueue1; Windows 10 does not, and
// there they are read from the device's message queue (`poll_debug_messages`)
let mut cookie = 0u32;
- let callback = device
+ let callback = std::env::var_os("XCL_LOCAL_TEST_POLL").is_none() && device
.cast::<ID3D12InfoQueue1>()
.is_ok_and(|q| q.RegisterMessageCallback(Some(debug_message), D3D12_MESSAGE_CALLBACK_FLAG_NONE, std::ptr::null_mut(), &mut cookie).is_ok());
if !callback {
--- a/crates/xcl/tests/debug_layer_log.rs
+++ b/crates/xcl/tests/debug_layer_log.rs
@@ -26,13 +26,30 @@
println!("SKIPPED debug_layer_messages_reach_the_log: no D3D12 debug layer");
return;
};
- let text = "xcl test: a debug layer message";
- let c = std::ffi::CString::new(text).unwrap();
- unsafe { queue.AddApplicationMessage(D3D12_MESSAGE_SEVERITY_ERROR, PCSTR(c.as_ptr() as *const u8)) }.expect("AddApplicationMessage");
+ let racing = std::env::var_os("XCL_LOCAL_RACE").is_some();
+ let gate = std::sync::Arc::new(std::sync::Barrier::new(2));
+ let writer_gate = gate.clone();
+ let writer = std::thread::spawn(move || {
+ writer_gate.wait();
+ for i in 0..7 {
+ let text = std::ffi::CString::new(format!("xcl-local-race-{i}-end")).unwrap();
+ unsafe { queue.AddApplicationMessage(D3D12_MESSAGE_SEVERITY_ERROR, PCSTR(text.as_ptr().cast())) }.unwrap();
+ std::thread::yield_now();
+ }
+ });
+ gate.wait();
+ if racing {
+ while !writer.is_finished() {
+ real::stop_if_device_removed();
+ }
+ }
+ writer.join().unwrap();
real::stop_if_device_removed();
xcl::log::flush();
- let log = std::fs::read_to_string(&path).unwrap_or_default();
+ let log = std::fs::read_to_string(&path).unwrap();
+ let observed = (0..7).filter(|i| log.contains(&format!("xcl-local-race-{i}-end"))).count();
+ println!("observed={observed}/7");
+ assert!(log.contains("D3D12: debug layer enabled"));
let _ = std::fs::remove_dir_all(&dir);
- assert!(log.contains("D3D12: debug layer enabled"), "the debug layer did not come up:\n{log}");
- assert!(log.lines().any(|l| l.contains("D3D12 debug layer (error") && l.contains(text)), "the debug layer's message is not in the log:\n{log}");
+ assert_eq!(observed, 7, "messages lost before final poll");
} |
With
XCL_D3D12_DEBUG=1, the debug layer's messages reachedxcl.logonly through anID3D12InfoQueue1message callback. Windows 10 has noID3D12InfoQueue1: the cast fails withE_NOINTERFACE(measured on 19045 with the Agility SDK 1.620.2), the failure was ignored, and the log got no message at all. The debug layer was on but silent there, andtest_title_draws_with_a_root_signature_under_the_debug_layerpassed without seeing a single message.Without
ID3D12InfoQueue1, XCL now keeps the device'sID3D12InfoQueue, logs its stored messages with the same caps (8 per id, 3 000 in all) and clears it, at every submission and present (stop_if_device_removed). The messages that led to a device removal are logged before the removal. WithID3D12InfoQueue1nothing changes.What is in it
crates/xcl/src/hle/d3d12x/real.rs: the fallback toID3D12InfoQueue(poll_debug_messages, called first instop_if_device_removed). The callback and the poll sharelog_debug_message.crates/xcl/tests/debug_layer_log.rs(its own process): adds an application message to the debug layer's queue and expects it in the log afterstop_if_device_removed. Skipped without the debug layer.Tested
stable-x86_64-pc-windows-msvc; DXC 1.8.2502.11; tests in debug, runs in release.cargo test --workspace --no-fail-fast -- --test-threads=4on8dde8ff: 713 passed, 4 failed, 41 ignored, noSKIPPED. The same 4 fail onmain09940bb(712 passed, 4 failed, 41 ignored):xmem_virtual_query_marks_cpu_readable_memory(misaligned output buffer, Tests: align XMemVirtualQuery buffers and verify CPU flags #650 / Tests: align the XMemVirtualQuery output buffer #656) andplaced_title_textures_share_vram_and_preserve_pixelswith the two tests on its poisoned lock (Tests: placed_title_textures_share_vram_and_preserve_pixels fails now and then at its cubemap reuse check (main 9ce2070) #718, Tests: check cubemap tile reuse independently of idle page reclamation #447).cargo test -p xcl --test debug_layer_log: fails onmain(the message is not in the log), passes here.test_title_draws_with_a_root_signature_under_the_debug_layer: passes on both. Onmainthe test title's log has 0 debug layer messages, here 22 (none about a missing root signature).XCL_D3D12_DEBUG=1andXCL_NETWORK=0: 53 debug layer messages in 30 s here (20 errors, ids 538, 1047, 824, 723, 1422); none in a 35 s run onmain.Regression run
main:This PR:
The smoke runs do not turn the debug layer on: without it the new code is a lock on an empty slot.
Not tested
ID3D12InfoQueue1(Windows 11): the callback path is unchanged, but the new test was not run there (it should pass through the callback).AI use
🤖 Generated with Claude Code