Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions crates/xcl/src/hle/d3d12x/late_release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ pub fn enabled() -> bool {
*ON.get_or_init(|| !std::env::var("XCL_LATE_RELEASE").is_ok_and(|v| v.trim() == "0"))
}

/// Force the one-time read of `XCL_LATE_RELEASE` on the calling (Wine) thread.
///
/// D3DMetal calls `Release` on adopted resources from a native thread of its own, which has
/// no Wine TEB. Reading the environment there for the first time never returns. Calling
/// this from `real::adopt` -- on the Wine thread that creates the object -- makes sure the
/// `OnceLock` inside `enabled()` is already set before the host's thread can reach it.
pub fn init() {
let _ = enabled();
}

/// how long a last `Release` itself waits for queues with nothing to do to say so
const IDLE_WAIT: Duration = Duration::from_micros(300);

Expand Down
4 changes: 4 additions & 0 deletions crates/xcl/src/hle/d3d12x/real.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,10 @@ pub unsafe fn adopt(obj: *mut c_void, kind: Kind) {
if is_ext(v) {
return;
}
// Read the setting `res_release` needs here, on the thread adopting the object: D3DMetal
// releases the resources of an executed list on a thread of its own, which has no Wine TEB,
// and reading the environment there for the first time never returns.
super::late_release::init();
let ext = class_for(obj, v, kind);
*(obj as *mut usize) = ext;
}
Expand Down
Loading