|
|
@@ -858,6 +858,11 @@ fn unlike(dst: This, src: This) -> bool {
|
|
|
unlike
|
|
|
}
|
|
|
|
|
|
+/// Copies left out because both sides were one host texture
|
|
|
+/// ([`copy_resource`], [`copy_texture_region`]), since the start.
|
|
|
+#[cfg(windows)]
|
|
|
+pub(crate) static SELF_COPIES: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
|
|
|
+
|
|
|
extern "system" fn copy_resource(this: This, dst: This, src: This) {
|
|
|
#[cfg(windows)]
|
|
|
{
|
|
|
@@ -871,6 +876,17 @@ extern "system" fn copy_resource(this: This, dst: This, src: This) {
|
|
|
if unlike(dst, src) {
|
|
|
return;
|
|
|
}
|
|
|
+ // Two title textures over the same memory have one host
|
|
|
+ // texture between them: the copy would be of that texture onto
|
|
|
+ // itself, which the host does not allow, and it would change
|
|
|
+ // nothing. It was recorded all the same, with the texture left
|
|
|
+ // in the source state as the copy's destination (run 205's
|
|
|
+ // debug layer: "CopyResource with its destination in the
|
|
|
+ // COPY_SOURCE state", 37 times, a 2560x1440 depth texture).
|
|
|
+ // Only the two state changes and the copy are left out: what
|
|
|
+ // is noted of the textures stays as it was. After
|
|
|
+ // triippywhale 6e502b3b.
|
|
|
+ let same = windows::core::Interface::as_raw(to) == windows::core::Interface::as_raw(from);
|
|
|
// A source the title fills itself is uploaded first (upstream
|
|
|
// PR #671): a copy read whatever the host texture held.
|
|
|
if crate::texture::title_written(from) {
|
|
|
@@ -882,9 +898,21 @@ extern "system" fn copy_resource(this: This, dst: This, src: This) {
|
|
|
// A destination made level by level gets its levels' memory
|
|
|
// ahead of this list (`crate::tiles`).
|
|
|
crate::texture::card_writes(list, dst, to, None);
|
|
|
+ crate::texture::host_written(dst);
|
|
|
+ if same {
|
|
|
+ SELF_COPIES.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
|
|
+ static ONCE: std::sync::Once = std::sync::Once::new();
|
|
|
+ ONCE.call_once(|| {
|
|
|
+ tracing::info!(
|
|
|
+ ?dst,
|
|
|
+ ?src,
|
|
|
+ "a copy between two title textures that share one host texture is left out: the first one"
|
|
|
+ );
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
ensure_state(list, dst, COPY_DEST);
|
|
|
ensure_state(list, src, COPY_SOURCE);
|
|
|
- crate::texture::host_written(dst);
|
|
|
#[cfg(feature = "diagnostics")]
|
|
|
list.note_op(|| format!("copy resource {src:?} to {dst:?}"));
|
|
|
// SAFETY: an open list and live textures.
|
|
|
@@ -977,6 +1005,8 @@ extern "system" fn copy_texture_region(
|
|
|
return;
|
|
|
}
|
|
|
let mut from = src;
|
|
|
+ // Both sides are the same subresource of one host texture (set below).
|
|
|
+ let mut same = false;
|
|
|
let _upload; // keeps the source alive while this call records it
|
|
|
#[cfg(feature = "diagnostics")]
|
|
|
let mut read = None;
|
|
|
@@ -1013,11 +1043,21 @@ extern "system" fn copy_texture_region(
|
|
|
let Some(texture) = crate::resource::host_resource(src.resource) else {
|
|
|
return;
|
|
|
};
|
|
|
+ // The same subresource of one host texture on both sides (two
|
|
|
+ // title textures over one memory): not a copy the host allows.
|
|
|
+ // The states and the copy are left out below; the rest is
|
|
|
+ // noted as before.
|
|
|
+ same = texture.as_raw() == to.as_raw()
|
|
|
+ && src.kind != FOOTPRINT
|
|
|
+ && dst.kind != FOOTPRINT
|
|
|
+ && src.footprint.offset as u32 == dst.footprint.offset as u32;
|
|
|
list.twin_use(src.resource, false, false);
|
|
|
if crate::texture::title_written(texture) {
|
|
|
crate::texture::upload(list, src.resource, texture);
|
|
|
}
|
|
|
- ensure_state(list, src.resource, COPY_SOURCE);
|
|
|
+ if !same {
|
|
|
+ ensure_state(list, src.resource, COPY_SOURCE);
|
|
|
+ }
|
|
|
from.resource = texture.as_raw().cast_const().cast();
|
|
|
}
|
|
|
// A depth texture shaders also write: what they wrote, first (the
|
|
|
@@ -1061,8 +1101,12 @@ extern "system" fn copy_texture_region(
|
|
|
// of its result into a block-compressed texture of that kind, and
|
|
|
// a copy into a level without memory is dropped.
|
|
|
crate::texture::card_writes(list, dst.resource, to, Some(dst.footprint.offset as u32));
|
|
|
- ensure_state(list, dst.resource, COPY_DEST);
|
|
|
crate::texture::host_written(dst.resource);
|
|
|
+ if same {
|
|
|
+ SELF_COPIES.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ensure_state(list, dst.resource, COPY_DEST);
|
|
|
let mut to_location = dst;
|
|
|
to_location.resource = to.as_raw().cast_const().cast();
|
|
|
let host_box = (!source_box.is_null()).then(|| source_box.cast::<D3D12_BOX>());
|