Files
VIctory-NVIDIA/scripts/play-nvidia.ps1

446 lines
32 KiB
PowerShell

# Starts your own copy of the title on VIctory-NVIDIA with the settings tested on an RTX 4070 SUPER (Series X profile,
# 2560x1440 output, DLSS Quality when NVIDIA Streamline is set up).
#
# .\scripts\play-nvidia.ps1 -Exe 'D:\MyDump\game_scarlett_master.exe'
# .\scripts\play-nvidia.ps1 -Exe ... -Dlss off the title's own upscaling, no DLSS
# .\scripts\play-nvidia.ps1 -Exe ... -Dlss balanced -FrameGen
# .\scripts\play-nvidia.ps1 -Exe ... -SeriesS Series S profile (1280x720 inside, faster, softer)
# .\scripts\play-nvidia.ps1 -Exe ... -Build diag diagnostics build (slower; captures, timelines)
# .\scripts\play-nvidia.ps1 -Exe ... -FrameGen -ForceMfg 3x DLSS frame generation on an RTX 40 through MFG Unlocker (a mod)
# .\scripts\play-nvidia.ps1 -Exe ... -FgType fsr4 -FrameGen AMD FSR 4 upscaling (quality) and FSR 4 frame generation (experimental)
# .\scripts\play-nvidia.ps1 -Exe ... -WarmUsed warm pipelines seen in earlier runs, then exit
# .\scripts\play-nvidia.ps1 -Exe ... -More @{VICTORY_AMBIENT_SPECULAR='0'} add or override switches
# .\scripts\play-nvidia.ps1 -Exe ... -Preload every shader and pipeline made first, with a progress
# window over the title's splash screen (-Splash <file or
# URL> for another picture, -NoPreloadWindow for none)
# .\scripts\play-nvidia.ps1 -Exe ... -Dlss off -NoMenu as asked here, whatever the F1 menu saved (measuring runs)
# .\scripts\play-nvidia.ps1 -Exe ... -More VICTORY_AMBIENT_SPECULAR=0 the same where a hashtable
# cannot be written (Steam's launch options); several pairs, comma-separated, in one -More
#
# In the game, F1 opens a settings menu (arrow keys pick and change, Enter does it). What it saves goes to
# victory-settings.txt under VICTORY_HOME, or in the repository folder by default. The script reads it at each start.
#
# Build first (README). Run from a normal window, not as administrator. Each run writes a log to
# the logs folder under VICTORY_HOME (default %LOCALAPPDATA%\victory).
# Every VICTORY_... switch is described in a comment where the code reads it.
param(
[Parameter(Mandatory)][string]$Exe,
[ValidateSet('diag', 'release')][string]$Build = 'release',
[switch]$SeriesS,
# 1440: output and scene 2560x1440 (Series X, the image is patched); 1080to1440: scene 1920x1080 upscaled by
# the title; 4k: the stock Series X output (3840x2160).
[ValidateSet('1440', '1080to1440', '4k')][string]$Res = '1440',
# DLSS Super Resolution in place of the title's upscaling; needs NVIDIA Streamline (README).
[ValidateSet('off', 'dlaa', 'quality', 'balanced', 'performance', 'ultraperformance')][string]$Dlss = 'quality',
# DLSS Frame Generation (RTX 40 or later, hardware-accelerated GPU scheduling on); needs DLSS.
[switch]$FrameGen,
# Frames shown for each one rendered with -FrameGen: 2 to 6 (more than 2 needs an RTX 50; the layer asks the
# driver how many this card does and gives no more).
[ValidateRange(2, 6)][int]$FrameGenX = 2,
# Frame generation is made ready at every start with Streamline, on or off, so that the F1 menu switches it
# and changes its amount while playing. Only with -FrameGenReady now: ready but off, Streamline's swap chain
# held this PC's frames at 14 a second (20 without), so frame generation off is off unless asked.
[switch]$FrameGenReady,
# (The default now; still taken.)
[switch]$NoFrameGenReady,
# Which frame generation: auto (DLSS Frame Generation where it runs, else AMD's FSR 3), dlss, or fsr (FSR 3
# even on an RTX 40/50; 2X only). FSR 3 needs AMD's FidelityFX DLLs (VICTORY_FIDELITYFX_DIR, else
# amd-sdk\FidelityFX\bin here, where Get-AMD-FSR.cmd puts them) and DLSS for the upscaling, on either console.
# fsr4 (experimental, as `victory play --fg-type fsr4`): AMD's PC upscaler in place of DLSS (FSR 4 on RDNA 4,
# VICTORY_PC_FSR), its scene at -Dlss's size (quality where -Dlss is off), and with -FrameGen FSR 4 frame
# generation (VICTORY_FSR_FRAMEGEN=4, 2X). Same DLLs.
[ValidateSet('auto', 'dlss', 'fsr', 'fsr4')][string]$FgType = 'auto',
# Frames begin every 1/Fps s whatever the title asks (it asks 1/30). 1000, the default: no cap, a frame
# begins as soon as the last is done. 30: the title's own rate.
[ValidateRange(1, 1000)][int]$Fps = 1000,
# -Fps also gives the title its own frame rate (VICTORY_FRAME_INTERVAL_MS), so that its simulation steps by the
# time that passed: with only our clock faster, each frame still moved game time 1/30 s and above 30 fps the game
# ran fast. -FixedStep: our clock alone (VICTORY_FRAME_INTERVAL_US), as before.
[switch]$FixedStep,
[switch]$ForceMfg,
# Every shader and the loading pipelines made first (`victory preload`), then the game; the F1 menu's
# PRELOAD SHADERS starts this again with it.
[switch]$Preload,
# The preload shows its progress in a window (scripts\preload-window.ps1) over the title's own splash screen
# (SplashScreenImage in MicrosoftGame.config beside -Exe), or over the picture -Splash names: a file, or an
# http(s) URL fetched once into %LOCALAPPDATA%\victory\splash. -NoPreloadWindow: in this window only.
[string]$Splash = '',
[switch]$NoPreloadWindow,
[switch]$WarmUsed,
# What the F1 menu saved (victory-settings.txt) is left out: this call's options stand. For runs
# that are compared with each other: a saved DLSS mode went over "-Dlss off" otherwise.
[switch]$NoMenu,
# Switches to add or override: a hashtable (`-More @{VICTORY_X='1'}`), or, where a hashtable
# cannot be written — Steam's launch options hand every argument over as it was typed, and
# anything else starting this with -File does too, and no parameter can be given twice —
# `NAME=VALUE`, several of them comma-separated in one `-More`; `NAME=` unsets a switch.
[object[]]$More = @()
)
$repo = Split-Path $PSScriptRoot -Parent
. (Join-Path $PSScriptRoot 'preload-window.ps1')
$preloadWindow = $null
# The F1 menu's "PRELOAD SHADERS" restarts this with -Preload (and VICTORY_PRELOAD=1, read here before the
# switches below are cleared).
$preload = $Preload -or $env:VICTORY_PRELOAD -eq '1'
# Its "CLEAR SHADER CACHE" restarts this with VICTORY_CLEAR_SHADERS=1 (read here too): the shaders and pipelines
# made so far are deleted before the game starts (`victory clear-shaders`).
$clearShaders = $env:VICTORY_CLEAR_SHADERS -eq '1'
# What the F1 menu saved: its own choices (VICTORY_MENU_...) stand in for this script's options, and its
# switches go over the settings below. An empty value unsets a switch.
$homeDir = if ($env:VICTORY_HOME) { $env:VICTORY_HOME } else { Join-Path $env:LOCALAPPDATA 'victory' }
$menuDir = if ($env:VICTORY_HOME) { $homeDir } else { $repo }
$menuFile = Join-Path $menuDir 'victory-settings.txt'
$menu = [ordered]@{}
if (-not $NoMenu -and (Test-Path -LiteralPath $menuFile)) {
foreach ($line in Get-Content -LiteralPath $menuFile) {
if ($line -match '^\s*(VICTORY_[A-Z0-9_]+)\s*=(.*)$') { $menu[$Matches[1]] = $Matches[2].Trim() }
}
}
$fpsWanted = $Fps
if ($menu.Contains('VICTORY_MENU_CONSOLE')) { $SeriesS = $menu['VICTORY_MENU_CONSOLE'] -eq 'series-s' }
if ($menu['VICTORY_MENU_RES'] -in '1440', '1080to1440', '4k') { $Res = $menu['VICTORY_MENU_RES'] }
$hasSavedDlss = $menu['VICTORY_MENU_DLSS'] -in 'off', 'dlaa', 'quality', 'balanced', 'performance', 'ultraperformance'
if ($hasSavedDlss) { $Dlss = $menu['VICTORY_MENU_DLSS'] }
$timesWanted = $FrameGenX
if ($menu.Contains('VICTORY_MENU_FRAMEGEN')) {
# 0: off; 2 to 6: that many frames shown for each one rendered (1, from an older file: 2).
$FrameGen = $menu['VICTORY_MENU_FRAMEGEN'] -match '^[1-6]$'
if ($menu['VICTORY_MENU_FRAMEGEN'] -match '^[2-6]$') { $timesWanted = [int]$menu['VICTORY_MENU_FRAMEGEN'] }
}
if ($menu['VICTORY_MENU_FG_TYPE'] -in 'auto', 'dlss', 'fsr', 'fsr4') { $FgType = $menu['VICTORY_MENU_FG_TYPE'] }
# F1's FORCE 3X ON RTX 40: MFG Unlocker (github.com/dashdogy/MFG-Unlocker, someone else's MIT mod, fetched and
# checked by scripts\get-mfg-unlocker.ps1) loaded by victory.exe, and 3x where frame generation is on at 2x. The
# layer keeps 2x if the card still reports one generated frame at most.
if ($menu.Contains('VICTORY_FORCE_MFG_RTX40')) { $ForceMfg = $menu['VICTORY_FORCE_MFG_RTX40'] -eq '1' }
if ($ForceMfg -and $timesWanted -eq 2) { $timesWanted = 3 }
if ($menu['VICTORY_MENU_FPS'] -match '^\d+$' -and [int]$menu['VICTORY_MENU_FPS'] -ge 1 -and [int]$menu['VICTORY_MENU_FPS'] -le 1000) { $fpsWanted = [int]$menu['VICTORY_MENU_FPS'] }
# Pipeline workers raise shader-build throughput but also increase the startup memory peak.
# Use fewer on 16 GiB hosts; `-More` can still override this for a specific run.
$physicalRam = (Get-CimInstance -ClassName Win32_ComputerSystem -ErrorAction SilentlyContinue).TotalPhysicalMemory
$pipelineWorkers = '8'
if ($physicalRam) { $pipelineWorkers = if ($physicalRam -le 16GB) { '4' } else { '12' } }
$settings = @{
# Submission and copy machinery
# Left off: VICTORY_RELAY=2, as fast as off on an RTX 5070 Ti (26.9 against 27.4 fps, the first cutscene's diner
# and the prologue's cell, release, every pipeline warmed) with more frames over 50 ms, and the switch
# fxceless/victory-fork #89 found characters' skin missing with on an RTX 5070 Laptop.
VICTORY_THIN = '1'; VICTORY_JOIN_PARTS = '8'; VICTORY_RELAY_COPY = '1'; VICTORY_WIDE_BACK = '1'
VICTORY_CARD_REHASH_RUNS = '1'; VICTORY_JOIN_COPIES = '1'; VICTORY_CARD_STEPS = '2'
# Not VICTORY_CARD_AWAKE (a compute job kept running between submissions): slower in the game, 17.4 fps against
# 19.0 on an RTX 4070 Ti SUPER, and it held a menu back (#771). -More @{VICTORY_CARD_AWAKE='1'} turns it on.
VICTORY_CARD_BUFFERS_MIN_KB = '64'; VICTORY_INDIRECT_WINDOW = '1'; VICTORY_INDIRECT_BATCH = '2'
VICTORY_UPLOAD_AHEAD = '1'; VICTORY_SHOW_AFTER = '1'; VICTORY_MAP_THREADS = '1'
# Shader writes into big write-combined copies stay on the card (-5 ms a frame)
VICTORY_WC_NO_BACK = '1'; VICTORY_WC_NO_BACK_MIN_KB = '1024'
# The title's page-mapping copies kept without Windows views (no cutscene freezes at scene cuts)
VICTORY_SOFT_VIEWS = 'copies'
# Textures: pool with no blocks made ahead, 32 ms a pass, no catch-up; auto selects on-demand levels for <=8 GiB budgets
VICTORY_TEXTURE_POOL = '1'; VICTORY_RIPE_BLOCKS = '0'; VICTORY_TEXTURE_NO_WAIT = '1'; VICTORY_TEXTURE_CATCHUP = '0'
VICTORY_TEXTURE_STAGE_MS = '32'; VICTORY_LEVELS_ON_DEMAND = 'auto'
# VICTORY_POOL_SMALL at its default (textures of 64 KiB and less at 4 KiB multiples in the pool): the 64 KiB
# placement was for device losses on an AMD card. On the RTX 5070 Ti the same ~18,000 textures took 1.52 GB
# instead of 2.24 and the pool's blocks 2.8 GB instead of 3.9; no device loss in six minutes.
# Small textures at 4 KiB. RTX 2060, Series S, one switch: about 10 fps to 13, about 800 MB less on the card (2026-11-28)
VICTORY_PRELUDE_UPLOADS = '1'; VICTORY_SHOW_NEW_LATER = '1'; VICTORY_POOL_SMALL = '1'; VICTORY_TABLED_REREAD = '1'
VICTORY_QUEUE_HOST_TEXTURES = '0'
# Descriptor heaps' records
VICTORY_HEAP_SYNC_FIRST = '1'; VICTORY_SYNC_IN_PLACE = '1'; VICTORY_SPANS_QUICK = '1'; VICTORY_SYNC_FINE = '1'
VICTORY_HEAP_SYNC_AT_SUBMIT = '1'
# A frame's texture passes within 8 ms together; helpers woken at each submission's start (foxhound 0.2.0-pre.4,
# from its PR #13); the layer's threads a frame waits for above normal priority (foxhound 0.2.0-pre.3). As `victory play`.
VICTORY_TEXSPK_PASS_MS = '8'; VICTORY_PASSES_HOT = '1'; VICTORY_HELPER_PRIORITY = '1'
# Light without the title's ray tracing: an estimate of indirect light and of reflections
VICTORY_AMBIENT = '0.8'; VICTORY_AMBIENT_AIR = '1.5'; VICTORY_AMBIENT_SPECULAR = '1'
# Pixel programs keep the console's early depth test
VICTORY_EARLY_DEPTH = '1'
# 默认跳过人脸重定位和热浪;人脸重定位的新 Wave32 路径由 PLAY_FACES_FIX 启用。
# Left out: the face-relocation compute and the heat-haze pass
VICTORY_LEAVE_OUT = '02384a60fda6f2d0,731a39171b568298'
# Pipelines the title makes are written down, so `victory warm` can make them ahead
VICTORY_PIPELINE_BOOK = '1'
# Fewer makers on 16 GiB hosts reduce shader-build peak memory; `-More` can override.
# Pipelines the library cannot hold are made again every start. The wait stays at 500 ms: at 50 ms a pass
# a face needs is dropped.
VICTORY_PIPELINE_LOWEST = '0'; VICTORY_PIPELINE_WORKERS = $pipelineWorkers; VICTORY_PIPELINE_SLOW = '0'
# Memory stack (skornuta): unused texture slots given back, old allocators taken anew, small buffers packed
VICTORY_SLOT_EVICT = '1'
VICTORY_ALLOCATOR_TRIM = '1'
VICTORY_BUDGET_PACK = '1'
}
# PCs with 16 GB of RAM or less: the host copies of title memory are cut on a 1 MiB grid, and an ask without a
# length (a root view) takes its 4 MiB cell from its own 256 KiB step on, not from the cell's start. Measured on an
# RTX 5060 Laptop (8 GB) with 16 GB of RAM, Series S, the prison's day room (diagnostics build, memory line): the
# windows 3,400 -> 2,598 MB, of them those asked for without a length 2,732 -> 980 MB, the card's share of the PC's
# memory 6.0 -> 5.2 GB, and the slowest tenth of seconds 3.7 -> 11.9 fps (median 14.0 -> 14.4); release build,
# median 16.0 -> 16.4 fps. -More @{VICTORY_WINDOW_KB='4096'} restores the 4 MiB grid.
$ramGb = try { (Get-CimInstance Win32_ComputerSystem -ErrorAction Stop).TotalPhysicalMemory / 1GB } catch { 0 }
if ($ramGb -gt 0 -and $ramGb -le 16.5) {
$settings.VICTORY_WINDOW_KB = '1024'; $settings.VICTORY_WINDOW_TAILS = '1'
}
if (-not $SeriesS) {
if ($Res -eq '1440') { $settings.VICTORY_NATIVE_1440P = '1' }
elseif ($Res -eq '1080to1440') { $settings.VICTORY_RENDER_1080P = '1' }
}
# Where victory.exe keeps NVIDIA's and AMD's files (its get-dlss and get-fsr, and its first start): VICTORY_HOME,
# else %LOCALAPPDATA%\victory. Looked in after this repository's own folders, as victory.exe looks there before
# its own: without it, a PC set up with victory.exe ran this launcher without DLSS and said so only in this
# window (an RTX 5070 Ti, 2026-11-28: six measured runs with the title's own upscaling instead of DLSS Quality).
$victoryHome = if ($env:VICTORY_HOME) { $env:VICTORY_HOME } else { Join-Path $env:LOCALAPPDATA 'victory' }
if ($Dlss -ne 'off' -and $FgType -ne 'fsr4') {
# NVIDIA's files: where VICTORY_STREAMLINE_DIR says, else where Get-NVIDIA-DLSS.cmd puts them, else victory.exe's.
$sl = if ($env:VICTORY_STREAMLINE_DIR) { $env:VICTORY_STREAMLINE_DIR } else {
@((Join-Path $repo 'nvidia-sdk\Streamline\bin\x64'), (Join-Path $victoryHome 'nvidia-sdk\Streamline\bin\x64')) |
Where-Object { Test-Path (Join-Path $_ 'sl.interposer.dll') } | Select-Object -First 1
}
if (-not $sl) { $sl = Join-Path $repo 'nvidia-sdk\Streamline\bin\x64' }
if (Test-Path (Join-Path $sl 'sl.interposer.dll')) {
# Absolute: the title is started from the repository's folder, where a relative path is not found.
$sl = (Resolve-Path -LiteralPath $sl).ProviderPath
$settings.VICTORY_DLSS = '1'; $settings.VICTORY_DLSS_MODE = $Dlss; $settings.VICTORY_STREAMLINE_DIR = $sl
if ($FrameGen) { $settings.VICTORY_FRAMEGEN = '1'; $settings.VICTORY_FRAMEGEN_X = [string]$timesWanted }
elseif ($FrameGenReady -and -not $NoFrameGenReady) { $settings.VICTORY_FRAMEGEN = '1'; $settings.VICTORY_FRAMEGEN_X = '0' } # ready, off
# Frame generation takes 1.5 to 2 GB of the card's memory, which the layer otherwise fills with textures up
# to nine tenths of its budget (on a 12 GB card it then ran out: no generated frames). On from the start, it
# is left a fifth of the budget; ready but off, a little less is held back.
if ($settings.VICTORY_FRAMEGEN -eq '1') {
$settings.VICTORY_TEXTURE_ROOM_PERCENT = if ($FrameGen -and $timesWanted -gt 2) { '74' } elseif ($FrameGen) { '80' } else { '86' }
# (held back only when a frame-generation backend was made available on this adapter)
$settings.VICTORY_FRAMEGEN_ROOM_RESERVE = '1'
}
} else {
Write-Host "No NVIDIA files in ${sl}: running without DLSS and frame generation. Get-NVIDIA-DLSS.cmd in the"
Write-Host "repository folder fetches them from NVIDIA once (about 70 MB); VICTORY_STREAMLINE_DIR names another folder."
}
}
# AMD's FidelityFX DLLs: where VICTORY_FIDELITYFX_DIR says, else where Get-AMD-FSR.cmd puts them, else victory.exe's.
$fx = if ($env:VICTORY_FIDELITYFX_DIR) { $env:VICTORY_FIDELITYFX_DIR } else {
@((Join-Path $repo 'amd-sdk\FidelityFX\bin'), (Join-Path $victoryHome 'amd-fidelityfx')) |
Where-Object { Test-Path (Join-Path $_ 'amd_fidelityfx_framegeneration_dx12.dll') } | Select-Object -First 1
}
if (-not $fx) { $fx = Join-Path $repo 'amd-sdk\FidelityFX\bin' }
if (Test-Path -LiteralPath $fx) { $fx = (Resolve-Path -LiteralPath $fx).ProviderPath }
# -FgType fsr4: AMD's PC upscaler takes the title's upscalings, as `victory play --fg-type fsr4` sets it up
# (play.rs). Its scene at -Dlss's size, quality where that is off: with frame generation and no mode named the
# layer keeps the scene at the output's size, which on an RX 9070 XT (2026-11-29) rendered 2560x1440 with
# nothing upscaled and fell from about 22 to 3 fps once a save was loaded.
if ($FgType -eq 'fsr4') {
$settings.VICTORY_PC_FSR = '1'; $settings.VICTORY_FIDELITYFX_DIR = $fx
$settings.VICTORY_DLSS_MODE = if ($Dlss -eq 'off') { 'quality' } else { $Dlss }
if (-not (Test-Path (Join-Path $fx 'amd_fidelityfx_upscaler_dx12.dll'))) {
Write-Host "No AMD FSR files in ${fx}: Get-AMD-FSR.cmd in the repository's folder fetches them from AMD (about"
Write-Host '30 MB, once). Without them the title upscales on its own.'
}
}
# AMD FSR 3 frame generation: made ready as DLSS Frame Generation is (on, or ready and off for the F1 menu).
# auto: the layer uses it only where DLSS Frame Generation does not run; fsr: DLSS Frame Generation is not asked;
# fsr4: FSR 4 frame generation on AMD's PC upscaler, without DLSS.
if ($FgType -ne 'dlss' -and ($FrameGen -or ($FrameGenReady -and -not $NoFrameGenReady))) {
# Asked whatever is here: the layer checks the files and the card, and the start's notice (on the picture for
# its first 30 s, and in this window) says what runs and why not. Without DLSS it stays off, on either
# console: it needs DLSS for the upscaling.
$settings.VICTORY_FSR_FRAMEGEN = if ($FgType -eq 'fsr4') { '4' } else { '1' }; $settings.VICTORY_FIDELITYFX_DIR = $fx
if (-not (Test-Path (Join-Path $fx 'amd_fidelityfx_framegeneration_dx12.dll'))) {
Write-Host "No AMD FSR 3 files in ${fx}: Get-AMD-FSR.cmd in the repository's folder fetches them from AMD (about"
Write-Host '30 MB, once). Needed only on cards without DLSS frame generation, or with FSR 3 chosen in F1.'
}
if ($FgType -in 'fsr', 'fsr4') { $settings.Remove('VICTORY_FRAMEGEN') }
if (-not $settings.VICTORY_FRAMEGEN_X) { $settings.VICTORY_FRAMEGEN_X = if ($FrameGen) { [string]$timesWanted } else { '0' } }
if (-not $settings.VICTORY_TEXTURE_ROOM_PERCENT) {
$settings.VICTORY_TEXTURE_ROOM_PERCENT = if ($FrameGen) { '80' } else { '86' }
$settings.VICTORY_FRAMEGEN_ROOM_RESERVE = '1'
}
}
if ($FixedStep) { $settings.VICTORY_FRAME_INTERVAL_US = [string][int][math]::Round(1000000 / $fpsWanted) }
elseif ($fpsWanted -ge 1000) {
# No wait of ours, and the title told 59 (not its "no limit", which halves a per-frame scale of its own):
# real speed from 15 to 59 rendered frames a second, measured 0.985x at 30-36.
$settings.VICTORY_FRAME_INTERVAL_MS = '0'; $settings.VICTORY_TITLE_FPS = '59'
}
else { $settings.VICTORY_FRAME_INTERVAL_MS = ([math]::Round(1000 / $fpsWanted, 3)).ToString([Globalization.CultureInfo]::InvariantCulture) }
foreach ($k in $menu.Keys) {
if ($k -like 'VICTORY_MENU_*') { continue }
if ($k -eq 'VICTORY_TEXTURE_ROOM_PERCENT') { $settings.Remove('VICTORY_FRAMEGEN_ROOM_RESERVE') }
if ($menu[$k]) { $settings[$k] = $menu[$k] } else { $settings.Remove($k) }
}
# -More: a hashtable from a PowerShell window, or NAME=VALUE strings where one cannot be written
# (Steam's launch options, and anything else that starts this with -File, hand the arguments over
# as they were typed).
$moreSettings = [ordered]@{}
foreach ($item in $More) {
if ($item -is [System.Collections.IDictionary]) {
foreach ($k in $item.Keys) { $moreSettings["$k"] = "$($item[$k])" }
continue
}
# A command line PowerShell did not split itself (Steam's, and -File's): the pairs may be
# comma-separated there. A comma inside a value is left alone — VICTORY_LEAVE_OUT has one —
# so only a comma in front of another NAME= separates.
foreach ($pair in ("$item" -split ',(?=\s*VICTORY_[A-Z0-9_]+\s*=)')) {
if ($pair -match '^\s*(VICTORY_[A-Z0-9_]+)\s*=(.*)$') {
$moreSettings[$Matches[1]] = $Matches[2].Trim()
} elseif ("$pair") {
Write-Host "Ignoring -More `"$pair`": not NAME=VALUE."
}
}
}
foreach ($k in $moreSettings.Keys) {
if ($k -eq 'VICTORY_TEXTURE_ROOM_PERCENT') { $settings.Remove('VICTORY_FRAMEGEN_ROOM_RESERVE') }
if ($moreSettings[$k]) { $settings[$k] = $moreSettings[$k] } else { $settings.Remove($k) }
}
# A held mouse that is not put back in the middle stops at the window's edge, and with it the turning.
if ($settings.VICTORY_MOUSE_CAPTURE -eq '1' -and -not $settings.Contains('VICTORY_MOUSE_WARP')) { $settings.VICTORY_MOUSE_WARP = '1' }
# Mouse and keyboard (F1, MOUSE AND KEYBOARD), as victory.exe play does it (play.rs): the keys and
# sensitivity in bindings.ini in %LOCALAPPDATA%\victory (VICTORY_HOME if set), written with the
# repository's defaults the first time, and the game started with it. Without that file named, the game
# had no mouse and keyboard however the menu was set, and KEY BINDINGS asked to turn them on (#1369).
# A VICTORY_MNK_BINDINGS given with -More names another file.
if ($settings.VICTORY_MNK -eq '1' -and -not $settings.VICTORY_MNK_BINDINGS) {
$mnkHome = if ($env:VICTORY_HOME) { $env:VICTORY_HOME } else { Join-Path $env:LOCALAPPDATA 'victory' }
$bindings = Join-Path $mnkHome 'bindings.ini'
if (-not (Test-Path -LiteralPath $bindings)) {
New-Item -ItemType Directory -Force -Path $mnkHome | Out-Null
# A copy that fails when the file is there, so the player's own keys are never written over
# (a file made since the check above, or one the check could not see); as play.rs does it.
try { [System.IO.File]::Copy((Join-Path $repo 'bindings.ini'), $bindings, $false) } catch { }
}
if (Test-Path -LiteralPath $bindings) {
$settings.VICTORY_MNK_BINDINGS = $bindings
Write-Host "mouse/keyboard on: keys and sensitivity in $bindings"
}
}
$console = if ($SeriesS) { 'series-s' } else { 'series-x' }
# For the menu: what it shows as the current choices, where it saves, and how it starts the game again
# (-More is not carried over a restart from the menu).
$settings.VICTORY_MENU_CONSOLE = $console
$settings.VICTORY_MENU_RES = $Res
$settings.VICTORY_MENU_DLSS = if ($hasSavedDlss -or $settings.VICTORY_DLSS -eq '1') { $Dlss } else { 'off' }
if ($ForceMfg -and $settings.VICTORY_DLSS -eq '1') {
$mfgDir = Join-Path $env:LOCALAPPDATA 'victory\mfg-unlocker'
& powershell.exe -NoProfile -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot 'get-mfg-unlocker.ps1') -To $mfgDir
$mfgDll = Join-Path $mfgDir 'MFGUnlocker.dll'
if (Test-Path -LiteralPath $mfgDll) {
$settings.VICTORY_MFG_UNLOCKER = '1'; $settings.VICTORY_MFG_UNLOCKER_DLL = $mfgDll; $settings.VICTORY_FORCE_MFG_RTX40 = '1'
} else {
Write-Warning 'MFG Unlocker did not arrive: frame generation stays at what the card gives (2x on RTX 40).'
}
}
$settings.VICTORY_MENU_FRAMEGEN = if ($settings.VICTORY_FRAMEGEN -eq '1' -or $settings.VICTORY_FSR_FRAMEGEN -in '1', '4') { [string]$settings.VICTORY_FRAMEGEN_X } else { '0' }
$settings.VICTORY_MENU_FG_TYPE = $FgType
$settings.VICTORY_MENU_FPS = [string]$fpsWanted
$settings.VICTORY_MENU_FILE = $menuFile
$settings.VICTORY_MENU_PLAY = $MyInvocation.MyCommand.Path
$settings.VICTORY_MENU_CWD = $PWD.ProviderPath
$settings.VICTORY_MENU_ARGS = "-Exe `$env:VICTORY_MENU_EXE -Build $Build$(if ($FrameGenReady -and -not $NoFrameGenReady) { ' -FrameGenReady' })$(if ($FixedStep) { ' -FixedStep' })" +
$(if ($Splash) { " -Splash '$($Splash -replace "'", "''")'" }) + $(if ($NoPreloadWindow) { ' -NoPreloadWindow' })
$victory = Join-Path $repo "target\$Build\victory.exe"
if (-not (Test-Path $victory)) {
# Not built yet: built here, once.
if (-not (Get-Command cargo -ErrorAction SilentlyContinue)) { Write-Host "No $victory, and no cargo to build it with: install Rust (README), then start this again."; exit 1 }
Write-Host 'Building the layer (a few minutes the first time) ...'
Push-Location $repo
try {
if ($Build -eq 'diag') { cargo build --locked --profile diag -p victory --features diagnostics }
else { cargo build --release --locked -p victory }
} finally { Pop-Location }
if (-not (Test-Path $victory)) { Write-Host "The build did not make $victory."; exit 1 }
}
if (-not (Test-Path -LiteralPath $Exe)) { Write-Host "No $Exe."; exit 1 }
# Absolute before the folder changes below: the title is started from the repository's folder, where a
# relative path would not be found (the check above looks from the folder the launcher was started in).
$Exe = (Resolve-Path -LiteralPath $Exe).ProviderPath
# Every translated shader is SM 6.6. Windows 10's own Direct3D 12 stops at 6.5, and with no D3D12\D3D12Core.dll
# beside victory.exe it makes no device at all ("none"); `victory get-d3d12` fetches Microsoft's newer runtime
# there, as `victory play` does. Asked only while that folder is missing; nothing is fetched at 6.6 or above.
if (-not (Test-Path -LiteralPath (Join-Path (Split-Path -Parent $victory) 'D3D12\D3D12Core.dll'))) {
$model = "$(& $victory shader-model 2>$null | Select-Object -Last 1)".Trim()
if ($model -notmatch '^\d+\.\d+$' -or [version]$model -lt [version]'6.6') {
Write-Host "Direct3D 12 here runs shader model $(if ($model -match '^\d+\.\d+$') { $model } else { 'none (no device)' }); the game's translated shaders need 6.6."
& $victory get-d3d12
if ($LASTEXITCODE -ne 0 -and $model -match '^\d+\.\d+$') {
Write-Host "Microsoft's Direct3D 12 runtime did not arrive: every shader would be refused. ``$victory get-d3d12`` tries again."
exit 1
}
}
}
$settings.VICTORY_MENU_EXE = $Exe
# The optional ReShade host has its own application directory. DXGI and its
# add-ons are discovered next to that executable, including at process start.
# For an RTX 40, install the full add-on edition of ReShade and the optional
# mavismmg/MFGAdaUnlock-RenoDx add-on in target/<build>/ada-mfg. In a new
# PowerShell session set $env:GTA6_ADA_MFG='1' and $env:GTA6_FRAMEGEN_X='4',
# then run .\PLAY_FRAMEGEN.cmd 3. The multiplier override accepts 2 through 6.
if ($env:GTA6_ADA_MFG -eq '1') {
$hostDir = Join-Path $repo "target\$Build\ada-mfg"
foreach ($file in 'dxgi.dll', 'renodx-mfgunlock.addon64') {
if (-not (Test-Path -LiteralPath (Join-Path $hostDir $file) -PathType Leaf)) {
throw "The optional Ada MFG host is missing $file in $hostDir"
}
}
$hostExe = Join-Path $hostDir 'victory.exe'
if (-not (Test-Path -LiteralPath $hostExe) -or (Get-FileHash $victory).Hash -ne (Get-FileHash $hostExe).Hash) {
Copy-Item -LiteralPath $victory -Destination $hostExe -Force -ErrorAction Stop
}
$victory = $hostExe
}
# Switches left over in this window are cleared; path settings and the card stay, as the launcher's KEPT
# keeps them (apps\victory\src\play.rs; victory.toml gives the paths otherwise). Cleared, VICTORY_HOME sent
# the preload's and the game's caches to %LOCALAPPDATA% (#751).
$paths = 'VICTORY_MENU_PAD', 'VICTORY_HOME', 'VICTORY_ADAPTER', 'VICTORY_CONFIG', 'VICTORY_GAME_DIR', 'VICTORY_CACHE_DIR', 'VICTORY_DATA_DIR', 'VICTORY_STREAMLINE_DIR', 'VICTORY_FIDELITYFX_DIR', 'VICTORY_LOG'
Get-ChildItem Env:VICTORY_* -ErrorAction SilentlyContinue | Where-Object { $_.Name -notin $paths } | ForEach-Object { Remove-Item "Env:$($_.Name)" }
# Play mode's defaults that are part of the shader translation key (apps\victory\src\play.rs): without them
# a cache made by `victory preload` is never hit and every shader is translated again in play (#4067).
foreach ($k in 'VICTORY_BVH_MISS', 'VICTORY_NAN_SCRUB', 'VICTORY_SAMPLED_MARKS') { if (-not $settings.ContainsKey($k)) { $settings[$k] = '1' } }
foreach ($k in $settings.Keys) { Set-Item "Env:$k" $settings[$k] }
$logs = Join-Path $homeDir 'logs'; New-Item -ItemType Directory -Force $logs | Out-Null
$log = Join-Path $logs ('victory-nvidia-{0:yyyyMMdd-HHmmss}.log' -f (Get-Date))
$writer = [IO.StreamWriter]::new($log, $false, [Text.UTF8Encoding]::new($false)); $writer.AutoFlush = $true
$writer.WriteLine("# console=$console build=$Build preload=$preload warm-used=$WarmUsed switches: " + (($settings.GetEnumerator() | Sort-Object Name | ForEach-Object { "$($_.Name)=$($_.Value)" }) -join ' '))
Write-Host "Log: $log"
Push-Location $repo # victory.toml is read from here
try {
if ($clearShaders) {
& $victory clear-shaders 2>&1 | ForEach-Object { $line = "$_"; $writer.WriteLine("# clear-shaders: $line"); $line }
}
if ($WarmUsed) {
$warmArgs = @('warm', '--used')
if ($settings.VICTORY_PRELOAD_JOBS -match '^[1-9][0-9]*$') {
$warmArgs += @('--jobs', $settings.VICTORY_PRELOAD_JOBS)
}
& $victory @warmArgs 2>&1 | ForEach-Object { $line = "$_"; $writer.WriteLine($line); $line }
exit $LASTEXITCODE
}
if ($preload) {
# With this start's switches (the translations depend on them); its lines go to the log too.
Write-Host 'Preloading shaders before the game starts. This takes a while (see the lines below).'
$began = Get-Date
if (-not $NoPreloadWindow) {
$preloadWindow = Start-PreloadWindow -Splash (Get-SplashImage $Exe $Splash) -Icon (Get-SplashIcon $Exe) `
-StateFile (Join-Path $env:LOCALAPPDATA 'victory\preload-last.txt')
}
# (Split-Path -LiteralPath with -Parent: no such parameter set in Windows PowerShell 5.1.)
& $victory preload ([IO.Path]::GetDirectoryName($Exe)) 2>&1 | ForEach-Object {
$line = "$_"; $writer.WriteLine("# preload: $line"); Update-PreloadWindow $preloadWindow $line; $line
}
$code = $LASTEXITCODE
$minutes = ((Get-Date) - $began).TotalMinutes
$how = if ($preloadWindow -and $preloadWindow.Skipped) { 'skipped (what it did is kept)' } elseif ($code -eq 0) { 'done' } else { "ended with code $code" }
$said = 'Preload {0} after {1:N1} min. Starting the game.' -f $how, $minutes
$writer.WriteLine("# $said"); Write-Host $said
Complete-PreloadWindow $preloadWindow ('Preload {0} after {1:N1} min.' -f $how, $minutes) ($code -eq 0)
}
# DLSS Enabler (winmm.dll beside victory.exe) stays off in a process with a console window or console output,
# so the layer runs without a window and its output comes through a pipe.
$env:VFG_BIN = $victory; $env:VFG_EXE = $Exe
$psi = [Diagnostics.ProcessStartInfo]::new('cmd.exe', ('/d /s /c ""%VFG_BIN%" run "%VFG_EXE%" --console {0} --execute 2>&1"' -f $console))
$psi.UseShellExecute = $false; $psi.CreateNoWindow = $true; $psi.RedirectStandardOutput = $true
$psi.StandardOutputEncoding = [Text.UTF8Encoding]::new($false); $psi.WorkingDirectory = $repo
$p = [Diagnostics.Process]::Start($psi)
while ($null -ne ($line = $p.StandardOutput.ReadLine())) { $writer.WriteLine($line); $line }
$p.WaitForExit()
$global:LASTEXITCODE = $p.ExitCode
}
finally { Pop-Location; $writer.Dispose(); Close-PreloadWindow $preloadWindow }
# What `victory run` returned: a title that failed is a failed start for whoever called this script.
exit $LASTEXITCODE