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
26 changes: 26 additions & 0 deletions crates/xcl/src/hle/d3d12x/texture_upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ pub(super) struct Pages {
last: Vec<Sent>,
/// what goes up again, and the uploads it has to come behind (`sent`)
again: Option<(Change, Vec<Sent>)>,
/// parts (from, to) a mapping changed under since they were last looked at: compared with
/// what they held at its next upload, as written pages are (`recheck`)
recheck: Vec<(usize, usize)>,
}

/// Where an upload went: the queue, the fence of that queue's uploads and the value behind it.
Expand Down Expand Up @@ -113,6 +116,7 @@ pub(super) fn all_sent(known: &Known, src: usize, size: usize) {
k.hashes.clear();
k.hashes.resize(pages_of(src, size), 0);
k.again = None;
k.recheck.clear();
}

/// Nothing is known about what the PC texture holds: its next upload is of all of it.
Expand Down Expand Up @@ -144,6 +148,28 @@ pub(super) fn stale(known: &Known, parts: Vec<(usize, usize)>) {
});
}

/// `parts` of a texture (from, to) show other pages now (a mapping changed under them): its next
/// upload compares their bytes with what its pages held when they last went up, as for written
/// pages (`take_recheck`), and sends only those that differ. A page whose hash is not known (0)
/// differs; what is known of a page is what the PC texture got (`Hashes::note`), so equal bytes
/// are what it holds there.
pub(super) fn recheck(known: &Known, parts: Vec<(usize, usize)>) {
known.lock().unwrap().recheck.extend(parts);
}

/// The pages of a texture at `src` to compare at this upload (`recheck`): their addresses, sorted.
pub(super) fn take_recheck(known: &Known, src: usize) -> Vec<usize> {
let parts = std::mem::take(&mut known.lock().unwrap().recheck);
let mut out: Vec<usize> = parts
.into_iter()
.filter(|r| r.0 < r.1)
.flat_map(|(from, to)| ((src + from) / PAGE * PAGE..src + to).step_by(PAGE))
.collect();
out.sort_unstable();
out.dedup();
out
}

/// `changed` of a texture (None: all of it) went up on `to`. An older upload of the texture on
/// another queue that has not run yet (and that `to`'s queue has not waited for: `waited`) can land
/// over it: it goes up again, behind that one (`take_again`). True when there is such a thing.
Expand Down
Loading
Loading