diff --git a/crates/xcl/src/hle/d3d12x/cpu_writes.rs b/crates/xcl/src/hle/d3d12x/cpu_writes.rs index f672e42f0a..f399082b96 100644 --- a/crates/xcl/src/hle/d3d12x/cpu_writes.rs +++ b/crates/xcl/src/hle/d3d12x/cpu_writes.rs @@ -69,6 +69,8 @@ fn worker() -> &'static Mutex> { W.get_or_init(|| { let (tx, rx) = mpsc::channel::(); let spawned = std::thread::Builder::new().name("xcl-cpu-writes".into()).spawn(move || unsafe { + // Title threads spin on the values written here (`xcl-fences` has why it is high). + th::SetThreadPriority(th::GetCurrentThread(), th::THREAD_PRIORITY_HIGHEST); let event = th::CreateEventW(std::ptr::null(), 0, 0, std::ptr::null()); for job in rx { if super::real::fence_completed(&job.fence) < job.value && job.fence.SetEventOnCompletion(job.value, HANDLE(event as *mut c_void)).is_ok() { diff --git a/crates/xcl/src/hle/d3d12x/fence_x.rs b/crates/xcl/src/hle/d3d12x/fence_x.rs index 348b70fbc0..0f6cfd70bb 100644 --- a/crates/xcl/src/hle/d3d12x/fence_x.rs +++ b/crates/xcl/src/hle/d3d12x/fence_x.rs @@ -158,10 +158,16 @@ fn event() -> usize { static E: OnceLock = OnceLock::new(); *E.get_or_init(|| unsafe { let e = th::CreateEventW(std::ptr::null(), 0, 0, std::ptr::null()) as usize; - let spawned = std::thread::Builder::new().name("xcl-fences".into()).spawn(move || loop { - th::WaitForSingleObject(e as _, th::INFINITE); - super::title_textures::poll_fence_downloads(); - table().refresh(); + let spawned = std::thread::Builder::new().name("xcl-fences".into()).spawn(move || { + // Title threads spin on the cells this thread writes: at normal priority it can queue + // behind those very threads. It sleeps nearly all the time, so a high priority costs + // them little (not time-critical: a wake can settle readbacks for up to 20 ms). + th::SetThreadPriority(th::GetCurrentThread(), th::THREAD_PRIORITY_HIGHEST); + loop { + th::WaitForSingleObject(e as _, th::INFINITE); + super::title_textures::poll_fence_downloads(); + table().refresh(); + } }); if let Err(err) = spawned { crate::xlog_error!("D3D12.X: no thread for the fences' completed values: {err}");