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
14 changes: 13 additions & 1 deletion crates/xcl/src/hle/d3d12x/present.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<ID3D12CommandList>() 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;
Expand Down
8 changes: 7 additions & 1 deletion crates/xcl/src/hle/d3d12x/title_textures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Loading