Files
VIctory-NVIDIA/scripts/play-rig.ps1
gertvw23 abfc2bde3a Rig launcher: live watch, processes left behind, tests
- scripts\watch-rig.ps1: the live watch as a script of its own (-Watch
  opens it beside the game): fps, stalls, memory and GPU every minute;
  alerts at once on low commit, out-of-memory, log errors, stalls, GPU
  heat, and a hang (the game's log still for 60 s, or its window not
  responding for 15 s), as the start that froze on 2026-11-28 did.
- Processes left behind: every victory.exe is listed as game, preload or
  warm worker; only those left behind (a game without a window, a preload
  or worker whose parent is gone) are offered to be ended, with what they
  started. Work whose parent still runs is listed and left alone.
- An error in the watcher's runspace is now reported instead of lost.
  It found a bug in this change: the new -Watch switch and the watcher's
  $watch script block were one variable (names are not case-sensitive),
  so the runspace ran the word False. Renamed to $watchScript.
- scripts\tests\play-rig.Tests.ps1: 13 Pester tests (3.4, Windows 10's
  own) against a stand-in victory.exe in a temporary VICTORY_HOME.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-28 21:06:52 +01:00

938 lines
59 KiB
PowerShell

# Starts the title on VIctory-NVIDIA with settings worked out for THIS PC: the processor's fast and slow cores,
# the card and its memory, how much memory Windows can still commit, the disk, the monitor. A wrapper around
# `victory.exe play`; the layer and the title's files are not changed.
#
# .\Play-MyRig.cmd double click: checks this PC, then plays
# .\scripts\play-rig.ps1 -Exe 'D:\MyDump\game_scarlett_master.exe' (remembered after the first time)
# .\scripts\play-rig.ps1 -Check only the checks, the settings and the command it would run
# .\scripts\play-rig.ps1 -Summary what the newest run's log says (fps, stalls, memory, crash)
# .\scripts\play-rig.ps1 -Cores pcores also keep the title's threads on the fast cores (try A/B)
# .\scripts\play-rig.ps1 -NoFrameGen -Dlss dlaa override what it picked
# .\scripts\play-rig.ps1 -Set VICTORY_X=1 add or override any switch (as often as needed)
#
# What it does, in order (docs/rig-launcher.md has the why of each):
# 1. Looks at the PC: CPU fast/slow cores, GPU, VRAM, driver, RAM, commit room, page file, the game's disk,
# Windows build and its Direct3D 12 runtime, GPU scheduling, power plan, monitor.
# 2. Checks what stopped earlier runs: a game process left behind without a window, and too little room
# to commit memory (the E_OUTOFMEMORY "no shared buffer" crash).
# 3. Picks the options and switches for this PC and starts `victory.exe play` with them (`--set`, so the F1
# menu's SAVE AND RESTART keeps them). Preloads shaders the first time for this victory.exe and driver.
# 4. While the game runs: makes its window borderless full screen at the monitor's size (one game pixel per
# screen pixel) and, with -Cores pcores, keeps the title's threads on the fast cores; again after a
# restart from the F1 menu.
# 5. After it closes: a summary of the run's log, and a line in %LOCALAPPDATA%\victory\rig-runs.csv so runs
# with different settings can be compared.
#
# Windows PowerShell 5.1 or PowerShell 7. ASCII only (5.1 reads files without a BOM as ANSI).
[CmdletBinding()]
param(
# The title's game_scarlett_master.exe. Not given: VICTORY_GAME_DIR, the last one used, victory.toml's
# game_dir, else asked.
[string]$Exe,
# victory.exe. Not given: the last one used, the one beside the title, else target\release here.
[string]$Victory,
# Only the checks, the settings and the command; nothing is started.
[switch]$Check,
# Only the summary of the newest run's log (or of -Log).
[switch]$Summary,
[string]$Log,
# layer: the layer's own placement (its threads a frame waits for on the fast cores; the default).
# pcores: the title's threads too, through the process's default CPU sets (a preference, not a hard mask).
[ValidateSet('layer', 'pcores')][string]$Cores = 'layer',
[ValidateSet('auto', 'off', 'dlaa', 'quality', 'balanced', 'performance')][string]$Dlss = 'auto',
[ValidateSet('auto', '1440', '1080to1440', '4k')][string]$Res = 'auto',
# Frames shown for each one rendered, 2 to 6 (0: off). Not given: 2 on an RTX 40 or 50 with GPU scheduling on.
[ValidateRange(-1, 6)][int]$FrameGen = -1,
[switch]$NoFrameGen,
[switch]$SeriesS,
# Frames a second at most (0: no cap, 1000 to the layer).
[ValidateRange(0, 1000)][int]$Fps = 0,
# auto: once for each victory.exe and graphics driver (asked: yes, no this time, or skip for this version);
# yes: now; no: not this time.
[ValidateSet('auto', 'yes', 'no')][string]$Preload = 'auto',
# An A/B test: this start takes whichever variant has the fewer runs of a minute or more in rig-runs.csv.
# cores: -Cores layer or pcores; room: the launcher's texture room (80 %) or the one worked out for the card.
[ValidateSet('', 'cores', 'room')][string]$Try = '',
# Only the comparison of the runs in rig-runs.csv, by settings, and what they say about the memory needed.
[switch]$Compare,
[switch]$NoFullscreen,
# A second window with scripts\watch-rig.ps1: fps, memory and GPU every minute, alerts at once, until the game ends.
[switch]$Watch,
# Add or override a switch: -Set VICTORY_X=1,VICTORY_Y=2
[string[]]$Set = @(),
# Take the default answer to every question.
[switch]$Yes
)
$ErrorActionPreference = 'Continue'
$repo = Split-Path $PSScriptRoot -Parent
$vhome = if ($env:VICTORY_HOME) { $env:VICTORY_HOME } else { Join-Path $env:LOCALAPPDATA 'victory' }
New-Item -ItemType Directory -Force $vhome | Out-Null
$stateFile = Join-Path $vhome 'rig-launcher.json'
$runsFile = Join-Path $vhome 'rig-runs.csv'
$interactive = [Environment]::UserInteractive -and -not [Console]::IsInputRedirected -and -not $Yes
# Commit room the title and the layer need. Measured on an i5-13600K / RTX 4080 / 32 GB PC (2026-11-28, Series X
# 1440p, DLSS Quality): the run that ended in E_OUTOFMEMORY ("no shared buffer", then "a host command list did not
# close") had 3.9 GB of commit left six seconds in, with about 20 GB already taken by other programs; the title
# and the layer held about 24 GB by then, and more while the world loads.
$CommitComfortGB = 32
$CommitTightGB = 26
# What DLSS frame generation takes of the card's memory (play.rs: "1.5 to 2 GB"), plus a margin.
$FrameGenVramMB = 2300
Add-Type -TypeDefinition @'
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
public static class RigNative {
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool GetSystemCpuSetInformation(IntPtr information, uint bufferLength, out uint returnedLength, IntPtr process, uint flags);
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool SetProcessDefaultCpuSets(IntPtr process, uint[] cpuSetIds, uint cpuSetIdCount);
[DllImport("kernel32.dll", SetLastError = true)]
static extern IntPtr OpenProcess(uint access, bool inherit, int pid);
[DllImport("kernel32.dll")]
static extern bool CloseHandle(IntPtr handle);
// The system's CPU sets: { id, group, logical processor index, core index, efficiency class (higher: faster) }.
public static List<uint[]> CpuSets() {
List<uint[]> sets = new List<uint[]>();
uint length = 0;
GetSystemCpuSetInformation(IntPtr.Zero, 0, out length, IntPtr.Zero, 0);
if (length == 0) return sets;
IntPtr buffer = Marshal.AllocHGlobal((int)length);
try {
if (!GetSystemCpuSetInformation(buffer, length, out length, IntPtr.Zero, 0)) return sets;
int at = 0;
while (at + 20 <= (int)length) {
int size = Marshal.ReadInt32(buffer, at);
if (size <= 0) break;
if (Marshal.ReadInt32(buffer, at + 4) == 0) { // CpuSetInformation
sets.Add(new uint[] {
(uint)Marshal.ReadInt32(buffer, at + 8),
(uint)(ushort)Marshal.ReadInt16(buffer, at + 12),
Marshal.ReadByte(buffer, at + 14),
Marshal.ReadByte(buffer, at + 15),
Marshal.ReadByte(buffer, at + 18) });
}
at += size;
}
} finally { Marshal.FreeHGlobal(buffer); }
return sets;
}
// The process's threads that choose no CPU sets of their own run on these (a preference the scheduler keeps
// while any of them is free; the layer's own frame threads keep the sets they chose).
public static string PreferCpuSets(int pid, uint[] ids) {
IntPtr process = OpenProcess(0x2000 | 0x1000, false, pid); // SET_LIMITED_INFORMATION | QUERY_LIMITED_INFORMATION
if (process == IntPtr.Zero) return "could not open it (error " + Marshal.GetLastWin32Error() + ")";
try {
if (SetProcessDefaultCpuSets(process, ids, (uint)ids.Length)) return "ok";
return "refused (error " + Marshal.GetLastWin32Error() + ")";
} finally { CloseHandle(process); }
}
[StructLayout(LayoutKind.Sequential)] public struct RECT { public int Left, Top, Right, Bottom; }
[StructLayout(LayoutKind.Sequential)] public struct MONITORINFO { public int cbSize; public RECT rcMonitor, rcWork; public uint dwFlags; }
[DllImport("user32.dll")] public static extern bool SetProcessDPIAware();
[DllImport("user32.dll")] static extern IntPtr MonitorFromWindow(IntPtr window, uint flags);
[DllImport("user32.dll")] static extern bool GetMonitorInfo(IntPtr monitor, ref MONITORINFO info);
[DllImport("user32.dll", EntryPoint = "SetWindowLongPtrW")] static extern IntPtr SetWindowLongPtr(IntPtr window, int index, IntPtr value);
[DllImport("user32.dll")] static extern bool SetWindowPos(IntPtr window, IntPtr after, int x, int y, int cx, int cy, uint flags);
[DllImport("user32.dll")] static extern bool SetForegroundWindow(IntPtr window);
// The window borderless and the size of its monitor (scripts\fullscreen.ps1 does the same once).
public static string Borderless(IntPtr window) {
IntPtr monitor = MonitorFromWindow(window, 2);
MONITORINFO info = new MONITORINFO();
info.cbSize = Marshal.SizeOf(info);
if (!GetMonitorInfo(monitor, ref info)) return "no monitor";
RECT r = info.rcMonitor;
SetWindowLongPtr(window, -16, new IntPtr(0x90000000L)); // WS_POPUP | WS_VISIBLE
SetWindowPos(window, IntPtr.Zero, r.Left, r.Top, r.Right - r.Left, r.Bottom - r.Top, 0x0060); // FRAMECHANGED | SHOWWINDOW
SetForegroundWindow(window);
return (r.Right - r.Left) + "x" + (r.Bottom - r.Top);
}
}
'@
[void][RigNative]::SetProcessDPIAware()
function Write-Line([string]$tag, [string]$text) {
$color = switch ($tag) { 'OK' { 'Green' } 'WARN' { 'Yellow' } 'FIX' { 'Red' } default { 'Gray' } }
Write-Host (' [{0,-4}] ' -f $tag) -ForegroundColor $color -NoNewline
Write-Host $text
}
function Read-YesNo([string]$question, [bool]$default) {
if (-not $interactive) { return $default }
$hint = if ($default) { '[Y/n]' } else { '[y/N]' }
$answer = Read-Host "$question $hint"
if ([string]::IsNullOrWhiteSpace($answer)) { return $default }
return $answer.Trim().ToLowerInvariant().StartsWith('y')
}
function Read-State {
if (Test-Path -LiteralPath $stateFile) {
try { return Get-Content -LiteralPath $stateFile -Raw | ConvertFrom-Json } catch { }
}
return [pscustomobject]@{}
}
function Save-State($state) {
$state | ConvertTo-Json -Depth 4 | Set-Content -LiteralPath $stateFile -Encoding UTF8
}
function Set-StateValue($state, [string]$name, $value) {
if ($state.PSObject.Properties[$name]) { $state.$name = $value } else { $state | Add-Member -NotePropertyName $name -NotePropertyValue $value }
}
# ---------------------------------------------------------------------------------------------------------------
# The PC
# ---------------------------------------------------------------------------------------------------------------
function Get-Rig([string]$gameExe, [string]$victoryExe) {
$os = Get-CimInstance Win32_OperatingSystem
$cpu = Get-CimInstance Win32_Processor | Select-Object -First 1
$build = [Environment]::OSVersion.Version.Build
# Fast and slow cores, as the layer sees them (crates\victory-gpu\src\cores.rs reads the same efficiency classes).
$sets = @([RigNative]::CpuSets() | Where-Object { $_[1] -eq 0 })
$best = ($sets | ForEach-Object { $_[4] } | Measure-Object -Maximum).Maximum
$fast = @($sets | Where-Object { $_[4] -eq $best })
$slow = @($sets | Where-Object { $_[4] -ne $best })
$hybrid = $slow.Count -gt 0
# The card: nvidia-smi where there is one, else what Windows says.
$gpu = [pscustomobject]@{ Name = ''; VramMB = 0; Driver = ''; Nvidia = $false; Refresh = 0; Width = 0; Height = 0 }
$smi = Get-Command nvidia-smi -ErrorAction SilentlyContinue
if ($smi) {
$row = & $smi.Source --query-gpu=name,memory.total,driver_version --format=csv,noheader,nounits 2>$null | Select-Object -First 1
if ($row -match '^\s*(.+?),\s*(\d+),\s*([\d.]+)\s*$') {
$gpu.Name = $Matches[1]; $gpu.VramMB = [int]$Matches[2]; $gpu.Driver = $Matches[3]; $gpu.Nvidia = $true
}
}
$controllers = @(Get-CimInstance Win32_VideoController)
$shown = $controllers | Where-Object { $_.CurrentVerticalResolution } | Sort-Object CurrentVerticalResolution -Descending | Select-Object -First 1
if ($shown) { $gpu.Width = [int]$shown.CurrentHorizontalResolution; $gpu.Height = [int]$shown.CurrentVerticalResolution; $gpu.Refresh = [int]$shown.CurrentRefreshRate }
if (-not $gpu.Name) {
$card = $controllers | Where-Object { $_.Name -match 'NVIDIA|AMD|Radeon|Arc' } | Select-Object -First 1
if (-not $card) { $card = $controllers | Select-Object -First 1 }
if ($card) {
$gpu.Name = $card.Name; $gpu.Driver = $card.DriverVersion; $gpu.Nvidia = $card.Name -match 'NVIDIA'
# Win32_VideoController stops at 4 GB; the driver's own key does not.
$key = 'HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}'
Get-ChildItem $key -ErrorAction SilentlyContinue | ForEach-Object {
$p = Get-ItemProperty $_.PSPath -ErrorAction SilentlyContinue
if ($p.DriverDesc -eq $card.Name -and $p.'HardwareInformation.qwMemorySize') { $gpu.VramMB = [int]([int64]$p.'HardwareInformation.qwMemorySize' / 1MB) }
}
}
}
$generation = if ($gpu.Name -match 'RTX\s*(\d{2})\d{2}') { [int]$Matches[1] } else { 0 }
$hags = (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\GraphicsDrivers' -Name HwSchMode -ErrorAction SilentlyContinue).HwSchMode -eq 2
$sticks = @(Get-CimInstance Win32_PhysicalMemory)
$ramSpeed = ($sticks | ForEach-Object { if ($_.ConfiguredClockSpeed) { $_.ConfiguredClockSpeed } else { $_.Speed } } | Measure-Object -Minimum).Minimum
# The speed the sticks are sold at, where the part number says it (CMK32GX5M2B5600C36: 5600).
$rated = 0
foreach ($s in $sticks) {
foreach ($m in [regex]::Matches([string]$s.PartNumber, '\d{4}')) { $v = [int]$m.Value; if ($v -ge 2133 -and $v -le 9600 -and $v -gt $rated) { $rated = $v } }
}
$pagefiles = @(Get-CimInstance Win32_PageFileUsage -ErrorAction SilentlyContinue)
$autoPage = (Get-CimInstance Win32_ComputerSystem).AutomaticManagedPagefile
$plan = ''
$planLine = powercfg /getactivescheme 2>$null
if ($planLine -match '\(([^)]+)\)\s*$') { $plan = $Matches[1] }
$disk = $null
if ($gameExe) {
try {
$letter = (Split-Path -Qualifier $gameExe).TrimEnd(':')
$part = Get-Partition -DriveLetter $letter -ErrorAction Stop
$d = Get-Disk -Number $part.DiskNumber -ErrorAction Stop
$pd = Get-PhysicalDisk -ErrorAction SilentlyContinue | Where-Object { $_.DeviceId -eq [string]$d.Number } | Select-Object -First 1
$disk = [pscustomobject]@{ Letter = $letter; Bus = [string]$d.BusType; Media = if ($pd) { [string]$pd.MediaType } else { '' }; Name = $d.FriendlyName }
} catch { }
}
$agility = $null
if ($victoryExe) {
$core = Join-Path (Split-Path $victoryExe -Parent) 'D3D12\D3D12Core.dll'
if (Test-Path -LiteralPath $core) { $agility = (Get-Item -LiteralPath $core).VersionInfo.FileVersion }
}
[pscustomobject]@{
CpuName = ($cpu.Name -replace '\s+', ' ').Trim()
Logical = $sets.Count
FastIds = [uint32[]]@($fast | ForEach-Object { $_[0] })
FastLogical = $fast.Count
FastCores = @($fast | ForEach-Object { $_[3] } | Sort-Object -Unique).Count
SlowLogical = $slow.Count
SlowCores = @($slow | ForEach-Object { $_[3] } | Sort-Object -Unique).Count
Hybrid = $hybrid
Gpu = $gpu
RtxGeneration = $generation
Hags = $hags
RamGB = [math]::Round($os.TotalVisibleMemorySize / 1MB, 1)
RamSpeed = $ramSpeed
RamRated = $rated
CommitLimitGB = [math]::Round($os.TotalVirtualMemorySize / 1MB, 1)
CommitFreeGB = [math]::Round($os.FreeVirtualMemory / 1MB, 1)
PageFiles = $pagefiles
PageAuto = $autoPage
Build = $build
Windows10 = $build -lt 22000
Agility = $agility
Plan = $plan
Disk = $disk
}
}
# Every victory.exe, what it is (game: `play` / `run`; preload; warm: a pipeline worker or a warm run; other)
# and whether it was left behind: a game without a window, or a preload or warm process whose parent is gone.
function Get-VictoryProcesses {
$all = @(Get-CimInstance Win32_Process -Filter "Name='victory.exe'" -ErrorAction SilentlyContinue)
$alive = @{}; foreach ($p in Get-Process -ErrorAction SilentlyContinue) { $alive[[int]$p.Id] = $p }
foreach ($w in $all) {
$cmd = [string]$w.CommandLine
$kind = if ($cmd -match '\spreload(\s|$)') { 'preload' } elseif ($cmd -match '\swarm(\s|$)') { 'warm' } elseif ($cmd -match '\s(play|run)(\s|$)') { 'game' } else { 'other' }
$proc = $alive[[int]$w.ProcessId]
$window = $proc -and $proc.MainWindowHandle -ne [IntPtr]::Zero
# A parent id can be reused after the parent ended: it only counts if that process started before this one.
$parent = $alive[[int]$w.ParentProcessId]
$parentAlive = $false
if ($parent -and $proc) { try { $parentAlive = $parent.StartTime -le $proc.StartTime } catch { $parentAlive = $true } }
$leftBehind = switch ($kind) { 'game' { -not $window } { $_ -in 'preload', 'warm' } { -not $parentAlive } default { $false } }
$state = if ($kind -eq 'game') { if ($window) { 'with a window' } else { 'no window (left behind)' } }
elseif ($kind -in 'preload', 'warm') { if ($parentAlive) { 'its parent is still running' } else { 'its parent is gone (left behind)' } }
else { 'not started by the launcher' }
[pscustomobject]@{ Id = [int]$w.ProcessId; Kind = $kind; CommitGB = if ($proc) { $proc.PrivateMemorySize64 / 1GB } else { 0 }; State = $state; LeftBehind = [bool]$leftBehind }
}
}
function Show-Rig($rig) {
Write-Host ''
Write-Host 'This PC' -ForegroundColor Cyan
$cores = if ($rig.Hybrid) {
"{0} fast cores ({1} threads) + {2} slow cores ({3} threads)" -f $rig.FastCores, $rig.FastLogical, $rig.SlowCores, $rig.SlowLogical
} else { "{0} threads, all alike" -f $rig.Logical }
Write-Host (" CPU {0}: {1}" -f $rig.CpuName, $cores)
$vram = if ($rig.Gpu.VramMB) { '{0:N0} GB' -f ($rig.Gpu.VramMB / 1024) } else { 'memory unknown' }
Write-Host (" GPU {0}, {1}, driver {2}" -f $rig.Gpu.Name, $vram, $rig.Gpu.Driver)
$rated = if ($rig.RamRated -gt $rig.RamSpeed) { " (sticks rated {0})" -f $rig.RamRated } else { '' }
Write-Host (" RAM {0} GB at {1} MT/s{2}" -f [math]::Round($rig.RamGB), $rig.RamSpeed, $rated)
$pf = if ($rig.PageAuto) { 'page file managed by Windows' } elseif ($rig.PageFiles.Count) { 'page file ' + (($rig.PageFiles | ForEach-Object { '{0} {1:N0} GB' -f $_.Name, ($_.AllocatedBaseSize / 1024) }) -join ', ') } else { 'no page file' }
Write-Host (" Commit {0:N1} GB free of {1:N1} GB ({2})" -f $rig.CommitFreeGB, $rig.CommitLimitGB, $pf)
if ($rig.Disk) { Write-Host (" Disk game on {0}: {1} {2} ({3})" -f $rig.Disk.Letter, $rig.Disk.Bus, $rig.Disk.Media, $rig.Disk.Name) }
$win = if ($rig.Windows10) { "Windows 10 build $($rig.Build)" } else { "Windows 11 build $($rig.Build)" }
if ($rig.Windows10) { $win += if ($rig.Agility) { ", D3D12 Agility runtime beside victory.exe ($($rig.Agility))" } else { ', no D3D12 Agility runtime beside victory.exe yet' } }
Write-Host (" Windows {0}" -f $win)
Write-Host (" Display {0}x{1} at {2} Hz; GPU scheduling {3}; power plan {4}" -f $rig.Gpu.Width, $rig.Gpu.Height, $rig.Gpu.Refresh, $(if ($rig.Hags) { 'on' } else { 'off' }), $rig.Plan)
}
# ---------------------------------------------------------------------------------------------------------------
# Checks
# ---------------------------------------------------------------------------------------------------------------
function Test-Rig($rig, [string]$victoryExe) {
Write-Host ''
Write-Host 'Checks' -ForegroundColor Cyan
# A game process left behind (the F1 menu's SAVE AND RESTART can leave one without a window) holds its memory.
# So can the shader preload's pipeline workers (`victory warm`) when their parent was closed or killed. Only
# those left behind are offered to be ended: a game with its window, or a preload or warm run whose parent
# is still there (started by hand, or by a build or test elsewhere), is someone's work in progress.
$left = @(Get-VictoryProcesses)
if ($left.Count) {
foreach ($v in $left) {
$tag = if ($v.LeftBehind) { 'FIX' } else { 'WARN' }
Write-Line $tag ("victory.exe already running: pid {0}, {1}, {2:N1} GB committed, {3}" -f $v.Id, $v.Kind, $v.CommitGB, $v.State)
}
$stale = @($left | Where-Object LeftBehind)
if ($stale.Count -and (Read-YesNo (" End the {0} left behind (and anything they started)? Their memory counts against this run." -f $stale.Count) $false)) {
foreach ($v in $stale) { & taskkill.exe /PID $v.Id /T /F 2>&1 | Out-Null }
Start-Sleep -Seconds 2
$os = Get-CimInstance Win32_OperatingSystem
$rig.CommitFreeGB = [math]::Round($os.FreeVirtualMemory / 1MB, 1)
Write-Line 'OK' ("ended; commit free now {0:N1} GB" -f $rig.CommitFreeGB)
}
if (@($left | Where-Object { -not $_.LeftBehind }).Count) {
Write-Host ' The others look like work in progress (a running game, or a preload or warm run whose parent is'
Write-Host ' still there); close them yourself if they are yours and not needed.'
}
} else {
Write-Line 'OK' 'no victory.exe left running'
}
# Room to commit memory: what ended a run on this PC (E_OUTOFMEMORY, "no shared buffer").
if ($rig.CommitFreeGB -ge $CommitComfortGB) {
Write-Line 'OK' ("{0:N1} GB of commit free (the game wants about {1} GB)" -f $rig.CommitFreeGB, $CommitComfortGB)
} else {
$tag = if ($rig.CommitFreeGB -lt $CommitTightGB) { 'FIX' } else { 'WARN' }
Write-Line $tag ("only {0:N1} GB of commit free of {1:N1} GB; the game wants about {2} GB. Runs ended with E_OUTOFMEMORY" -f $rig.CommitFreeGB, $rig.CommitLimitGB, $CommitComfortGB)
Write-Host ' ("no shared buffer") when it ran out. What holds the most now:'
Get-Process | Group-Object Name | ForEach-Object {
[pscustomobject]@{ Name = $_.Name; GB = ($_.Group | Measure-Object PrivateMemorySize64 -Sum).Sum / 1GB; Count = $_.Count }
} | Sort-Object GB -Descending | Select-Object -First 6 | ForEach-Object {
Write-Host (" {0,-22} {1,5:N1} GB{2}" -f $_.Name, $_.GB, $(if ($_.Count -gt 1) { " ($($_.Count) processes)" } else { '' }))
}
Write-Host ' Closing browsers and chat apps before playing gives it back. This launcher also'
Write-Host ' makes fewer pipelines at a time (VICTORY_PIPELINE_WORKERS) while room is short.'
}
$wantLimit = $rig.RamGB + 32
if ($rig.CommitLimitGB -lt $wantLimit) {
Write-Line 'WARN' ("the commit limit is {0:N1} GB (RAM + page file). A page file that lets it reach {1:N0} GB or more" -f $rig.CommitLimitGB, $wantLimit)
Write-Host ' keeps the game from running out (docs/windows-memory.md): sysdm.cpl > Advanced > Performance'
Write-Host ' Settings > Advanced > Virtual memory > Change: "System managed size" on the NVMe drive, or a'
Write-Host (" custom size of at least {0:N0} MB, then restart Windows." -f (($wantLimit - $rig.RamGB) * 1024))
}
# The card.
if (-not $rig.Gpu.Nvidia) {
Write-Line 'WARN' "$($rig.Gpu.Name): not an NVIDIA card; DLSS is left off (README: FSR 3 on the Series S profile)"
} elseif ($rig.RtxGeneration -ge 40) {
if ($rig.Hags) { Write-Line 'OK' ("RTX {0}: DLSS and DLSS frame generation; GPU scheduling is on, as frame generation needs" -f $rig.RtxGeneration) }
else { Write-Line 'FIX' 'GPU scheduling is off: DLSS frame generation needs it (Settings > Display > Graphics settings > Hardware-accelerated GPU scheduling, then restart)' }
} elseif ($rig.RtxGeneration -ge 20) {
Write-Line 'OK' ("RTX {0}: DLSS; frame generation only through FSR 3 or the MFG Unlocker mod (README)" -f $rig.RtxGeneration)
}
# Windows 10's own Direct3D 12 stops at shader model 6.5; victory.exe offers Microsoft's newer one when it is missing.
if ($rig.Windows10) {
if ($rig.Agility) { Write-Line 'OK' "Windows 10: Microsoft's D3D12 Agility runtime is beside victory.exe ($($rig.Agility)), for shader model 6.6" }
else { Write-Line 'WARN' "Windows 10 without D3D12\D3D12Core.dll beside victory.exe: victory.exe will offer to fetch it (victory.exe get-d3d12)" }
}
# The disk: the title streams from it all the time.
if ($rig.Disk) {
if ($rig.Disk.Bus -eq 'NVMe') { Write-Line 'OK' ("the game is on an NVMe drive ({0}:)" -f $rig.Disk.Letter) }
elseif ($rig.Disk.Media -eq 'HDD') { Write-Line 'FIX' ("the game is on a hard disk ({0}:): streaming will stall; move it to an SSD, NVMe best" -f $rig.Disk.Letter) }
else { Write-Line 'WARN' ("the game is on a {0} drive ({1}:); an NVMe drive streams faster" -f $rig.Disk.Bus, $rig.Disk.Letter) }
}
# Memory speed: the layer leans on the CPU and its memory more than on the card.
if ($rig.RamRated -gt $rig.RamSpeed + 200) {
Write-Line 'WARN' ("RAM runs at {0} MT/s, the sticks are rated {1}: turning on XMP/EXPO in the BIOS speeds up the CPU-bound layer" -f $rig.RamSpeed, $rig.RamRated)
}
if ($rig.Plan -and $rig.Plan -match 'saver|Energiebesparing|Economie') {
Write-Line 'WARN' "power plan '$($rig.Plan)': the CPU is held back; High performance or Balanced is better"
}
if ($rig.Hybrid -and $rig.Windows10) {
Write-Line 'INFO' ("Windows 10 places threads on fast and slow cores without Intel's Thread Director. The layer keeps its own frame threads on the {0} fast" -f $rig.FastLogical)
Write-Host ' threads already; -Cores pcores asks the same for the title''s threads (compare runs with -Summary).'
}
}
# ---------------------------------------------------------------------------------------------------------------
# Settings for this PC
# ---------------------------------------------------------------------------------------------------------------
function Get-RigSettings($rig) {
$o = [ordered]@{ Console = 'series-x'; Res = '1440'; Dlss = 'quality'; FrameGen = 0; Fps = 1000 }
$switchSet = [ordered]@{} # (not $set: names are not case-sensitive, and -Set is the script's parameter)
$why = New-Object System.Collections.Generic.List[string]
if ($SeriesS) { $o.Console = 'series-s' }
# The picture: native 1440p where the monitor has the lines for it.
if ($Res -ne 'auto') { $o.Res = $Res }
elseif ($rig.Gpu.Height -ge 1440 -or $rig.Gpu.Height -eq 0) { $o.Res = '1440' }
else { $o.Res = '1080to1440'; $why.Add("res 1080to1440: the monitor has $($rig.Gpu.Height) lines") }
if ($o.Console -eq 'series-x' -and $o.Res -eq '1440') { $why.Add("Series X at a native 2560x1440: the monitor is $($rig.Gpu.Width)x$($rig.Gpu.Height)") }
# DLSS: on any RTX card; Quality, as tested. The card is rarely the limit on this layer (the run's log: about
# 9 % busy while the CPU side worked), so -Dlss dlaa is the picture to try next.
if ($Dlss -ne 'auto') { $o.Dlss = $Dlss }
elseif ($rig.Gpu.Nvidia -and $rig.RtxGeneration -ge 20) { $o.Dlss = 'quality' }
else { $o.Dlss = 'off'; $why.Add('DLSS off: no RTX card') }
# Frame generation: DLSS's on an RTX 40/50 with GPU scheduling on. 2x: what an RTX 40 does, and the least
# latency on an RTX 50. The layer is CPU-bound near 30 frames a second, so this is where smoothness comes from.
if ($NoFrameGen) { $o.FrameGen = 0 }
elseif ($FrameGen -ge 0) { $o.FrameGen = if ($FrameGen -eq 1) { 2 } else { $FrameGen } }
elseif ($o.Dlss -ne 'off' -and $rig.RtxGeneration -ge 40 -and $rig.Hags) { $o.FrameGen = 2 }
if ($o.FrameGen -ge 2) {
$why.Add(("DLSS frame generation {0}x: RTX {1} with GPU scheduling on; the layer renders near 30 fps, shown {2}" -f $o.FrameGen, $rig.RtxGeneration, $(if ($o.FrameGen -eq 2) { 'near 60' } else { 'more' })))
# The launcher keeps a fifth of the card's budget out of the texture pool for frame generation, sized for a
# 12 GB card. Frame generation itself takes about 2 GB; on a bigger card the rest can hold textures.
if ($rig.Gpu.VramMB -gt 0) {
$budget = $rig.Gpu.VramMB * 0.933 # what Windows gives as the budget (16376 MB card: 15280 MB)
$percent = [math]::Floor(100 * ($budget - $FrameGenVramMB) / $budget)
$percent = [math]::Max(80, [math]::Min(90, $percent))
if ($percent -gt 80) {
$switchSet.VICTORY_TEXTURE_ROOM_PERCENT = [string]$percent
$why.Add(("VICTORY_TEXTURE_ROOM_PERCENT=$percent : {0:N0} GB card, about {1:N1} GB kept for frame generation instead of the 12 GB card's fifth" -f ($rig.Gpu.VramMB / 1024), ((100 - $percent) * $budget / 100 / 1024)))
}
}
}
if ($Fps -gt 0) { $o.Fps = $Fps; $why.Add("frame cap $Fps") }
elseif ($rig.Gpu.Refresh -ge 100) { $why.Add("no frame cap: a $($rig.Gpu.Refresh) Hz monitor is above anything the layer renders") }
# Commit room: fewer pipelines made at a time while it is short (docs/windows-memory.md: the 32 GB reports that
# ran out did so while pipelines were being made; fxceless #777 throttles the same workers). The layer's own
# choice on a 32 GB PC is 8. A preload makes most of them before the game, so few are left to make in play.
if ($rig.CommitFreeGB -lt $CommitTightGB) {
$switchSet.VICTORY_PIPELINE_WORKERS = '2'
$why.Add(("VICTORY_PIPELINE_WORKERS=2 : only {0:N1} GB of commit free" -f $rig.CommitFreeGB))
} elseif ($rig.CommitFreeGB -lt $CommitComfortGB) {
$switchSet.VICTORY_PIPELINE_WORKERS = '4'
$why.Add(("VICTORY_PIPELINE_WORKERS=4 : {0:N1} GB of commit free, under the {1} GB the game wants" -f $rig.CommitFreeGB, $CommitComfortGB))
}
if ($Cores -eq 'pcores' -and $rig.Hybrid) {
$why.Add("-Cores pcores: the title's threads prefer the $($rig.FastLogical) fast threads too")
}
foreach ($pair in $Set) {
# Split before each further VICTORY_ name only: a value can hold commas (VICTORY_LEAVE_OUT).
foreach ($item in ($pair -split ',(?=\s*VICTORY_)')) {
if ($item -match '^\s*(VICTORY_[A-Z0-9_]+)\s*=(.*)$') { $switchSet[$Matches[1]] = $Matches[2].Trim(); $why.Add("$($Matches[1])=$($Matches[2].Trim()) : given with -Set") }
elseif ($item.Trim()) { Write-Line 'WARN' "-Set '$item' is not VICTORY_NAME=value; left out" }
}
}
[pscustomobject]@{ Options = $o; Set = $switchSet; Why = $why }
}
function Get-PlayArgs([string]$gameExe, $settings, [bool]$preload) {
$o = $settings.Options
$list = New-Object System.Collections.Generic.List[string]
foreach ($a in @('play', $gameExe, '--res', $o.Res, '--dlss', $o.Dlss, '--fg-type', 'auto', '--fps', [string]$o.Fps)) { $list.Add($a) }
if ($o.Console -eq 'series-s') { $list.Add('--series-s') }
if ($o.FrameGen -ge 2) { $list.Add('--framegen'); $list.Add([string]$o.FrameGen) }
if ($preload) { $list.Add('--preload') }
foreach ($k in $settings.Set.Keys) { $list.Add('--set'); $list.Add("$k=$($settings.Set[$k])") }
return , $list.ToArray()
}
# ---------------------------------------------------------------------------------------------------------------
# A run's log
# ---------------------------------------------------------------------------------------------------------------
function Get-RunSummary([string]$path) {
$lines = [IO.File]::ReadAllLines($path)
$header = $lines | Select-Object -First 1
$switches = @{}
foreach ($m in [regex]::Matches([string]$header, '(VICTORY_[A-Z0-9_]+)=(\S*)')) { $switches[$m.Groups[1].Value] = $m.Groups[2].Value }
$windows = New-Object System.Collections.Generic.List[double]
$first = $null; $last = $null; $minCommit = $null; $pressure = 0; $oom = 0; $errors = 0; $firstError = $null; $ended = $false
foreach ($line in $lines) {
if ($line -match '^(\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d)') {
$t = [datetime]::ParseExact($Matches[1], "yyyy-MM-dd'T'HH:mm:ss", [Globalization.CultureInfo]::InvariantCulture)
if (-not $first) { $first = $t }
$last = $t
}
if ($line -match 'frame times: (\d+) frames, median ([\d.]+) ms') {
$ms = [double]::Parse($Matches[2], [Globalization.CultureInfo]::InvariantCulture)
# Menus and loading screens draw at hundreds a second; the game's world and its cutscenes do not.
if ($ms -ge 8.0) { $windows.Add(1000.0 / $ms) }
}
if ($line -match 'available_commit_mib=(\d+)') { $v = [int]$Matches[1]; if ($null -eq $minCommit -or $v -lt $minCommit) { $minCommit = $v } }
if ($line -match 'host memory pressure') { $pressure++ }
if ($line -match '0x8007000E') { $oom++ }
if ($line -match '^\S+\s+ERROR\s') { $errors++; if (-not $firstError) { $firstError = $line } }
if ($line -match 'title suspended; ending the title|window closed: suspending the title') { $ended = $true }
}
$sorted = @($windows | Sort-Object)
$pick = { param($q) if ($sorted.Count) { $sorted[[math]::Min($sorted.Count - 1, [math]::Floor($q * $sorted.Count))] } else { $null } }
$crash = $null
if ($path -match '-(\d+)\.log$') {
$procId = $Matches[1]
foreach ($file in Get-ChildItem (Join-Path $vhome 'data\*\crashes.log') -ErrorAction SilentlyContinue) {
$text = Get-Content -LiteralPath $file.FullName
for ($i = 0; $i -lt $text.Count; $i++) {
if ($text[$i] -match "^unix time \d+, process $procId\s*$" -and $i + 1 -lt $text.Count) { $crash = $text[$i + 1] }
}
}
}
[pscustomobject]@{
Log = Split-Path $path -Leaf
Seconds = if ($first -and $last) { [int]($last - $first).TotalSeconds } else { 0 }
Console = $switches['VICTORY_MENU_CONSOLE']
Res = $switches['VICTORY_MENU_RES']
Dlss = $switches['VICTORY_MENU_DLSS']
FrameGen = $switches['VICTORY_MENU_FRAMEGEN']
Workers = $switches['VICTORY_PIPELINE_WORKERS']
Room = $switches['VICTORY_TEXTURE_ROOM_PERCENT']
GameSeconds = $sorted.Count
FpsMedian = & $pick 0.5
FpsLow = & $pick 0.05
Stalls = @($sorted | Where-Object { $_ -lt 10 }).Count
MinCommitMB = $minCommit
Pressure = $pressure
OutOfMemory = $oom
Errors = $errors
FirstError = $firstError
Ended = if ($crash -or ($oom -gt 0 -and -not $ended)) { 'crashed' } elseif ($ended) { 'closed' } else { 'unknown' }
Crash = $crash
}
}
function Show-RunSummary($s) {
Write-Host ''
Write-Host "Run: $($s.Log)" -ForegroundColor Cyan
Write-Host (" settings {0} {1}, DLSS {2}, frame generation {3}, pipeline workers {4}, texture room {5}" -f $s.Console, $s.Res, $s.Dlss, $(if ($s.FrameGen -and $s.FrameGen -ne '0') { "$($s.FrameGen)x" } else { 'off' }), $(if ($s.Workers) { $s.Workers } else { "layer's" }), $(if ($s.Room) { "$($s.Room) %" } else { "layer's" }))
Write-Host (" length {0}:{1:00}, of it {2} s in the game (not menus or loading screens)" -f [math]::Floor($s.Seconds / 60), ($s.Seconds % 60), $s.GameSeconds)
if ($s.GameSeconds) {
Write-Host (" rendered median {0:N1} fps, slowest 5 % {1:N1} fps, {2} s under 10 fps (pipelines being made or streaming)" -f $s.FpsMedian, $s.FpsLow, $s.Stalls)
}
$commit = if ($null -ne $s.MinCommitMB) { ', lowest commit free {0:N1} GB' -f ($s.MinCommitMB / 1024) } else { '' }
Write-Host (" memory {0} memory-pressure warnings, {1} out-of-memory errors{2}" -f $s.Pressure, $s.OutOfMemory, $commit)
$tag = if ($s.Ended -eq 'crashed') { 'FIX' } elseif ($s.Ended -eq 'closed') { 'OK' } else { 'WARN' }
$end = switch ($s.Ended) { 'crashed' { 'it crashed' } 'closed' { 'it was closed' } default { 'its end is not in the log' } }
Write-Line $tag $end
if ($s.Crash) { Write-Host " $($s.Crash)" }
elseif ($s.FirstError) { Write-Host (" first error: " + $s.FirstError.Substring(0, [math]::Min(200, $s.FirstError.Length))) }
if ($s.OutOfMemory -gt 0) { Write-Host ' Out of memory: close other programs and give Windows a bigger page file (the checks say how).' }
if ($s.Stalls -gt 5) { Write-Host ' Many seconds under 10 fps: a shader preload (-Preload yes) makes those pipelines ahead.' }
}
function Add-RunRow($s, [string]$cores, [hashtable]$extra) {
$gb = { param($mb) if ($null -ne $mb -and "$mb" -ne '') { [math]::Round([double]$mb / 1024, 1) } else { '' } }
$row = [ordered]@{
When = (Get-Date).ToString('yyyy-MM-dd HH:mm'); Log = $s.Log; Console = $s.Console; Res = $s.Res; Dlss = $s.Dlss
FrameGen = $s.FrameGen; Cores = $cores; Workers = $s.Workers; Room = $s.Room; GameSeconds = $s.GameSeconds
FpsMedian = if ($null -ne $s.FpsMedian) { [math]::Round($s.FpsMedian, 1) } else { '' }
FpsLow = if ($null -ne $s.FpsLow) { [math]::Round($s.FpsLow, 1) } else { '' }
Stalls = $s.Stalls; MinCommitMB = $s.MinCommitMB; OutOfMemory = $s.OutOfMemory; Ended = $s.Ended
# Added for A/B tests and the commit thresholds (rows written before have these empty).
Variant = $extra.Variant
CommitStartGB = $extra.CommitStartGB
CommitLimitGB = $extra.CommitLimitGB
MinCommitFreeGB = & $gb $extra.MinCommitFreeMB
PeakGameGB = & $gb $extra.PeakGameMB
}
# The file is written whole, so rows from before a column was added line up under the new header.
$old = if (Test-Path -LiteralPath $runsFile) { @(Import-Csv -LiteralPath $runsFile) } else { @() }
$all = @(foreach ($r in $old) {
$o = [ordered]@{}
foreach ($c in $row.Keys) { $o[$c] = if ($r.PSObject.Properties[$c]) { $r.$c } else { '' } }
[pscustomobject]$o
}) + @([pscustomobject]$row)
$all | Export-Csv -LiteralPath $runsFile -NoTypeInformation -Encoding UTF8
}
function Get-Median([double[]]$values) {
$a = @($values | Sort-Object)
if (-not $a.Count) { return $null }
if ($a.Count % 2) { return $a[($a.Count - 1) / 2] }
return ($a[$a.Count / 2 - 1] + $a[$a.Count / 2]) / 2
}
# Runs of a minute or more in the game: shorter ones (a warm-up restart, a quick look) say little about speed.
$MinGameSeconds = 60
function Get-TryVariant([string]$kind, [string[]]$options) {
$counts = @{}; foreach ($o in $options) { $counts[$o] = 0 }
if (Test-Path -LiteralPath $runsFile) {
foreach ($r in Import-Csv -LiteralPath $runsFile) {
if ($r.PSObject.Properties['Variant'] -and "$($r.Variant)" -match "^$kind=(.+)$" -and $counts.ContainsKey($Matches[1]) -and [int]("0$($r.GameSeconds)") -ge $MinGameSeconds) { $counts[$Matches[1]]++ }
}
}
$pick = $options | Sort-Object { $counts[$_] }, { [array]::IndexOf($options, $_) } | Select-Object -First 1
[pscustomobject]@{ Pick = $pick; Counts = $counts }
}
function Show-Compare {
if (-not (Test-Path -LiteralPath $runsFile)) { Write-Host "No runs recorded yet ($runsFile): play through this launcher first."; return }
$rows = @(Import-Csv -LiteralPath $runsFile)
Write-Host ''
Write-Host "Runs in $runsFile : $($rows.Count) ($(@($rows | Where-Object { [int]("0$($_.GameSeconds)") -ge $MinGameSeconds }).Count) with a minute or more in the game)" -ForegroundColor Cyan
$key = { param($r) if ($r.PSObject.Properties['Variant'] -and $r.Variant) { $r.Variant } else { "cores=$($r.Cores) room=$(if ($r.Room) { $r.Room } else { 'layer' }) workers=$(if ($r.Workers) { $r.Workers } else { 'layer' }) fg=$($r.FrameGen)" } }
$groups = $rows | Group-Object { & $key $_ }
$table = foreach ($g in $groups) {
$long = @($g.Group | Where-Object { [int]("0$($_.GameSeconds)") -ge $MinGameSeconds -and "$($_.FpsMedian)" -ne '' })
$secs = 0; $stalls = 0
foreach ($r in $long) { $secs += [int]$r.GameSeconds; $stalls += [int]("0$($r.Stalls)") }
[pscustomobject]@{
Settings = $g.Name
Runs = $long.Count
'Fps median' = if ($long.Count) { '{0:N1}' -f (Get-Median ($long | ForEach-Object { [double]$_.FpsMedian })) } else { '-' }
'Fps low 5%' = if ($long.Count) { '{0:N1}' -f (Get-Median ($long | ForEach-Object { [double]$_.FpsLow })) } else { '-' }
'Stalls/min' = if ($secs) { '{0:N2}' -f (60.0 * $stalls / $secs) } else { '-' }
Crashes = @($g.Group | Where-Object { $_.Ended -eq 'crashed' }).Count
}
}
$table | Format-Table -AutoSize | Out-String | Write-Host
# The A/B pairs: a verdict only with three runs of each, and a difference larger than run-to-run noise.
foreach ($kind in 'cores', 'room') {
# Only rows an A/B start tagged ("cores=pcores"), not the settings key of untagged runs.
$pair = @($table | Where-Object { $_.Settings -match "^$kind=\S+$" })
if ($pair.Count -lt 2) { if ($pair.Count) { Write-Host " -Try ${kind}: only $($pair[0].Settings) so far; the next -Try $kind start takes the other." }; continue }
$few = @($pair | Where-Object { $_.Runs -lt 3 })
if ($few.Count) { Write-Host (" -Try {0}: not enough runs yet ({1}); three of a minute or more each, in the same part of the game." -f $kind, (($pair | ForEach-Object { "$($_.Settings): $($_.Runs)" }) -join ', ')); continue }
$a = $pair[0]; $b = $pair[1]
$diff = 100.0 * ([double]$b.'Fps median' - [double]$a.'Fps median') / [double]$a.'Fps median'
if ([math]::Abs($diff) -lt 3) { Write-Host (" -Try {0}: {1} vs {2}: {3:+0.0;-0.0} % median fps, inside run-to-run noise: no clear winner (compare slow 5 % and stalls too)." -f $kind, $b.Settings, $a.Settings, $diff) }
else { Write-Host (" -Try {0}: {1} vs {2}: {3:+0.0;-0.0} % median fps." -f $kind, $b.Settings, $a.Settings, $diff) }
}
# What the runs used of Windows' commit: the launcher's thresholds (want $CommitComfortGB GB free, fewer workers under
# $CommitTightGB) came from one crashed run; these replace guesswork once there are a few runs.
$mem = @($rows | Where-Object { $_.PSObject.Properties['CommitStartGB'] -and "$($_.CommitStartGB)" -ne '' -and "$($_.MinCommitFreeGB)" -ne '' })
if ($mem.Count) {
$used = @($mem | ForEach-Object { [double]$_.CommitStartGB - [double]$_.MinCommitFreeGB })
$peak = ($used | Measure-Object -Maximum).Maximum
$low = ($mem | ForEach-Object { [double]$_.MinCommitFreeGB } | Measure-Object -Minimum).Minimum
Write-Host (" Memory: the game took up to {0:N1} GB of commit in {1} run(s) (median {2:N1}); the least left free was {3:N1} GB." -f $peak, $mem.Count, (Get-Median $used), $low)
Write-Host (" The launcher wants {0} GB free; from these runs {1} GB would be enough (the most used plus 15 %)." -f $CommitComfortGB, [math]::Ceiling($peak * 1.15))
if ($mem.Count -lt 3) { Write-Host ' (Fewer than three runs: keep the current threshold until there are more.)' }
} else {
Write-Host ' Memory: no runs with commit measurements yet (they are recorded from now on).'
}
}
# What the preload has finished so far, by victory.exe's own list (one line per pipeline made).
function Get-PreloadDoneCount {
$cache = if ($env:VICTORY_CACHE_DIR) { $env:VICTORY_CACHE_DIR } else { Join-Path $vhome 'cache' }
$file = Join-Path $cache 'pipelines\warm-done.txt'
if (-not (Test-Path -LiteralPath $file)) { return 0 }
$n = 0
foreach ($l in [IO.File]::ReadLines($file)) { if ($l.Trim()) { $n++ } }
return $n
}
function Read-PreloadChoice([string]$question) {
if (-not $interactive) { return 'yes' }
$answer = [string](Read-Host "$question [Y]es / [n]o, not this time / [s]kip for this version")
switch -regex ($answer.Trim().ToLowerInvariant()) { '^n' { 'no' } '^s' { 'skip' } default { 'yes' } }
}
# ---------------------------------------------------------------------------------------------------------------
# -Summary: no start
# ---------------------------------------------------------------------------------------------------------------
if ($Summary) {
$path = if ($Log) { $Log } else { Get-ChildItem (Join-Path $vhome 'logs') -Filter 'victory-nvidia*.log' -ErrorAction SilentlyContinue | Sort-Object LastWriteTime | Select-Object -Last 1 -ExpandProperty FullName }
if (-not $path) { Write-Host "No run logs in $(Join-Path $vhome 'logs')."; return }
Show-RunSummary (Get-RunSummary $path)
if (Test-Path -LiteralPath $runsFile) { Write-Host ''; Write-Host "Earlier runs: $runsFile (-Compare compares them)" }
return
}
if ($Compare) { Show-Compare; return }
# ---------------------------------------------------------------------------------------------------------------
# The title and victory.exe
# ---------------------------------------------------------------------------------------------------------------
$state = Read-State
$game = $null
$candidates = @()
if ($Exe) { $candidates += $Exe }
if ($env:VICTORY_GAME_DIR) { $candidates += (Join-Path $env:VICTORY_GAME_DIR 'game_scarlett_master.exe') }
if ($state.PSObject.Properties['exe']) { $candidates += $state.exe }
$toml = Join-Path $repo 'victory.toml'
if ((Test-Path -LiteralPath $toml) -and ((Get-Content -LiteralPath $toml -Raw) -match "(?m)^\s*game_dir\s*=\s*['""]([^'""]+)['""]")) { $candidates += (Join-Path $Matches[1] 'game_scarlett_master.exe') }
foreach ($c in $candidates) {
if ($c -and (Test-Path -LiteralPath $c -PathType Container)) { $c = Join-Path $c 'game_scarlett_master.exe' }
if ($c -and (Test-Path -LiteralPath $c -PathType Leaf)) { $game = (Resolve-Path -LiteralPath $c).Path; break }
}
if (-not $game -and $interactive) {
$typed = (Read-Host 'Path to your own dump''s game_scarlett_master.exe (or its folder)').Trim('"', ' ')
if ($typed -and (Test-Path -LiteralPath $typed -PathType Container)) { $typed = Join-Path $typed 'game_scarlett_master.exe' }
if ($typed -and (Test-Path -LiteralPath $typed -PathType Leaf)) { $game = (Resolve-Path -LiteralPath $typed).Path }
}
if (-not $game) { Write-Host 'No game_scarlett_master.exe: give it with -Exe (it is remembered), or set VICTORY_GAME_DIR.'; exit 2 }
$runner = $null
foreach ($c in @($Victory, $(if ($state.PSObject.Properties['victory']) { $state.victory }), (Join-Path (Split-Path $game -Parent) 'victory.exe'), (Join-Path $repo 'target\release\victory.exe'))) {
if ($c -and (Test-Path -LiteralPath $c -PathType Leaf)) { $runner = (Resolve-Path -LiteralPath $c).Path; break }
}
if (-not $runner) { Write-Host "No victory.exe: put the release's victory.exe beside $game, or build it (cargo build --release --locked -p victory)."; exit 2 }
Set-StateValue $state 'exe' $game
Set-StateValue $state 'victory' $runner
$rig = Get-Rig $game $runner
Show-Rig $rig
Write-Host ''
Write-Host " Game $game"
Write-Host " Runner $runner"
Test-Rig $rig $runner
# An A/B test: the variant with the fewer long runs so far.
$variant = ''
if ($Try -eq 'cores') {
if ($rig.Hybrid) {
$t = Get-TryVariant 'cores' @('layer', 'pcores')
$Cores = $t.Pick; $variant = "cores=$Cores"
} else { Write-Line 'WARN' '-Try cores: this CPU has one kind of core; nothing to compare' }
}
$settings = Get-RigSettings $rig
if ($Try -eq 'room') {
$ours = $settings.Set['VICTORY_TEXTURE_ROOM_PERCENT']
if ($settings.Options.FrameGen -ge 2 -and $ours) {
$t = Get-TryVariant 'room' @('80', [string]$ours)
$settings.Set['VICTORY_TEXTURE_ROOM_PERCENT'] = $t.Pick; $variant = "room=$($t.Pick)"
} else { Write-Line 'WARN' '-Try room: needs frame generation on and a card with more than 12 GB; nothing to compare' }
}
if ($variant) {
$settings.Why.Add(("A/B test {0} this start (long runs so far: {1}); play the same part of the game as in the other runs" -f $variant, (($t.Counts.GetEnumerator() | Sort-Object Name | ForEach-Object { "$($_.Name) $($_.Value)" }) -join ', ')))
}
# A preload for each victory.exe (its bytes) and graphics driver: both change what the pipelines are.
$hash = (Get-FileHash -LiteralPath $runner -Algorithm SHA256).Hash.Substring(0, 16)
$preloadKey = "$hash|$($rig.Gpu.Driver)"
$done = $state.PSObject.Properties['preloaded'] -and $state.preloaded -eq $preloadKey
$skipped = $state.PSObject.Properties['preloadSkip'] -and $state.preloadSkip -eq $preloadKey
$doPreload = switch ($Preload) { 'yes' { $true } 'no' { $false } default { -not $done -and -not $skipped } }
$builtBefore = Get-PreloadDoneCount
Write-Host ''
Write-Host 'Settings for this PC' -ForegroundColor Cyan
foreach ($w in $settings.Why) { Write-Host " - $w" }
if ($Preload -eq 'auto') {
if ($done) { Write-Host ' - shaders already preloaded for this victory.exe and driver' }
elseif ($skipped) { Write-Host ' - shader preload skipped for this victory.exe and driver, as you chose (-Preload yes runs it)' }
elseif ($builtBefore) { Write-Host (" - shader preload: partly done ({0:N0} pipelines built so far); it goes on from there" -f $builtBefore) }
else { Write-Host " - shader preload: not done yet for this victory.exe and driver $($rig.Gpu.Driver) (the last run sat at 2-3 fps while the world's pipelines were made)" }
}
if (-not $NoFullscreen) { Write-Host ' - borderless full screen at the monitor''s size once frames are being shown (15 s after the first; the layer fits a window inside the screen, scaling the picture)' }
$playArgs = Get-PlayArgs $game $settings $doPreload
Write-Host ''
Write-Host 'Command' -ForegroundColor Cyan
Write-Host (" & '{0}' {1}" -f $runner, (($playArgs | ForEach-Object { if ($_ -match '[\s'']') { "'" + ($_ -replace "'", "''") + "'" } else { $_ } }) -join ' '))
Write-Host ' (What the F1 menu saved in victory-settings.txt still goes over these options, as at every start.)'
if ($Check) { Save-State $state; return }
if ($Preload -eq 'auto' -and $doPreload) {
$choice = Read-PreloadChoice 'Preload shaders before the game starts? A while (more on a first time); what is done is kept.'
if ($choice -ne 'yes') { $doPreload = $false; $playArgs = Get-PlayArgs $game $settings $false }
if ($choice -eq 'skip') {
Set-StateValue $state 'preloadSkip' $preloadKey
Write-Host ' Not asked again for this victory.exe and driver; -Preload yes runs it.'
}
}
if ($rig.CommitFreeGB -lt $CommitTightGB -and -not (Read-YesNo 'Commit room is short and the game may run out of memory. Start anyway?' $true)) { Save-State $state; return }
Save-State $state
# ---------------------------------------------------------------------------------------------------------------
# While it runs: the window, and the title's threads on the fast cores
# ---------------------------------------------------------------------------------------------------------------
$sync = [hashtable]::Synchronized(@{ Stop = $false; Notes = [System.Collections.ArrayList]::Synchronized((New-Object System.Collections.ArrayList))
PreloadExit = $null; MinCommitMB = $null; PeakGameMB = 0 })
$pin = if ($Cores -eq 'pcores' -and $rig.Hybrid) { $rig.FastIds } else { $null }
# (Not $watch: names are not case-sensitive, and -Watch is the script's switch; assigned to it, this
# script block became the word False.)
$watchScript = {
param($RunnerPath, $PinIds, $MakeBorderless, $Sync, $LogsDir, $SettleSeconds)
$seen = @{}
$tick = 0
while (-not $Sync.Stop) {
$gameMB = 0; $games = 0
foreach ($p in @(Get-Process victory -ErrorAction SilentlyContinue)) {
$path = $null
try { $path = $p.Path } catch { }
if ($path -ne $RunnerPath) { continue }
$st = $seen[$p.Id]
if (-not $st) {
$cmd = [string](Get-CimInstance Win32_Process -Filter "ProcessId=$($p.Id)" -ErrorAction SilentlyContinue).CommandLine
# preload: `victory preload`; warm: its pipeline workers; game: `play` or `run`.
$kind = if ($cmd -match '\spreload\s') { 'preload' } elseif ($cmd -match '\swarm(\s|$)') { 'warm' } else { 'game' }
$st = @{ Kind = $kind; Proc = $null; Reported = $false; Pinned = $false; Window = [IntPtr]::Zero; WindowAt = $null; FramesAt = $null; Done = $false }
# The preload's own process is held, so that its exit code can be read once it ends: 0 when every
# step ran to the end, anything else when it stopped early (closed, killed, failed).
if ($kind -eq 'preload') { $st.Proc = $p; try { [void]$p.Handle } catch { } }
$seen[$p.Id] = $st
}
if ($st.Kind -ne 'game') { continue } # the shader preload and its workers: every core is welcome
$games++
try { $gameMB += $p.PrivateMemorySize64 / 1MB } catch { }
if ($PinIds -and -not $st.Pinned) {
$r = [RigNative]::PreferCpuSets($p.Id, [uint32[]]$PinIds)
$st.Pinned = $true
[void]$Sync.Notes.Add("pid $($p.Id): the title's threads prefer the fast cores: $r")
}
# Not while the title starts: a style and size change 3 s after the window appeared froze a start in
# its DirectStorage set-up (2026-11-28; the log stopped there, Windows closed it as hung). Only once
# this process's log shows frames being presented, and some seconds after that.
if ($MakeBorderless -and -not $st.Done) {
if (-not $st.FramesAt) {
$own = Get-ChildItem $LogsDir -Filter "victory-nvidia-play-*-$($p.Id).log" -ErrorAction SilentlyContinue | Select-Object -First 1
if ($own -and (Select-String -LiteralPath $own.FullName -Pattern 'frame times:' -SimpleMatch -List -ErrorAction SilentlyContinue)) { $st.FramesAt = Get-Date }
}
$h = $p.MainWindowHandle
if ($st.FramesAt -and $h -ne [IntPtr]::Zero) {
if ($st.Window -ne $h) { $st.Window = $h; $st.WindowAt = Get-Date }
elseif (((Get-Date) - $st.WindowAt).TotalSeconds -ge 3 -and ((Get-Date) - $st.FramesAt).TotalSeconds -ge $SettleSeconds) {
$size = [RigNative]::Borderless($h)
$st.Done = $true
[void]$Sync.Notes.Add("pid $($p.Id): window made borderless full screen ($size)")
}
}
}
}
foreach ($st in @($seen.Values)) {
if ($st.Kind -eq 'preload' -and $st.Proc -and -not $st.Reported) {
try { if ($st.Proc.HasExited) { $st.Reported = $true; $Sync.PreloadExit = $st.Proc.ExitCode } } catch { $st.Reported = $true }
}
}
# What the game holds and what Windows can still commit, every 5 s while the game (not the preload) runs.
if ($games -and ($tick++ % 5) -eq 0) {
if ($gameMB -gt $Sync.PeakGameMB) { $Sync.PeakGameMB = [int]$gameMB }
$free = [int]((Get-CimInstance Win32_OperatingSystem).FreeVirtualMemory / 1KB)
if ($null -eq $Sync.MinCommitMB -or $free -lt $Sync.MinCommitMB) { $Sync.MinCommitMB = $free }
}
Start-Sleep -Milliseconds 1000
}
}
$ps = [powershell]::Create()
[void]$ps.AddScript($watchScript).AddArgument($runner).AddArgument($pin).AddArgument(-not $NoFullscreen).AddArgument($sync).AddArgument((Join-Path $vhome 'logs')).AddArgument(15)
$handle = $ps.BeginInvoke()
# ---------------------------------------------------------------------------------------------------------------
# The run
# ---------------------------------------------------------------------------------------------------------------
$began = Get-Date
$preloadOk = $false
if ($Watch) {
$watcher = Join-Path $PSScriptRoot 'watch-rig.ps1'
if (Test-Path -LiteralPath $watcher) {
Start-Process powershell -ArgumentList @('-NoProfile', '-ExecutionPolicy', 'Bypass', '-NoExit', '-File', "`"$watcher`"") | Out-Null
Write-Host ' live watch: a second window (fps, memory and GPU every minute; it stays open after the game ends)'
} else { Write-Line 'WARN' "no $watcher" }
}
Write-Host ''
Write-Host 'Starting. F1 in the game: settings; F3: the stats panel.' -ForegroundColor Cyan
& $runner @playArgs 2>&1 | ForEach-Object {
$line = "$_"
if ($line -match '^Shaders preloaded in') { $preloadOk = $true }
$line
}
$code = $LASTEXITCODE
# A restart from the F1 menu (or the first start's warm-up) is a new victory.exe: wait for it as well.
while (@(Get-Process victory -ErrorAction SilentlyContinue | Where-Object { try { $_.Path -eq $runner } catch { $false } }).Count) { Start-Sleep -Seconds 2 }
$sync.Stop = $true
[void]$ps.EndInvoke($handle)
# The watcher runs in a runspace of its own; an error there would otherwise go unseen.
if ($ps.Streams.Error.Count) {
$first = $ps.Streams.Error[0]
Write-Line 'WARN' ("the watcher stopped on an error ({0} in all): {1} (line {2})" -f $ps.Streams.Error.Count, $first.Exception.Message, $first.InvocationInfo.ScriptLineNumber)
}
$ps.Dispose()
foreach ($n in $sync.Notes) { Write-Host " $n" }
# The preload counts as done when its process ended with 0 (every step ran to the end); its closing line
# ("Shaders preloaded in ...") is only a fallback, for a start whose preload process the watcher did not see.
$builtAfter = Get-PreloadDoneCount
if ($doPreload) {
$complete = if ($null -ne $sync.PreloadExit) { $sync.PreloadExit -eq 0 } else { $preloadOk }
if ($complete) {
$state = Read-State
Set-StateValue $state 'preloaded' $preloadKey
Save-State $state
Write-Line 'OK' ("shader preload complete ({0:N0} pipelines built in all); not asked again for this victory.exe and driver" -f $builtAfter)
} else {
$why = if ($null -ne $sync.PreloadExit) { "ended with code $($sync.PreloadExit)" } else { 'did not report its end' }
Write-Line 'WARN' ("shader preload stopped early ({0}): {1:N0} pipelines built so far, {2:N0} of them this time. The next start offers to go on." -f $why, $builtAfter, ($builtAfter - $builtBefore))
}
}
$extra = @{ Variant = $variant; CommitStartGB = $rig.CommitFreeGB; CommitLimitGB = $rig.CommitLimitGB; MinCommitFreeMB = $sync.MinCommitMB; PeakGameMB = $(if ($sync.PeakGameMB) { $sync.PeakGameMB } else { $null }) }
if ($null -ne $sync.MinCommitMB) {
Write-Host (" memory: {0:N1} GB of commit free at the start, {1:N1} GB at the least; the game held up to {2:N1} GB" -f $rig.CommitFreeGB, ($sync.MinCommitMB / 1024), ($sync.PeakGameMB / 1024))
}
$logs = @(Get-ChildItem (Join-Path $vhome 'logs') -Filter 'victory-nvidia-play-*.log' -ErrorAction SilentlyContinue | Where-Object { $_.LastWriteTime -ge $began } | Sort-Object LastWriteTime)
foreach ($l in $logs) {
$s = Get-RunSummary $l.FullName
Show-RunSummary $s
Add-RunRow $s $Cores $extra
}
if ($logs.Count) { Write-Host ''; Write-Host "Runs so far: $runsFile (-Compare compares them by settings)" }
else { Write-Host "victory.exe ended (code $code) without a new log in $(Join-Path $vhome 'logs')." }