Merge local/upcopies

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
localandClaude Opus 5.5 committed 2026-11-25 01:12:28 -06:00
commit ff1bd66387
7 files changed
+738 -23

No files matched your search

+33 -7
View File
@@ -809,6 +809,20 @@ fn buffer_range(buffer: This, offset: u64, len: u64) -> Option<*mut u8> {
Some(unsafe { data.add(offset as usize) })
}
/// A copy of title memory that `list` records: on the card at its place in
/// the list ([`crate::host::HostList::place_copy`]), or at submission.
#[cfg(windows)]
fn buffer_copy(this: This, list: &crate::host::HostList, to: *mut u8, from: *const u8, len: usize) {
if len == 0 {
return;
}
if list.place_copy(to as usize, from as usize, len) {
with_state(this, |_, state| state.copied());
} else {
list.defer_copy(to, from, len);
}
}
/// Buffer to buffer: both are host memory, copied at submission.
extern "system" fn copy_buffer_region(
this: This,
@@ -823,7 +837,7 @@ extern "system" fn copy_buffer_region(
&& let Some(to) = buffer_range(dst, dst_offset, len)
&& let Some(from) = buffer_range(src, src_offset, len)
{
list.defer_copy(to, from, len as usize);
buffer_copy(this, list, to, from, len as usize);
}
#[cfg(not(windows))]
let _ = (this, dst, dst_offset, src, src_offset, len);
@@ -879,7 +893,7 @@ extern "system" fn copy_resource(this: This, dst: This, src: This) {
crate::resource::buffer_bytes(dst),
crate::resource::buffer_bytes(src),
) {
list.defer_copy(to, from, a.min(b) as usize);
buffer_copy(this, list, to, from, a.min(b) as usize);
}
}
#[cfg(not(windows))]
@@ -973,12 +987,20 @@ extern "system" fn copy_texture_region(
let Some(data) = buffer_range(src.resource, src.footprint.offset, bytes) else {
return;
};
let Some((buffer, staging)) = list.upload(host, bytes) else {
return;
let buffer = match list.place_source(data as usize, bytes as usize) {
// What shaders wrote to it, at this place of the list.
Some(buffer) => buffer,
None => {
let Some((buffer, staging)) = list.upload(host, bytes) else {
return;
};
// The list owns this mapped D3D12 upload buffer. Wine can
// report its address as MEM_FREE, so use the host-upload
// path.
list.defer_fill_buffer(&buffer, staging, data, bytes as usize);
buffer
}
};
// The list owns this mapped D3D12 upload buffer. Wine can report
// its address as MEM_FREE, so use the host-upload path.
list.defer_fill_buffer(&buffer, staging, data, bytes as usize);
from.resource = buffer.as_raw().cast_const().cast();
from.footprint.offset = 0;
#[cfg(feature = "diagnostics")]
@@ -1309,6 +1331,10 @@ extern "system" fn copy_memory(this: This, dst: u64, src: u64, len: u64, _flags:
&& src != 0
{
let len = len as usize;
if list.place_copy(dst as usize, src as usize, len) {
with_state(this, |_, state| state.copied());
return;
}
list.defer(move || {
if crate::texture::committed(src as *const u8, len)
&& crate::texture::committed(dst as *const u8, len)