A texture is not copied onto itself; the process opts out of the efficiency mode (victory-fork a2537066)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
4b3bdf1f98
commit
0ca4cda3ea
2 files changed
+59
-5
No files matched your search
@@ -858,6 +858,11 @@ fn unlike(dst: This, src: This) -> bool {
|
|||||||
unlike
|
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) {
|
extern "system" fn copy_resource(this: This, dst: This, src: This) {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
{
|
{
|
||||||
@@ -871,6 +876,17 @@ extern "system" fn copy_resource(this: This, dst: This, src: This) {
|
|||||||
if unlike(dst, src) {
|
if unlike(dst, src) {
|
||||||
return;
|
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
|
// A source the title fills itself is uploaded first (upstream
|
||||||
// PR #671): a copy read whatever the host texture held.
|
// PR #671): a copy read whatever the host texture held.
|
||||||
if crate::texture::title_written(from) {
|
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
|
// A destination made level by level gets its levels' memory
|
||||||
// ahead of this list (`crate::tiles`).
|
// ahead of this list (`crate::tiles`).
|
||||||
crate::texture::card_writes(list, dst, to, None);
|
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, dst, COPY_DEST);
|
||||||
ensure_state(list, src, COPY_SOURCE);
|
ensure_state(list, src, COPY_SOURCE);
|
||||||
crate::texture::host_written(dst);
|
|
||||||
#[cfg(feature = "diagnostics")]
|
#[cfg(feature = "diagnostics")]
|
||||||
list.note_op(|| format!("copy resource {src:?} to {dst:?}"));
|
list.note_op(|| format!("copy resource {src:?} to {dst:?}"));
|
||||||
// SAFETY: an open list and live textures.
|
// SAFETY: an open list and live textures.
|
||||||
@@ -977,6 +1005,8 @@ extern "system" fn copy_texture_region(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let mut from = src;
|
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
|
let _upload; // keeps the source alive while this call records it
|
||||||
#[cfg(feature = "diagnostics")]
|
#[cfg(feature = "diagnostics")]
|
||||||
let mut read = None;
|
let mut read = None;
|
||||||
@@ -1013,11 +1043,21 @@ extern "system" fn copy_texture_region(
|
|||||||
let Some(texture) = crate::resource::host_resource(src.resource) else {
|
let Some(texture) = crate::resource::host_resource(src.resource) else {
|
||||||
return;
|
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);
|
list.twin_use(src.resource, false, false);
|
||||||
if crate::texture::title_written(texture) {
|
if crate::texture::title_written(texture) {
|
||||||
crate::texture::upload(list, src.resource, 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();
|
from.resource = texture.as_raw().cast_const().cast();
|
||||||
}
|
}
|
||||||
// A depth texture shaders also write: what they wrote, first (the
|
// 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
|
// of its result into a block-compressed texture of that kind, and
|
||||||
// a copy into a level without memory is dropped.
|
// a copy into a level without memory is dropped.
|
||||||
crate::texture::card_writes(list, dst.resource, to, Some(dst.footprint.offset as u32));
|
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);
|
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;
|
let mut to_location = dst;
|
||||||
to_location.resource = to.as_raw().cast_const().cast();
|
to_location.resource = to.as_raw().cast_const().cast();
|
||||||
let host_box = (!source_box.is_null()).then(|| source_box.cast::<D3D12_BOX>());
|
let host_box = (!source_box.is_null()).then(|| source_box.cast::<D3D12_BOX>());
|
||||||
|
|||||||
@@ -239,13 +239,23 @@ pub fn title() -> Title {
|
|||||||
pub fn use_console_timers() {
|
pub fn use_console_timers() {
|
||||||
use windows_sys::Win32::Media::timeBeginPeriod;
|
use windows_sys::Win32::Media::timeBeginPeriod;
|
||||||
use windows_sys::Win32::System::Threading::{
|
use windows_sys::Win32::System::Threading::{
|
||||||
GetCurrentProcess, PROCESS_POWER_THROTTLING_CURRENT_VERSION,
|
GetCurrentProcess, PROCESS_POWER_THROTTLING_CURRENT_VERSION, PROCESS_POWER_THROTTLING_EXECUTION_SPEED,
|
||||||
PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION, PROCESS_POWER_THROTTLING_STATE,
|
PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION, PROCESS_POWER_THROTTLING_STATE,
|
||||||
ProcessPowerThrottling, SetProcessInformation,
|
ProcessPowerThrottling, SetProcessInformation,
|
||||||
};
|
};
|
||||||
|
// Also: the system does not run this process at reduced speed (its
|
||||||
|
// "efficiency mode": lower clock, the slow cores of a hybrid processor)
|
||||||
|
// when its window is not the one in front, as while its owner works in
|
||||||
|
// another window or streams. The console has eight cores alike and no
|
||||||
|
// such mode. `VICTORY_EFFICIENCY_MODE=1` leaves the system its choice.
|
||||||
|
let execution = if std::env::var_os("VICTORY_EFFICIENCY_MODE").is_some_and(|v| v == "1") {
|
||||||
|
0
|
||||||
|
} else {
|
||||||
|
PROCESS_POWER_THROTTLING_EXECUTION_SPEED
|
||||||
|
};
|
||||||
let keep = PROCESS_POWER_THROTTLING_STATE {
|
let keep = PROCESS_POWER_THROTTLING_STATE {
|
||||||
Version: PROCESS_POWER_THROTTLING_CURRENT_VERSION,
|
Version: PROCESS_POWER_THROTTLING_CURRENT_VERSION,
|
||||||
ControlMask: PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION,
|
ControlMask: PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION | execution,
|
||||||
StateMask: 0,
|
StateMask: 0,
|
||||||
};
|
};
|
||||||
// SAFETY: plain process settings; `keep` outlives the call.
|
// SAFETY: plain process settings; `keep` outlives the call.
|
||||||
|
|||||||
Reference in new issue
Block a user