diff --git a/crates/xcl/src/hle/d3d12x/present.rs b/crates/xcl/src/hle/d3d12x/present.rs index 01b3c92a4a..6df9d83b6d 100644 --- a/crates/xcl/src/hle/d3d12x/present.rs +++ b/crates/xcl/src/hle/d3d12x/present.rs @@ -733,7 +733,19 @@ unsafe fn present_now(min_interval: Duration, frame: Option<(usize, usize)>) { let qraw = queue as *mut c_void; let Some(q) = ID3D12CommandQueue::from_raw_borrowed(&qraw) else { return }; let Ok(cl) = p.list.cast::() else { return }; - q.ExecuteCommandLists(&[Some(cl)]); + // The copy reads only `src`, a GPU resource (render targets are not kept in step with title + // memory): XCL's own submit, with no second look at the title's memory – what the CPU wrote + // since the title's last submit stays dirty and goes up before its next one. That look cost + // a quarter of the submit thread in profiling. A `src` kept in step is looked at as before. The + // queue still waits for the pages mapped since its last work, as XCL's other own work does. + if super::title_textures::address(src.as_raw() as usize).is_some() { + q.ExecuteCommandLists(&[Some(cl)]); + } else { + super::title_textures::own_work(|| { + super::vram::before_execute(q); + q.ExecuteCommandLists(&[Some(cl)]); + }); + } p.copy_source = Some(src); p.dumps = dumps; p.value += 1; diff --git a/crates/xcl/src/hle/d3d12x/title_textures.rs b/crates/xcl/src/hle/d3d12x/title_textures.rs index ada439cbaa..9d7557a3b2 100644 --- a/crates/xcl/src/hle/d3d12x/title_textures.rs +++ b/crates/xcl/src/hle/d3d12x/title_textures.rs @@ -1327,8 +1327,14 @@ mod tests { let key = texture.as_raw() as usize; register(raw_device, texture.as_raw(), va, &console, D3D12_RESOURCE_STATE_COMMON).unwrap(); let _registered = RegisteredTexture(key); - for value in [0x3D, 0x9A] { + for (k, value) in [0x3D, 0x9A].into_iter().enumerate() { std::ptr::write_bytes(src as *mut u8, value, PAGE); + if k > 0 { + // XCL's own submits (the present copy) do not look: the write waits for the + // title's next submit and is not lost + own_work(|| refresh(queue.as_raw())); + assert_eq!(read_r8(dev, &queue, &texture), vec![0x3D; 64 * 64], "XCL's own work does not upload"); + } refresh(queue.as_raw()); assert_eq!(read_r8(dev, &queue, &texture), vec![value; 64 * 64], "GPU contents follow CPU writes"); assert_eq!(address(key), Some(va), "the title address stays in the GPU view");