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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@
3. Double-click it. Windows may say the publisher is unknown (the file is not
signed): "More info", then "Run anyway".

The supported Xbox Series build shows the stock Victory keyboard prompts by
default. Animated hold prompts retain their original icons.
Use `--set VICTORY_PROMPTS=gamepad` with `victory play` to show Xbox prompts.
The optional custom mouse-and-keyboard profile continues to use gamepad prompts.
Prompts follow the F1 settings only, nothing is detected: Xbox button prompts
by default, keyboard keys when CONTROLS is KEYBOARD or MOUSE AND KEYBOARD is on.
Animated hold prompts keep their original icons. A custom mouse-and-keyboard
bindings file keeps the gamepad pictures.

- The first start asks once whether to download NVIDIA's DLSS and frame
generation files (about 70 MB) from NVIDIA's own GitHub. They are NVIDIA's
Expand Down
6 changes: 4 additions & 2 deletions apps/victory/src/native_1440p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,11 @@ pub(super) fn prepare(image: &mut PreparedImage, render_1080p: bool) -> Result<(
// no more than 0x1FFFFF of it is left over (`0x247AF25`). Rounded to
// 2 MiB: 0x5E00000 (94 MiB). The stock Series X 64 MiB had no room for
// the legacy surfaces (the title's allocator asserted, `int3` at
// `0x56A2AFD`).
// `0x56A2AFD`). The UI targets stay 2560x1440 at every output size: sized
// for a wider output (3440x1440: 12.25 MiB more), more than 0x1FFFFF was
// left over and every start stopped at that assert (`int3` at `0x247AF2D`).
let pool_size = u32::try_from(
(ui_surface_bytes(LEGACY_UI_WIDTH, LEGACY_UI_HEIGHT)? * 2 + ui_surface_bytes(width(), height())? * 2)
(ui_surface_bytes(LEGACY_UI_WIDTH, LEGACY_UI_HEIGHT)? * 2 + ui_surface_bytes(DEFAULT.0, DEFAULT.1)? * 2)
.next_multiple_of(2 << 20),
)?;
let pool = field::<5>(image, UI_POOL)?;
Expand Down
5 changes: 5 additions & 0 deletions apps/victory/src/play.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ const SETTINGS: &[(&str, &str)] = &[
// 默认跳过人脸重定位和热浪过程;启用人脸修复的启动器会只保留热浪跳过。
// Left out: the face-relocation compute and the heat-haze pass
("VICTORY_LEAVE_OUT", "02384a60fda6f2d0,731a39171b568298"),
// Wave32: write-only last resort for every refused wave64 compute program
// (play clears other VICTORY_* from the surroundings; without this the
// layer's unset default can be missed if a settings file left the name
// empty or at 0. Kamioku on PR #1: picture only with =1.)
("VICTORY_LDS_LAST_RESORT", "1"),
// Pipelines the title makes are written down, for `victory warm`
("VICTORY_PIPELINE_BOOK", "1"),
// Memory stack (skornuta): texture slots left unused are given back, old command allocators
Expand Down
34 changes: 33 additions & 1 deletion apps/victory/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,14 @@ pub fn run(
// generation is on (bound as before otherwise).
let interposed = victory_hle::modules::fidelityfx::Interpose { inner: &with_dlls };
show(&exe_name, image.bind_imports(&interposed, policy)?);
if execute && std::env::var_os("VICTORY_PROMPTS").is_none_or(|mode| mode == "keys") {
// Prompts follow the settings only, nothing is detected: keyboard keys
// when CONTROLS is KEYBOARD or MOUSE AND KEYBOARD is on, the title's own
// Xbox pictures otherwise. (Keys used to be drawn unless
// VICTORY_PROMPTS said otherwise, so players on a pad saw keys.)
if execute && keyboard_selected() {
show_keys_in_prompts(&image, build);
} else if execute {
println!("prompts gamepad pictures: CONTROLS is not KEYBOARD and MOUSE AND KEYBOARD is off");
}
if execute {
let size = image.info().size_of_image as usize;
Expand Down Expand Up @@ -823,6 +829,32 @@ pub fn run(
Ok(())
}

/// Whether the settings ask for keyboard prompts: CONTROLS is KEYBOARD
/// (`VICTORY_CONTROLS=keyboard`) or MOUSE AND KEYBOARD is on (`VICTORY_MNK=1`).
fn keyboard_selected() -> bool {
keyboard_selected_by(std::env::var("VICTORY_CONTROLS").ok().as_deref(), std::env::var("VICTORY_MNK").ok().as_deref())
}

fn keyboard_selected_by(controls: Option<&str>, mnk: Option<&str>) -> bool {
controls.is_some_and(|c| c.eq_ignore_ascii_case("keyboard")) || mnk == Some("1")
}

#[cfg(test)]
mod prompt_choice_tests {
use super::keyboard_selected_by;

/// Keys only when keyboard is selected; a pad setting or nothing set gives the Xbox pictures.
#[test]
fn keys_only_when_keyboard_is_selected() {
assert!(keyboard_selected_by(Some("keyboard"), None));
assert!(keyboard_selected_by(None, Some("1")));
assert!(keyboard_selected_by(Some("gamepad"), Some("1")));
assert!(!keyboard_selected_by(None, None));
assert!(!keyboard_selected_by(Some("gamepad"), None));
assert!(!keyboard_selected_by(Some("dualsense"), Some("0")));
}
}

#[cfg(windows)]
fn show_keys_in_prompts(
image: &victory_loader::LoadedImage,
Expand Down
6 changes: 3 additions & 3 deletions crates/victory-gpu/src/alias_rt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ const ST_PHYSICAL: usize = 2;
const ST_OVERFLOW: usize = 3;
const ST_FALLBACK: usize = 4;

/// Whether physical-page transient RT aliasing is enabled (on by default;
/// `VICTORY_ALIAS_TARGETS=0` disables).
/// Whether physical-page transient RT aliasing is enabled (off by default:
/// it left block artifacts; `VICTORY_ALIAS_TARGETS=1` turns it on).
pub(crate) fn on() -> bool {
static ON: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
*ON.get_or_init(|| std::env::var_os("VICTORY_ALIAS_TARGETS").is_none_or(|v| v != "0"))
*ON.get_or_init(|| std::env::var_os("VICTORY_ALIAS_TARGETS").is_some_and(|v| v == "1"))
}

/// Physical local VRAM bytes currently held by aliased RT heap chunks.
Expand Down
46 changes: 46 additions & 0 deletions crates/victory-gpu/src/compilemem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,23 @@ fn on() -> bool {
})
}

/// Whether, once free commit is under twice the commit floor, only one
/// compile runs at a time (`VICTORY_COMPILE_SERIAL`, on). Off with `=0`.
fn serial_near_commit() -> bool {
static ON: OnceLock<bool> = OnceLock::new();
*ON.get_or_init(|| std::env::var_os("VICTORY_COMPILE_SERIAL").is_none_or(|v| v != "0"))
}

/// A Create*PipelineState that returned E_OUTOFMEMORY: raise the expected
/// cost so the next admits stay one-at-a-time until small compiles teach it
/// down again.
pub(crate) fn note_oom() {
let g = gate();
let mut state = g.state.lock().unwrap_or_else(|e| e.into_inner());
state.estimator.record(MOST);
g.changed.notify_all();
}

/// What compiles are expected to take, from what they took.
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub(crate) struct Estimator {
Expand Down Expand Up @@ -160,6 +177,19 @@ impl State {
} else {
Verdict::Allow
};
// Near the commit floor (under 2×): one compile at a time. The first
// guess of 1 GB under-counted mesh compiles that took ~2.8 GB
// (upstream #2303), so several were let through and then failed with
// 0x8007000E for good. `VICTORY_COMPILE_SERIAL=0` turns this off.
if gated
&& serial_near_commit()
&& !self.running.is_empty()
&& let Some(f) = figures
&& floors.commit > 0
&& f.free_commit < floors.commit.saturating_mul(2)
{
verdict = Verdict::Throttle;
}
// Short of free physical memory (a soft floor): compiles go one at a
// time, never refused for that alone.
if verdict == Verdict::Throttle && self.running.is_empty() {
Expand Down Expand Up @@ -443,6 +473,22 @@ mod tests {
assert_eq!(admit(figures(0, 0), off, 12, 6 * GB, false), Verdict::Allow);
}

#[test]
fn near_the_commit_floor_a_second_compile_waits() {
// 6 GB free over a 4 GB floor: admit alone would allow two of 1 GB, but
// under 2× the floor the serial rule holds the second.
let f = figures(30 * GB, 6 * GB);
let mut s = State::default();
assert_eq!(s.try_start("a", f, floors(), 0, true, false).0, Verdict::Allow);
// Without the serial rule this would be Allow (6−1 ≥ 4).
assert_eq!(admit(f, floors(), 1, GB, false), Verdict::Allow);
// With it applied in try_start (and serial on by default): Throttle.
let second = s.try_start("b", f, floors(), 0, true, false).0;
if serial_near_commit() {
assert_eq!(second, Verdict::Throttle);
}
}

#[test]
fn an_allocation_that_just_failed_lets_no_second_compile_start() {
// Plenty of room, but the system just said out of memory: one goes on
Expand Down
55 changes: 54 additions & 1 deletion crates/victory-gpu/src/cores.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,57 @@ pub(crate) fn place_process() {
});
}

/// On a hybrid processor (P + E cores), carve one physical P-core for
/// `victory-submit` alone (`VICTORY_SUBMIT_PCORE=1`, off by default). The
/// rest of the process keeps the remaining P-cores (and E-cores stay for the
/// title / pipeline makers via the usual fast-core selection). Aimed at
/// 20-thread Intel parts (i7-12700K class) where the submitting thread is the
/// frame wall (~50 ms) and sharing a P-core's SMT sibling costs idle GPU time.
fn carve_submit_pcore() {
use windows_sys::Win32::System::Threading::{GetCurrentProcess, GetProcessAffinityMask, SetProcessDefaultCpuSets};
if submit_core_mode() == SubmitCore::Off || std::env::var_os("VICTORY_SUBMIT_PCORE").is_none_or(|v| v != "1") {
return;
}
let sets = cpu_sets();
let classes: Vec<(u32, u8)> = sets.iter().map(|s| (s.0, s.1)).collect();
let fast = fast_of(&classes);
if fast.is_empty() {
tracing::info!("VICTORY_SUBMIT_PCORE=1: no hybrid P/E split; nothing carved");
return;
}
let Some((id, others_fast)) = carve_core(&sets, &fast) else {
tracing::info!(fast = fast.len(), "VICTORY_SUBMIT_PCORE=1: could not carve a P-core");
return;
};
// Process default: every set except the carved P-core's physical core.
let carved_core = sets.iter().find(|s| s.0 == id).map(|s| s.3);
let others: Vec<u32> = sets
.iter()
.filter(|s| carved_core.is_none_or(|c| s.3 != c))
.map(|s| s.0)
.collect();
let every = sets.iter().fold(0usize, |m, s| m | 1 << s.2);
let (mut ours, mut all) = (0usize, 0usize);
// SAFETY: this process's own masks.
if unsafe { GetProcessAffinityMask(GetCurrentProcess(), &mut ours, &mut all) } != 0 && ours & every != every {
tracing::warn!(mask = %format!("{ours:#x}"), "the process was started with an affinity mask: no P-core kept for the submitting thread");
return;
}
// SAFETY: our own process and a list of the system's own set ids.
if unsafe { SetProcessDefaultCpuSets(GetCurrentProcess(), others.as_ptr(), others.len() as u32) } == 0 {
tracing::warn!(error = %std::io::Error::last_os_error(), "no P-core kept for the submitting thread: the process's sets were refused");
return;
}
let _ = PROCESS_SETS.set(others);
SUBMIT_SET.store(id, std::sync::atomic::Ordering::Release);
SUBMIT_ALONE.store(true, std::sync::atomic::Ordering::Release);
tracing::info!(
set = id,
remaining_p = others_fast.len(),
"a physical P-core kept for the submitting thread alone (VICTORY_SUBMIT_PCORE=1)"
);
}

/// Where the process is not put on one half ([`place_process`]): on a processor of one core class
/// with two logical processors a core and six cores or more, one physical core (both its logical
/// processors) is kept for `victory-submit` alone, every other thread of the process off it, as
Expand All @@ -237,12 +288,14 @@ pub(crate) fn place_process() {
fn carve_submit_core_alone() {
use windows_sys::Win32::System::Threading::{GetCurrentProcess, GetProcessAffinityMask, SetProcessDefaultCpuSets};
if submit_core_mode() == SubmitCore::Off || std::env::var_os("VICTORY_SUBMIT_CORE_ALONE").is_none_or(|v| v != "1") {
carve_submit_pcore();
return;
}
let sets = cpu_sets();
let classes: Vec<(u32, u8)> = sets.iter().map(|s| (s.0, s.1)).collect();
// Two kinds of cores: the submitting thread is kept on the fast ones already.
// Two kinds of cores: prefer the hybrid P-core carve when asked.
if !fast_of(&classes).is_empty() {
carve_submit_pcore();
return;
}
let mut cores: Vec<u8> = sets.iter().map(|s| s.3).collect();
Expand Down
17 changes: 12 additions & 5 deletions crates/victory-gpu/src/descriptor/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2896,6 +2896,13 @@ pub(crate) const DYNAMIC: u32 = 1 << 18;
/// `null - extra` can never underflow.
const PORTABLE_DYNAMIC_CAP: u32 = DYNAMIC << 1;

/// The dynamic slots of a capped host heap without `VICTORY_DYNAMIC_SLOTS`:
/// 393,216, leaving the title 606,783. [`DYNAMIC`] ran out as a new area
/// streamed in (up to 1,900 draws dropped in five seconds: see-through
/// patches on the character and a ghosted picture); with these no draw was
/// dropped on the same walk, and no title slot past 475,711 was asked for.
const PORTABLE_DYNAMIC_DEFAULT: u32 = DYNAMIC + (DYNAMIC >> 1);

fn dynamic_slots_override() -> Option<u32> {
static OVERRIDE: std::sync::OnceLock<Option<u32>> = std::sync::OnceLock::new();
*OVERRIDE.get_or_init(|| {
Expand Down Expand Up @@ -2930,7 +2937,7 @@ fn dynamic_slots_for(count: u32, null: u32, requested: Option<u32>) -> (u32, boo
// `count`, while still granting unused headroom up to `ceiling`
// (even count so dynamic pairs stay aligned).
let spare = (null.saturating_sub(count) & !1).min(ceiling);
(spare.max(floor), false)
(spare.max(PORTABLE_DYNAMIC_DEFAULT.min(ceiling)).max(floor), false)
}
};
}
Expand Down Expand Up @@ -9686,8 +9693,8 @@ void main() {
#[test]
fn dynamic_slots_for_portable_and_uncapped_hosts() {
let nvidia_null = PORTABLE_VIEWS - 1;
assert_eq!(dynamic_slots_for(1_000_000, nvidia_null, None), (DYNAMIC, false));
assert_eq!(dynamic_slots_for(1_048_576, nvidia_null, None), (DYNAMIC, false));
assert_eq!(dynamic_slots_for(1_000_000, nvidia_null, None), (PORTABLE_DYNAMIC_DEFAULT, false));
assert_eq!(dynamic_slots_for(1_048_576, nvidia_null, None), (PORTABLE_DYNAMIC_DEFAULT, false));
assert_eq!(dynamic_slots_for(1_000_000, nvidia_null, Some(393_216)), (393_216, false));
assert_eq!(dynamic_slots_for(1_000_000, nvidia_null, Some(524_288)), (524_288, false));
assert_eq!(
Expand Down Expand Up @@ -9716,8 +9723,8 @@ void main() {
};
// SAFETY: live heap query.
assert_eq!(unsafe { default_heap.heap.GetDesc().NumDescriptors }, PORTABLE_VIEWS);
assert_eq!(default_heap.dynamic, DYNAMIC);
assert_eq!(default_heap.count, nvidia_null - DYNAMIC);
assert_eq!(default_heap.dynamic, PORTABLE_DYNAMIC_DEFAULT);
assert_eq!(default_heap.count, nvidia_null - PORTABLE_DYNAMIC_DEFAULT);

let raised = HostHeap::new_with(false, 1_000_000, Some(nvidia_null), Some(393_216))
.expect("PORTABLE_VIEWS heap with 393,216 dynamic slots");
Expand Down
Loading