Repository navigation
D3D12.X: forget command list before its final release - #2852
guinpereira wants to merge 1 commit into
Conversation
|
In Minimal local test, inserted in the existing #[test]
fn lab_command_list_nonfinal_release_consumes_one_reference() {
use std::sync::atomic::{AtomicU32, Ordering};
#[repr(C)]
struct MockList { vtable: *const usize, refs: AtomicU32 }
unsafe extern "system" fn add(this: *mut c_void) -> u32 {
(*(this as *mut MockList)).refs.fetch_add(1, Ordering::SeqCst) + 1
}
unsafe extern "system" fn release(this: *mut c_void) -> u32 {
(*(this as *mut MockList)).refs.fetch_sub(1, Ordering::SeqCst) - 1
}
let original = [0, add as usize, release as usize];
let extended = [original.as_ptr() as usize, 0];
let mut list = MockList {
vtable: unsafe { extended.as_ptr().add(1) },
refs: AtomicU32::new(2),
};
let left = unsafe { cl_release((&raw mut list).cast()) };
assert_eq!((left, list.refs.load(Ordering::SeqCst)), (1, 1));
}The mock uses At minimum, balance the temporary AddRef on every branch, and retain the nonfinal-reference regression. That alone is not proof of a complete #2690 fix: reference-count sampling is not exclusive finalization. The comment says concurrent last-but-one releases fall back to cleanup afterward, but the new code contains no such post-release cleanup. Please also cover concurrent final releases/address reuse with an ownership protocol; do not treat an AddRef return value as synchronization. The existing single-reference DMA-release fixture cannot exercise this ordinary two-reference leak. No title launch, GPU destruction, driver validation, or measured host-RAM delta. AI-assisted verification/source review (OpenAI GPT-6 Astra). Matched execution result (Wine 11.0 / Rust 1.98.1, Windows MSVC target):
Command on each checkout: Local logs: |
…landed superset, probe past xcl-dev#2852)
|
Two contributors checked independently and found that this PR makes the same change as #2691 (for #2690): #1607, group D140. They suggest keeping #2691. If you agree, closing this PR or joining the other one would save the maintainers a review. If the two differ in a way the checks missed, a note in #1607 helps. 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. |
Fixes #2690.
Forgets list/bind/dred state before the runtime frees the list, closing the address-reuse window.
What is in it
crates/xcl/src/hle/d3d12x/real.rs: forget command list state before final release.Tested
cargo test -p xcl --lib -- --test-threads=4: 1315 passed, 4 failed (GPU OOM in dxil fuzz tests, environment), 27 ignored.cargo build -p xcl: clean.Regression run
Reference run on the author's local main (05adb5a). A run on ivall/xcl main and on this PR's head commit is still pending (cold shader cache crashes the title's startup precompile on this machine).
Not tested
AI use
OpenCode, Beam Free - drafted the change; smoke run and review by the author.