Skip to content
Draft
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
2 changes: 2 additions & 0 deletions crates/xcl/src/hle/d3d12x/cpu_writes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ fn worker() -> &'static Mutex<mpsc::Sender<Job>> {
W.get_or_init(|| {
let (tx, rx) = mpsc::channel::<Job>();
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() {
Expand Down
14 changes: 10 additions & 4 deletions crates/xcl/src/hle/d3d12x/fence_x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,16 @@ fn event() -> usize {
static E: OnceLock<usize> = 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}");
Expand Down
Loading