# Starts the title on an NVIDIA card: Series S, the game's own 720p picture taken to 1080p by DLSS, the F1 # settings menu in the game (measured on an RTX 5070: about 15-17 fps before generated frames). # scripts\play-nvidia.ps1 -Exe # DLSS and DLSS frame generation need a few NVIDIA files (about 70 MB) that this repository does not carry: # run Get-NVIDIA-DLSS.cmd in the repository's folder once, and they are fetched from NVIDIA's GitHub into # nvidia-sdk\. Without them the game runs with its picture stretched to the screen instead. # The layer is built here if it is not built yet, and built again with DLSS once those files are there. # In the game: F1 = settings (arrows pick and change, Enter saves; kept in leonida-settings.txt next to this # folder), F3 = the numbers panel. The last choice wins, one setting at a time: a switch typed for a start wins over # the menu's saved value of what it sets (and the menu file drops that value); every other setting keeps the menu's. # -NoSmoothMotion run target\\leonida.exe itself. By default a copy named leonida_sm.exe is started instead, # so a Smooth Motion profile set for that exe in the NVIDIA App applies every time. # -NoDlss no DLSS: the picture is stretched (fast, softer) # -SeriesX the Series X profile instead (much slower). Without -Dlss or -FrameGen the title's own upscaler # makes its 3840x2160 output, as before. # -Dlss DLSS makes the output, from a render height by mode: quality (2/3 of the output's lines: 1440 on # Series X, the game's own 720 on Series S), balanced (0.6: 1296), performance (1/2: 1080) or ultra # (1/3: 720). On Series X the title is made to upscale through FidelityFX as on Series S # (LEONIDA_FSR_UPSCALER), which is where DLSS takes over. # -FrameGen DLSS frame generation: 2 (twice the frames shown), up to 6 where the card does more (RTX 40: 2). # It takes depth and motion vectors from the DLSS upscale, so on Series X it turns -Dlss quality on # unless a mode is given; with -Resolution, from the G-buffer pass, and it is then on (2) by # default on RTX 40 and 50 cards when its files are here. # -NoFrameGen no DLSS frame generation (Smooth Motion instead, if the NVIDIA App has it on for leonida_sm.exe) # -MotionBlur the title's own motion blur, left out by default: it blurs by the movement of one frame, so at # this port's frame rate its smears are twice as long as at 30 and break into blocks on camera turns # -FsrFrameGen AMD's FSR 3 frame generation instead (twice the frames shown), for cards without DLSS frame # generation (RTX 20 and 30). It takes the same depth and motion vectors, and needs AMD's signed # amd_fidelityfx_loader_dx12.dll and amd_fidelityfx_framegeneration_dx12.dll in amd-sdk\FidelityFX\bin # (or -FidelityFxDir). Also in the F1 menu (FSR 3 FRAME GEN), from the next start. # -FidelityFxDir the folder with AMD's two DLLs, if not amd-sdk\FidelityFX\bin # -Fullscreen the game's window borderless over its whole monitor from the start (Alt+Enter switches back and # forth while it runs, with or without this; also FULLSCREEN in the F1 menu) # -Aspect the window's shape: 21:9, 32:9, 16:9, W:H or auto (the screen's). The game still draws 16:9. # -PresentScale fit (the 16:9 picture centred, black bars beside it: the default with -Aspect) or stretch # -Quality fewer stretched/jumping bodies, slower (relay stage 1, no card steps) # -RayTracing the title's real ray tracing (the structure builder runs). Shaders build for minutes the # first time, and DLSS frame generation is left off with it (the two together do not work yet). # -HardwareRT a trial: the title's rays on the card's ray-tracing cores (DXR 1.1, LEONIDA_HW_RT=1), in place of # -RayTracing. The ray-tracing shaders are translated again the first time. # -Resolution the older path: the game renders at this height (2160, 1440, 1080, 720, 540 or 480) and the # title's own upscaler does the rest, without DLSS. The play-S-*.ps1 and play-X-*.ps1 scripts use it. # -Lowest as -Resolution, but the title's own dynamic resolution picks the height as on the console, from # this one (1440, 1080, 720, 540 or 480) up to its output's (Series X at 1440 or fewer: 1440 of a # 2560x1440 output), by how long its frames take (LEONIDA_RENDER_SCALE_MIN, the loader's hooks.rs). # Series X, same save, RTX 4060 Ti, frame generation off (2026-11-29): -Lowest 1080 57.0 and 59.6 ms # a frame (median, two series) against 66.0 and 67.9 at -Resolution 1440; the frames sat at 1080. # -Adapter on a PC with more than one card, the one to use: part of its name (-Adapter 5060) or its index # (-Adapter '#1'). Default: Windows' default card. # -Build target\diag (the default, the build all measurements are of) or target\release # -DlssDir the folder with nvngx_dlss.dll, if not nvidia-sdk\DLSS\lib\Windows_x86_64\rel # -StreamlineDir the folder with sl.interposer.dll (frame generation), if not nvidia-sdk\Streamline\bin\x64 # -NoPrecompile start at once. By default every shader of the title is translated into the cache and the # pipelines earlier runs drew with are made before the title starts (minutes the first time # and after a change of the layer, seconds otherwise), so that the world does not come up # half drawn or stall while they are made. # -PrecompileAll every pipeline the title has created in earlier runs, not only those drawn with (as foxhound's # launcher): fewer stalls in new places; an hour or more and gigabytes the first time. # -Log the layer's log goes to a file in %LOCALAPPDATA%\Leonida\logs instead of this window # -Capture F9 in the game saves that frame and the pictures it drew, in %LOCALAPPDATA%\Leonida\captures # -WindowsBarMB maximum MiB of title memory windows in CPU-mapped VRAM, which needs resizable BAR (by default # 3072 on PCs with under 48 GB of RAM, unless the card has under 6 GB, else 0; -WindowsBarMB 0 turns it off). # -More other settings: -More @{LEONIDA_PANEL='1'} # -PcGlyphs a folder of your own pictures for the keyboard-and-mouse button prompts (docs/prompt_glyphs.md) # instead of the built-in key caps # -DryRun prints the settings this start would run with (after the F1 menu's saved ones) and stops: nothing # is built or started # Run it from a normal window, not as administrator: the driver then keeps its shader cache elsewhere. param( [Parameter(Mandatory)][string]$Exe, [switch]$NoSmoothMotion, [switch]$NoDlss, [switch]$SeriesX, [switch]$Quality, [switch]$RayTracing, [switch]$HardwareRT, [ValidateSet('2160', '1440', '1080', '720', '540', '480')][string]$Resolution, [ValidateSet('1440', '1080', '720', '540', '480')][string]$Lowest, [ValidateSet('quality', 'balanced', 'performance', 'ultra')][string]$Dlss, [ValidateRange(2, 6)][int]$FrameGen, [switch]$NoFrameGen, [switch]$MotionBlur, [switch]$FsrFrameGen, [string]$FidelityFxDir, [switch]$Fullscreen, [ValidatePattern('^(auto|\d+(\.\d+)?([:x/]\d+(\.\d+)?)?)$')][string]$Aspect, [ValidateSet('fit', 'stretch')][string]$PresentScale, [string]$Adapter, [ValidateSet('diag', 'release')][string]$Build = 'diag', [string]$DlssDir, [string]$StreamlineDir, [switch]$NoPrecompile, [switch]$PrecompileAll, [switch]$Log, [switch]$Capture, [hashtable]$More = @{}, [string]$PcGlyphs, [uint32]$WindowsBarMB, [switch]$DryRun, # The switches the user typed, by this script's names, when another script starts this one with switches of its # own (scripts\play-d3d12.ps1's Series X default): they win over the F1 menu's saved values. Unset: this start's. [string[]]$Typed, # Set by the F1 menu's SAVE AND RESTART: the switches are the last start's again, so the menu's values win. [switch]$MenuRestart ) $root = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path if (-not (Test-Path $Exe)) { Write-Host "No $Exe."; return } if ($Dlss -and ($Resolution -or $Lowest)) { Write-Host '-Dlss sets the render height by its mode: leave -Resolution and -Lowest out with it.'; return } if ($Resolution -and $Lowest) { Write-Host '-Resolution holds one height, -Lowest lets the title pick from a lowest one: one or the other.'; return } if ($Dlss -and $NoDlss) { Write-Host '-Dlss and -NoDlss: one or the other.'; return } $Exe = (Resolve-Path $Exe).Path # NVIDIA's own files: where they are (Get-NVIDIA-DLSS.cmd puts them in nvidia-sdk\). Nothing is downloaded here. if (-not $DlssDir) { $DlssDir = $env:LEONIDA_DLSS_DIR } if (-not $StreamlineDir) { $StreamlineDir = $env:LEONIDA_STREAMLINE_DIR } $sdkDlss = Join-Path $root 'nvidia-sdk\DLSS' $sdkDlssLib = Join-Path $sdkDlss 'lib\Windows_x86_64\x64\nvsdk_ngx_d.lib' $sdkStreamline = Join-Path $root 'nvidia-sdk\Streamline\bin\x64' # DLSS by default on Series S; on Series X when -Dlss or -FrameGen asks for it. $wantDlss = -not $NoDlss -and -not $Resolution -and -not $Lowest -and (-not $SeriesX -or $Dlss -or $FrameGen) if (-not $DlssDir -and (Test-Path (Join-Path $sdkDlss 'lib\Windows_x86_64\rel\nvngx_dlss.dll'))) { $DlssDir = Join-Path $sdkDlss 'lib\Windows_x86_64\rel' } if (-not $StreamlineDir -and (Test-Path (Join-Path $sdkStreamline 'sl.interposer.dll'))) { $StreamlineDir = $sdkStreamline } if ($wantDlss -and -not $DlssDir) { Write-Host 'No DLSS files here: the picture is stretched to the screen instead. Get-NVIDIA-DLSS.cmd (in the' Write-Host "repository's folder) fetches them from NVIDIA once, about 70 MB, with frame generation's." } # The build: made here if there is none, and made again with DLSS once its SDK is there (the diag build only), # whatever this start's switches ask for: the F1 menu's saved settings are read further down, and a DLSS choice saved # there stands behind a replayed -Resolution too. Asked for only when the switches wanted DLSS, that build was never # made for such a start, which fell back from DLSS every time (D3D12-F1-DLSS-REBUILD). -NoDlss: not for this start. $leonida = Join-Path $root "target\$Build\leonida.exe" $built = Join-Path $root "target\$Build\built-with.txt" $hasDlss = (Test-Path $built) -and ((Get-Content $built -Raw) -match 'dlss') $canDlss = -not $NoDlss -and (Test-Path $sdkDlssLib) # A build noted as made without DLSS, and the SDK here: it is made again. $stale = $Build -eq 'diag' -and $canDlss -and -not $hasDlss -and (Test-Path $built) $noCargo = -not (Get-Command cargo -ErrorAction SilentlyContinue) if ($stale -and $noCargo -and (Test-Path $leonida)) { # The build that is here still runs: only DLSS waits for cargo. Write-Host "NVIDIA's SDK is here, but there is no cargo to build the layer again with DLSS (README.md): the build that is here runs." } elseif ($stale -and $DryRun -and -not $noCargo) { # Nothing is built in a dry run: it says what a start does first, and prints the settings of the start after it. Write-Host "NVIDIA's SDK is here: a start builds the layer again with DLSS first." $hasDlss = $true } elseif (-not $DryRun -and $Build -eq 'diag' -and (-not (Test-Path $leonida) -or $stale)) { if ($noCargo) { Write-Host 'No build and no cargo: install Rust (README.md), then start this again.'; return } Write-Host 'Building the layer (a few minutes the first time) ...' & (Join-Path $PSScriptRoot 'build-nvidia.ps1') $hasDlss = (Test-Path $built) -and ((Get-Content $built -Raw) -match 'dlss') } if (-not $DryRun -and -not (Test-Path $leonida)) { Write-Host "No $leonida. Build it first (scripts\build-nvidia.ps1)."; return } # Windows 10's own Direct3D 12 stops at shader model 6.5 and refuses every translated pipeline (6.6): there the # exe needs Microsoft's newer runtime beside it, which it asks Windows for (apps\leonida\src\agility.rs). # Nothing is downloaded here: Get-D3D12.cmd fetches it once. $windowsBuild = [int](Get-CimInstance Win32_OperatingSystem).BuildNumber $agility = Join-Path (Split-Path $leonida) 'D3D12\D3D12Core.dll' if ($windowsBuild -lt 22000 -and -not (Test-Path $agility)) { Write-Host "Windows 10 (build $windowsBuild): its own Direct3D 12 refuses the game's shaders (shader model 6.6)." Write-Host "Get-D3D12.cmd in the d3d12 folder fetches Microsoft's newer runtime (about 22 MB, from nuget.org) into" Write-Host "$(Split-Path $agility); then start this again." if (-not $DryRun) { return } } # A build nobody noted the making of (cargo by hand) is taken at its word: with DLSS if the files are there. # $dlssCan: DLSS can run (its files and a build with it), whoever asks for it: this start, or the F1 menu later. $dlssCan = -not $NoDlss -and $DlssDir -and ($hasDlss -or -not (Test-Path $built)) $dlssOn = $wantDlss -and $dlssCan $settings = @{ # The play set. Textures are waited for: one loaded once at the start could stay empty for the run otherwise. LEONIDA_TEXTURE_NO_WAIT = '0'; LEONIDA_RELAY = '2'; LEONIDA_CARD_STEPS = '2' LEONIDA_WIDE_BACK = '1'; LEONIDA_CARD_REHASH_RUNS = '1' LEONIDA_JOIN_COPIES = '1'; LEONIDA_INDIRECT_WINDOW = '1'; LEONIDA_RELAY_COPY = '1' # Copy-backs caught half-written are fetched again (torn.rs). LEONIDA_FETCH_CHECK = '1' # Leonida: an indirect batch stays open past a program only if all it can store goes through views its bind # declares, and a record one was bound to since the batch's pass is clamped again behind it (INDIRECT_BATCH=4; # 1 ended a batch at every storing program; 2, ending only at waits and draws, clamped the culling passes' # arguments before they were written: the sea's surface missing for a frame). Waterside save, 1440p, RTX 4060 Ti # (2026-11-28), in turns of 4 s against 1: standing -2.15 ms a frame (+-0.39, of 60 to 82; 2: -3.77), walking # -1.6 (+-1.6); 900 to 1,000 batch passes a frame against 1,150. No sea fault found in 1,116 recorded frames. LEONIDA_INDIRECT_BATCH = '4'; LEONIDA_MAP_THREADS = '1'; LEONIDA_TITLE_PRIORITIES = '0' # Leonida: renderer port #6, the guards' lock shared by the title's write faults, a block's claim for what # changes it (watch.rs). The title's threads waited 76 ms a frame in all for that lock, 337 times, the submitting # thread and the heap sync holding it (run d43, timeline d46). In turns of 4 s standing (runs d50, 147 phases): # the frame's median -0.47 +-0.18 ms, the submitting thread -0.58 +-0.11; the card 0.52 busier, as it is fed sooner. LEONIDA_PORT_GUARD = '1' # Leonida: the card is not kept awake between submissions (it was '1': a small compute loop that keeps the # card's clocks up while it stands idle between submissions, host\awake.rs). Switched in turns of 4 s (LEONIDA_AB) # from one save, Series X, RTX 4060 Ti, Ryzen 5 7600X (2026-11-28), the frame with the loop against without: # standing at 1440 lines +2.1 ms (+-0.3, of 72), standing at 1080 lines +0.4 to +0.6 (+-0.3, of 66), walking and # turning at 1440 lines +0.7 (+-1.2) and +1.8 (+-1.8, of 83 to 87). The card is 86 to 99 % busy in all of them: # there is no idle card to keep awake, and the loop takes its share of a busy one. What is given up: where the # card does stand idle for half of a frame (a faster card behind the same processor) the driver lowers its # clocks and the next submission starts slow (a captured frame of 30 ms took 38 to 40 with waits between its # submissions). '1' in -More: kept awake, as before. LEONIDA_CARD_AWAKE = '0' # Leonida: a store of the title's that faults on a guarded block is done beside the guard (through our own view # of the page) and the block stays read-only, instead of two changes of protection for it (titlewrite.rs; a # store that is not understood, or a block's fifth, opens the block as before). The same save and PC, in turns # of 4 s: standing at 1440 lines -0.6 ms (+-0.3; means -0.9), standing at 1080 lines -2.4 (+-0.3; means -2.2), # walking and turning at 1440 lines -1.9 (+-0.9), -0.9 (+-1.6) and -1.6 (+-1.5) in three runs. 1.4 to 1.7 million # stores a run done so and 56,000 to 75,000 not understood (those open the block); no "title memory not written" # in any run; every frame of the standard moves saved both ways (553 and 571 frames): the frames the scan flags # with it (6 against 2) are a fast turn past a white house and the sky, with nothing missing in them. # '0' in -More: every faulting store opens its block, as before. LEONIDA_STORE_BESIDE = '1' # Leonida: the copy behind an aliased view (an R9G9B9E5 view the title places in an R32_UINT texture shaders # write: 86 copies, 390 MiB a frame) goes from texture to texture, not through a buffer: the same texels, moved # once. Standing at one save, Series X, 1440p, RTX 4060 Ti (2026-11-28): the copies 3.6 -> 1.9 ms of a timing # run's frame; switched in turns of 4 s (LEONIDA_AB) the frame is 2.6 ms shorter with it (+-0.9, of 78); every # frame of the standard moves saved both ways shows the same picture (513 and 547 frames). LEONIDA_ALIAS_DIRECT = '1' # Leonida: the sun's tiled cascade shadows (CS_ShadowRenderTiledCascadesCB and ...AlphaCB) in the paired form # (one host wave of 32 threads for a console wave of 64, no group barriers) instead of the form the chain gives # them (without skips, scalars followed: exact, with group barriers). Same place and card: their two lines of a # timing run 2.5 -> 1.2 to 1.6 ms together (two runs each way); left out in turns of 3.5 s they are 2.9 ms of # the frame as they were (+-0.6) and 1.3 ms paired (+-0.5); the shadows on the deck, the fence and the player # look the same in every frame of the standard moves (526 frames, in daylight). Only those two programs are # translated again. The decals' tile classification 1f1fbd86759b3da2 too since 2026-11-28: the paired form takes # it from 2.9 ms to 0.03 (timing runs; 2.3 ms of the frame to nothing when left out in turns). Compared with # projected decals: at the waterside save the decals in view are the player's (grime on arms and shirt; left out # by turns in one view, run ds, they go); in a start with the paired form they are there as without it, nothing # blocky, and the standard moves of a start each way show the same 6 one-frame blips (runs pf0, pf1). # Since 2026-11-29 also the programs the chain gave an approximate form (each half-wave its own results, what the # console computes once for its whole wave; docs/findings.md): the four opaque temporal resolves # (CS_TemporalResolve*Opaque*: 0ffd3b911e35e7d0, 71883e40620a567a, 3c9d23fa83d63d43, 4031c6c05fa7ec48), the sun's # shadow masks (CS_GenerateShadowMasks bc76c37f9fa3672b and _HairOnly 0a5ecfee6b79e13b) and the lights' clusters # (CS_ClusterLightsWorldSpace d3e5b737ea7cc150 and ...IntensityBased 55d2bce91ec9abcc, each half of a cell given # half of the lights). Two recorded tours of one build from the same save, these approximate against paired # (runs d33, d34): in sunlight the player's cap, light grey with a dark brim, came out black as if in shadow in # the approximate form, and lit in the paired one; indoors both were alike. # And the other 22 the chain gave an approximate form (docs/findings.md, "Forms of ..."): what shades where no ray # hit and the irradiance cache, the shader bins, the shadow tiles' classification and screen-space rays, the # volumetrics' resolve, the gathers and mip scans, the projected decals' vectorized resolve and the fire's. Timing # runs of one build, these 11 against all 33 (run d39): the frames alike, the named programs' card time 2.31 ms a # frame against 1.98 (CS_ProjDecalResolve_Vectorized c4183d3cbee28e8e 0.46 against 0.07); no removed device; and a # recorded tour each way (runs d37, d38) with nothing broken in either. # And the decal heap's relocations with the five programs that move its blocks (voidopcode/vilocity add4873): # CS_DefragHeap_ComputeRelocations 02384a60fda6f2d0, dropped every frame before (two console waves that meet only # at barriers each passes once), and CS_RelocateVfxStartIndexLocation 339d476c267c03c7, its Alt 39998898c90889b2, # CS_DefragHeap_Defrag c042a10ed3428758, _RelocateAllocations c85cb6bc1cd8e2ad and _PostDefrag c80d02ddc38ef279, # which copy overlapping blocks of 1 KB a pass: in 32-lane halves one half stored over what the other had not read # yet (white blotches there). Named, they take the paired form before their own translation. # And two particle programs dropped in every run since the first (5e3dd99e0f067aee, 57f1b81de55c2842: one console # wave whose lane branches hold LDS reads and writes, which no other form takes): the paired form takes them since # it lowers ds_write2st64_b32 and the atomics with the old value back (60 and 71 branches taken wave-wide). # And the other three model emitters of the same kind (particles from a character's body; voidopcode/vilocity # 324fe01 and 4244b51, issue 17, GPL-3.0): GpuParticleEmit CS_Emit_Dynamic_Model_Skinned ae0deeafe219c15c, # _AttachMesh 407eca669212d400 and CS_Emit_Dynamic_Model 18d957e62926ed3e. Translated alone here (leonida # translate --warm, a host of 32-lane waves) none of the three translates as it is (an LDS read and write in one # lane-branch region of a 64-thread group) and all three do paired (41 and 69 branches taken wave-wide). LEONIDA_PAIRED_FOR = 'ae0deeafe219c15c,407eca669212d400,18d957e62926ed3e,5e3dd99e0f067aee,57f1b81de55c2842,02384a60fda6f2d0,339d476c267c03c7,39998898c90889b2,c042a10ed3428758,c85cb6bc1cd8e2ad,c80d02ddc38ef279,be6ce5d849d51127,922e1d0ee1e19a85,1f1fbd86759b3da2,0ffd3b911e35e7d0,71883e40620a567a,3c9d23fa83d63d43,4031c6c05fa7ec48,bc76c37f9fa3672b,0a5ecfee6b79e13b,d3e5b737ea7cc150,55d2bce91ec9abcc,f8f712930c606707,40bc5fd052acfdf4,294e7cdd91ebd1f1,b7953a05b189dfc1,a53a7977fe762268,be14e72d86362031,0a5d4f9047b3dce4,8dd8d739047fe557,12b0005a30bc18a9,2620618869072a85,eb9a057a81d18c42,89ed0b981f99573c,b2711644ca5566cc,0903802745985664,ce2378e5e8711aad,136986812880cead,3c196d81eca7ff15,acf14a70f37fb012,f79824724d8e2daf,f0aa2b1e79275592,c4183d3cbee28e8e,2e92491c2ae5472b' # Leonida: asks for memory outside buffers remembered per thread (shadow.rs quick_windows). Series X, RX 6800, # two sessions played from a new game (2026-11-29, runs ab-02 and ab-03, LEONIDA_AB in turns of 4 s, 222 and 215 # world phases): the frame -2.4 ms (+-1.5) and -0.9 ms (+-1.0) median, -2.0 (+-1.7) and -2.5 (+-1.4) mean, of 61-68. # (LEONIDA_AHEAD_SPLIT, the list ahead of each frame recorded by two threads, cut the submitting thread's wait for # it 7.6 -> 4.7 ms but not the frame: -1.6 (+-1.3) and +0.8 (+-1.1) ms median in the same runs. Left off.) LEONIDA_QUICK_FIND_WINDOWS = '1' # Leonida: renderer port 2 (port_descriptors.rs): the title's descriptor stores tell which slots they wrote, in # place of a look at every slot of every changed heap page. Series X, RX 6800, the boat mission from a new game # (2026-11-29, run ab-04, LEONIDA_AB in turns of 4 s, 106 world phases): the frame -3.4 ms (+-1.4) median, -3.9 # (+-1.7) mean, -6.0 (+-3.3) p90, of 63-69. Its fallback made 7,528 view records no store told of (about one a # frame; writers outside the title's image), the player saw no flicker and no black textures. LEONIDA_PORT_DESCRIPTORS = '1' # Leonida: a title copy or placed write in a submission's steps forgets only the copies refreshed ahead that it # touches (host.rs title_written_at), not all of them. Series X, RX 6800, from a new game (2026-11-29, run ab-06, # LEONIDA_AB in turns of 4 s, 185 world phases): the frame -2.2 ms (+-1.0) median, -2.5 (+-1.2) mean, -3.4 (+-2.4) # p90, of 59-62; about 13 scoped forgettings a frame kept ~1,600 copies, none fell back to forgetting all. # (In the same run LEONIDA_REFRESH_NEXT, the next submission's front spans refreshed early by helpers, found # ~24 spans and no bytes to copy and cost +1.2 ms (+-0.7); LEONIDA_WIDE_SPIN=30 -0.6 (+-1.8). Both left off.) LEONIDA_COPY_SCOPED = '1' # Keep the buffer range covered by each host copy up to date as its heap slots change. # Series X, RX 6800 (2026-11-30): ab-22, 130 walking phases, 63 pairs, frame median -4.8 ms, # mean -4.7, p90 -6.0. In ab-21, 49 moving road phases, 20 pairs, median -3.7, mean -4.2, p90 -6.6. LEONIDA_INDEX_HEAP_SPANS = '1' # Leonida: the list ahead of each frame recorded by two threads (above: left off on the RX 6800). Series X, RTX # 4060 Ti, Ryzen 5 7600X, standing (2026-11-30, runs whab1 and whab2, LEONIDA_AB in turns of 4 s with three other # helper switches, 77 world phases each): the frame -0.22 (+-0.29) and -0.73 (+-0.39) ms median, -0.65 (+-0.40) and # -0.66 (+-0.46) mean. The wider views' and records' pools did nothing there, half the processors refreshing copies # made the frame slower (+0.84 and +1.24 ms): left as they are. LEONIDA_AHEAD_SPLIT = '1' # Leonida: the light stand-in stays on while the rays are off (below). Off, with every ray missing, shade went # black and the sky white (run n1, 453 frames); on, the same view is lit as on the console. What the title left # is kept up to 2 times the estimate (ambient.rs). # Device-removed data: the faulting address only. The breadcrumbs of 'light' kept the card 89% busy against 83% # for 'faults' at the same frame time (runs d35, two pairs standing, frame generation on); 'light' is for a # removed device that needs the command it stopped at. LEONIDA_SHOW_AFTER = '1'; LEONIDA_AMBIENT = '0.8'; LEONIDA_AMBIENT_MOST = '2'; LEONIDA_D3D12_DRED = 'faults' LEONIDA_THIN = '1'; LEONIDA_JOIN_PARTS = '8'; LEONIDA_UPLOAD_AHEAD = '1' # Leonida: six threads translate the title's lists, not eight (list\thin.rs). The eight stood idle 39 % of their # time while the title's threads waited for a core on the frame's chain (3.2 ms a frame "woken, not running yet"). # Two of the eight parked by turns of 4 s (LEONIDA_THIN_PARK), standing at one save, Series X, 1440p, RTX 4060 Ti, # Ryzen 5 7600X (2026-11-29), two runs: the frame's median -0.83 ms (+-0.16) and -0.94 (+-0.52), the submitting # thread -0.49 (+-0.12) and -0.74 (+-0.62). '8' in -More: eight, as before. LEONIDA_THIN_THREADS = '6' # Leonida: a texture whose bytes hashed the same four turns running is hashed one turn in 16 (texture.rs). By # turns of 4 s standing, same PC and save (2026-11-29, runs d118): the frame's median -1.67 (+-0.81) and -0.76 # (+-0.82) ms, the submitting thread -2.88 (+-0.50) and -2.62 (+-0.49); a tour with it on (d121) showed no texture # late or wrong. '0' in -More: every texture hashed every turn, as before. LEONIDA_TEXTURE_HASH_BACKOFF = '1' # Fog bounded by 1.5 times the light around; a NaN a shader writes is made 0 before blur and the upscaler spread it. LEONIDA_AMBIENT_AIR = '1.5'; LEONIDA_NAN_SCRUB = '1' # Leonida: reflections no brighter than half the room's light (ambient.rs, after CS_UpdateHistory). Without rays # every glossy texel holds the sky of its missed ray: eyes glowed white and wooden floors indoors had an oily white # sheen with dark streaks. With 0.5 they are wood and eyes again, and outdoors the water and sky look the same # (Jason's house, guard on and off by turns of 3 s in one run, rf2-rab1/rab2, 2026-11-28). It only ran since the # guard follows the indirect dispatch the title uses for that program (draw.rs). LEONIDA_REFLECT_MOST = '0.5' # Leonida: the light of glass, particles and the dust in a room's air no more than 4 times the light around # (ambient.rs, after CS_SpatialFilterAlpha; KyleS98/VIctory-Neo a6e85c6). Without rays the title's volume for it # holds the open sky everywhere: white specks all over every room. Inside Jason's house, on and off by turns of 3 s # while standing (run lv1-live, 2026-11-28): specks everywhere without it, none with it, nothing else changed; on # the balcony the same either way (al1-aab1..3). LEONIDA_AMBIENT_ALPHA = '4' # Leonida: the samplers the tonemap's programs (PS_Composite*) carry in their code filter linearly where they # would point-sample. Without it the colour grading came out in bands (a 2000s camera look): the tonemap reads # its 33^3 identity grading tables at a log-encoded colour, and read unfiltered they hand back 33 steps over 14 # stops, about five flat levels per doubling of brightness (runs p3, p4, c1: 700-1,400 colours in a sky region; # run s1 with every program's made linear: 28,000-32,000). What read them unfiltered was a pipeline restored # from the pipeline library with another run's sampler places; such pipelines are kept by those places since, # or left to the driver (pipeline/places.rs), so this is a second guard for the tonemap alone. # It was '1' (every program) until 2026-11-27. The title point-samples on purpose in 1,468 of its program names: # the pass that puts the low-resolution fog on the picture picks its four texels by depth one by one, and read # linearly each of them is a mix across the silhouette (pipeline/host.rs LinearScope; the expected cause of the # light rim around trees, wires and signs in fog, not confirmed in a run yet). -More # @{LEONIDA_STATIC_SAMPLERS_LINEAR='1'} is the setting from before, '0' none at all. LEONIDA_STATIC_SAMPLERS_LINEAR = 'PS_Composite' # Pixel programs keep the console's early depth test (emit/mod.rs): transparent surfaces behind a wall no # longer write depth and motion for the wall's pixels. On since 2026-11-27 (a start with it: the picture as # before at the dock; the glass door's squares not looked at yet). '0' in -More: the late test, as before. LEONIDA_EARLY_DEPTH = '1' # A copy at its place in a list into bytes no shader wrote lately is the title's own: what reads it in the same # submission does not wait for every flight to land (host.rs, placed_is_titles). '0' in -More: waited for. LEONIDA_PLACED_TITLE = '1' # Wait for new shaders rather than skip their draws (each pipeline is waited for at most once). The F1 menu's # SHADER WAIT MS changes it: 0 never waits, things then show up as their shaders are done. LEONIDA_PIPELINE_WAIT_MS = '10000' # NVIDIA caps the shader-visible view heap at 1,000,000: without more dynamic slots thousands of draws a frame # are dropped (descriptor/host.rs dynamic_slots). LEONIDA_DYNAMIC_SLOTS = '524288' # Memory compares on the card instead of the CPU. # Leonida: every title buffer of 64 KiB and more gets its copy in the card's memory (not only those of 1 MiB and # more): the frame is GPU-bound, and shaders read the small ones over the bus otherwise. Static scene, Series X # 1440p: 120.7 -> 94.7 ms a frame, the card's time 64.1 -> 33.9 ms (2026-11-27, two runs each way). LEONIDA_CARD_BUFFERS_MIN_MB = '1'; LEONIDA_CARD_BUFFERS_MIN_KB = '64'; LEONIDA_CARD_BUFFERS_MB = '1536' # Leonida: a small fill of upload memory the title wrote itself goes on without waiting for the flights whose # shaders are declared to write around it (host.rs fill_is_titles). Each such wait emptied the pipeline, about # 75 ms, every few frames. A/B over moves, 7 phases of 30 s each way (2026-11-27): mean 116.8 -> 104.9 ms, median # 112.3 -> 102.3, p90 158 -> 130; waits behind placed copies 266 -> 5. The standard moves captured with it on: # 227 frames, none with a one-frame dip or spike, lighting as before (run x34). LEONIDA_FILL_TITLE = '1' # Leonida: what shaders write into host copies of memory the title asked for write-combined (1 MiB and more) is # not copied back into title memory: the title does not read such memory on the CPU (after trustno1-coder/ # VIctory-NVIDIA 50c15a1 and 2f81d0c, GPL-3.0). Standing at the save, A/B of 20 s phases, three of each of 8 # combinations (2026-11-27): median 91.0 -> 80.2-82.5 ms a frame; pieces landed a frame 1,416 -> 341, their # pages with a new byte 41 -> 6.6 MB, "copying back" 30-40 -> 10-12 ms. The standard moves captured with it on: # 338 frames, one with a one-frame dip or spike, the picture as before (run x36). LEONIDA_WC_NO_BACK = '1' # Leonida: the diag build's walk of the whole address space for its "memory map" log line is left out of play: # 285,000 regions asked of Windows one by one took a thread 1.06 s every 30 s (2026-11-27), beside the title's # own mapping calls. -More @{LEONIDA_MEMORY_MAP='1'} has the line again. LEONIDA_MEMORY_MAP = '0' # Leonida: the title's physical pages come in sections of 16 MiB, not one section for each allocation of # gigabytes: unmapping and mapping a page of a small section is far cheaper for Windows (after Trex/Dolores # e5e7120 and El1xr's section_mb.rs, GPL-3.0, which measured the unmap at 99-182 -> 3-11 us). Walking and turning # from one save, 4 minutes each (2026-11-28, RTX 4060 Ti): mean 111.6 -> 94.4 ms a frame, median 105.1 -> 91.7, # p90 139.3 -> 113.9; title memory held for mapping changes 43.2 -> 8.9 ms a frame, the mapping thread 46.2 -> # 20.7. Sections of 2 MiB measured the same (91.7, 91.8, 111.4). '0' in -More: one section, as before. LEONIDA_SECTION_MB = '16' } # The card's own memory, from its driver's key (HardwareInformation.qwMemorySize, 64-bit; Win32_VideoController's # AdapterRAM stops at 4 GB), the largest adapter's; 0 when unknown. $vram = 0 try { Get-ChildItem 'HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}' -ErrorAction Stop | ForEach-Object { $q = (Get-ItemProperty $_.PSPath -Name 'HardwareInformation.qwMemorySize' -ErrorAction SilentlyContinue).'HardwareInformation.qwMemorySize' if ($q -and [uint64]$q -gt $vram) { $vram = [uint64]$q } } } catch { } # Under 6 GB of it (a 4 GB card) the limits above, measured on large cards, are more than the card has: 1536 MiB of # buffer copies and 3 GB of windows on a 3.2 GB budget put 5.5 GB on the card, which the system pages out # (GTX 1050 Ti, 2026-11-28). There the runtime sizes the copies to its budget (`shadow.rs` default_card_limits_mb: # 512 MiB) and no windows go to the card: frames steadier, more textures drawn (eyes on the same scenes, not a capture). $smallCard = $vram -gt 0 -and $vram -lt 6GB if ($smallCard) { $settings.Remove('LEONIDA_CARD_BUFFERS_MB') Write-Host "$([math]::Round($vram / 1GB, 1)) GB of video memory: buffer copies sized by the runtime, no title memory windows in it" } $console = if ($SeriesX) { 'series-x' } else { 'series-s' } # The render scale of each DLSS mode (rendered lines over output lines; the layer picks DLSS's own mode by it). $dlssScale = @{ quality = '0.6667'; balanced = '0.6'; performance = '0.5'; ultra = '0.3333' } if ($DlssDir) { $settings.LEONIDA_DLSS_DIR = $DlssDir } if ($Resolution -or $Lowest) { # The older path: a render scale and the title's own upscaler (rendered height over output height). -Lowest sets # the lowest scale of the title's own dynamic resolution instead, which picks the scale above it by itself. $height = if ($Resolution) { $Resolution } else { $Lowest } $outHeight = if ($SeriesX) { 2160 } else { 1080 } # Series X at 1440 lines or fewer: the title's own output is 2560x1440 (LEONIDA_OUTPUT, the loader's hooks.rs), # not 3840x2160 shrunk into the window afterwards. The frame takes as long (it is not the pixels': 2026-11-27), # the picture was the same in the runs of that day, and the card and the PC hold about 1.5 GB less. # -More @{LEONIDA_OUTPUT='3840x2160'} is the 4K output as before. if ($SeriesX -and [int]$height -le 1440 -and -not $More.ContainsKey('LEONIDA_OUTPUT')) { $settings.LEONIDA_OUTPUT = '2560x1440' $outHeight = 1440 } if ([int]$height -gt $outHeight) { Write-Host "That console outputs ${outHeight}p: ${height}p is above it."; return } $scale = ([int]$height / $outHeight).ToString('0.####', [Globalization.CultureInfo]::InvariantCulture) if ($Resolution) { $settings.LEONIDA_RENDER_SCALE = $scale } else { $settings.LEONIDA_RENDER_SCALE_MIN = $scale } $settings.LEONIDA_OWN_UPSCALER = '1' } elseif ($dlssOn) { $settings.LEONIDA_UPSCALE = 'dlss' # Series S renders 2/3 of its output by itself: quality needs no scale there. Series X renders 1.0 through # FidelityFX unless told (the scale is set below, quality if no mode was given). if ($Dlss -and ($SeriesX -or $Dlss -ne 'quality')) { $settings.LEONIDA_RENDER_SCALE = $dlssScale[$Dlss] } } elseif (-not $SeriesX) { $settings.LEONIDA_UPSCALE = 'stretch' if ($Dlss -and $Dlss -ne 'quality') { $settings.LEONIDA_RENDER_SCALE = $dlssScale[$Dlss] } } if ($Dlss -and -not $dlssOn) { Write-Host "-Dlss ${Dlss}: no DLSS here (its files, or a build with it): the title's picture is not made by DLSS." } if ($FrameGen) { $settings.LEONIDA_FRAME_GEN = "$FrameGen" } if ($FsrFrameGen) { $settings.LEONIDA_FSR_FRAMEGEN = '1' } # Leonida: DLSS frame generation twice the frames shown by default on cards that make it (RTX 40 and 50) when its # Streamline files are here and the title upscales by itself (-Resolution: its depth and motion vectors are the # G-buffer pass's, fg.rs). Series X at -Resolution 1080 on an RTX 4060 Ti (2026-11-28): 15 frames rendered, 29 # shown. It generates only while the game's window has the focus. -NoFrameGen leaves it off (Smooth Motion then). if (-not $FrameGen -and -not $NoFrameGen -and ($Resolution -or $Lowest) -and -not $RayTracing -and $StreamlineDir) { $card = try { (Get-CimInstance Win32_VideoController -ErrorAction Stop | ForEach-Object { $_.Name }) -join ';' } catch { '' } if ($card -match 'RTX\s*(40|50)\d\d') { $settings.LEONIDA_FRAME_GEN = '2' # Reflex holds the frames shown to 28 a second (14 rendered, 71.4 ms apart), so that the made frames fall # evenly between the rendered ones (fg.rs, limit_us). Same save, 1080 lines, RTX 4060 Ti (2026-11-28): rendered # frames 70.6 ms mean, 68.8 median, 76.6 p90 without it; 72.5, 71.4, 76.7 with 28 (the spread of a phase's # p90 over its median 7.8 -> 5.3 ms); 26 cost two shown frames a second for no more evenness. Again at the # launcher's default of 2026-11-29 (the title's dynamic resolution, one start each, standing): rendered # frames 72 to 76 ms median whatever the limit (28: 73.8, 30: 72.3 and 76.4, 32: 66.8 and 71.6, none: 74.4; # the start's view, 10,700 to 11,900 draws, decides it), the card 90 to 96 % busy; the p90 3.2 ms over the # median with 28 and 4.8 to 10.6 with the others. Frame generation itself costs the card some 8 to 10 ms of # a rendered frame here (57 to 60 ms without it at like draws), so 30 shown is not there yet to hold. # -More @{LEONIDA_FG_LIMIT_FPS='0'}: no limit. $settings.LEONIDA_FG_LIMIT_FPS = '28' } } if ($Fullscreen) { $settings.LEONIDA_FULLSCREEN = '1' } if ($Aspect) { $settings.LEONIDA_ASPECT = $Aspect } if ($PresentScale) { $settings.LEONIDA_PRESENT_SCALE = $PresentScale } if ($StreamlineDir) { $settings.LEONIDA_STREAMLINE_DIR = $StreamlineDir } if ($Quality) { $settings.LEONIDA_RELAY = '1'; $settings.LEONIDA_CARD_STEPS = '0' } if ($HardwareRT) { # A trial: the title's structures are built as DXR structures and its traversal loops become ray queries # (crate::hwrt, emit/rayquery.rs). Its rays light the picture: no stand-in beside them, and the passes left out # without structures run. Loops that are not lifted miss every node by themselves (emit/intersect.rs bvh_miss). $settings.LEONIDA_HW_RT = '1'; $settings.LEONIDA_AMBIENT = '0'; $settings.Remove('LEONIDA_AMBIENT_MOST') $settings.LEONIDA_RT_RESOLVE = '1'; $settings.LEONIDA_ACTIVATE_RAYS = '1' } elseif ($RayTracing) { # The title's own rays light the picture: no stand-in beside them. $settings.LEONIDA_BVH_BUILDER = '1'; $settings.LEONIDA_AMBIENT = '0'; $settings.Remove('LEONIDA_AMBIENT_MOST') } else { # Leonida: ray tracing mostly off, as before the renderer changed. Ray walks end at the root (emit/intersect.rs), # and rt_off_hashes.txt lists the 1,000 CS_RaytracingResolve and 34 traced-shadow shaders, which are skipped: # run with every ray a miss they made rooms white or black and took the card 33-50 ms a frame (about 10 without). # The screen-probe and visibility traces keep running: skipping those too left their outputs as garbage. $settings.LEONIDA_BVH_MISS = '1' # Leonida: the resolve and ray-activation passes run again (every ray a miss), as klbf-lab 64ff6a0 found: with # them skipped, foliage in shade, blinds and the deck at the save showed magenta blocks and stair-stepped bars. # Series X 1440p, the standard moves: magenta 0.00 per mille in 316 frames (bars in every turn before), frames # 60-91 ms, brightness as before (2026-11-27). LEONIDA_SKIP_RT_RESOLVE=1 skips them as before (rt_off_hashes.txt). $settings.LEONIDA_RT_RESOLVE = '1'; $settings.LEONIDA_ACTIVATE_RAYS = '1' $rtList = Join-Path $PSScriptRoot 'rt_off_hashes.txt' if ($env:LEONIDA_SKIP_RT_RESOLVE -eq '1' -and (Test-Path $rtList)) { $settings.LEONIDA_SKIP_PIPELINES = (Get-Content $rtList -Raw).Trim() } } # Leonida: the water's CS_TransmissionVolumetrics program 6f225b641c5b0708 translates since the wave-wide form # (docs/findings.md), but that form puts 115 group barriers in its outer loop (an exchange between the two host # waves of each console wave at every branch on EXEC): one indirect dispatch of it took 76-80 ms of an RTX 4060 Ti's # frame, the next heaviest command 3 ms (GPU timing run, 2026-11-27; frames 180-260 ms against about 95 without it). # Its dispatches were dropped for that. With the paired-lane form (emit/paired.rs, after Vice-Tay 5e588e8: a host # thread runs two console lanes, so the halves never exchange) it has 5 group barriers, none in a loop, and is no # longer among the 40 costliest commands of the timing run (under 0.3 ms a frame), so it runs again. # It was then dropped again until its picture was right: a dark band with a hard horizontal edge and blocky fringes # near water (2026-11-27). Dropped, the water is a dark opaque sheet seen from above and, under it, the scene's # light is lost (black or white, particles only). The blocks were the water's tile list # (CS_TransmissionVolumetrics_GenerateTiles 1aa247ed3653b616) losing tiles on 32-lane hosts, which the translator's # loop convergence on such hosts (LEONIDA_LOOPS_WAVE, on by default) fixed. So the family runs by default again: the # water clear from above, the seagrass and the seabed seen under it, no blocks (RTX 5070, Series X at 1440 lines, # 2026-11-30). LEONIDA_WATER_TRANSMISSION=0 drops the family as before. # The whole family (findings.md): another configuration binds another variant (1440p output with render scale 1.0: # 5dc3b25986622949). $skip = @() # The two opt-outs are kept in $settings too: the window's LEONIDA_* go before the start (below), and the restart # from F1 runs this script again in that environment. if ($env:LEONIDA_WATER_TRANSMISSION -eq '0') { $skip += '6f225b641c5b0708', '5dc3b25986622949', '926c46bab3b86bd6', '6871d6e4b3ac9a10', 'a10179ab7eda0dc3' $settings.LEONIDA_WATER_TRANSMISSION = '0' } # 2889c21328c69e58 and 888af37a584acf98 were counted with that family from cef91163b on because they trip on the same # thing (findings.md), but by the entry points in their containers they are CS_GenerateShadowMasks_SampleHairScreenSpace # and CS_GenerateShadowMasksHairOnly_SampleHairScreenSpace: the sun's shadow mask where hair is sampled on screen. # Dropped, what they would have written keeps an old mask (edsuuu/VI-BR-PORT b120167 saw that as blocky, lit hair # with another program of that pass out). They run; LEONIDA_HAIR_SHADOW_MASKS=0 in the window's environment drops # them as before. if ($env:LEONIDA_HAIR_SHADOW_MASKS -eq '0') { $skip += '2889c21328c69e58', '888af37a584acf98' $settings.LEONIDA_HAIR_SHADOW_MASKS = '0' } if ($skip) { if ($settings.LEONIDA_SKIP_PIPELINES) { $skip = @($settings.LEONIDA_SKIP_PIPELINES) + $skip } $settings.LEONIDA_SKIP_PIPELINES = $skip -join ',' } # Leonida: the title's motion blur is left out unless -MotionBlur: its first pass, the downsample # (CS_MotionBlurDownSample*, four variants), so the later passes find no movement and blur nothing. The blur is # by the movement of one frame: at 12-14 frames a second its smears are twice as long as at the console's 30, and # its tiles show as blocks of an older picture on camera turns (the user's "ghosting" and "blocky glitches"). # Waterside save, camera turns recorded (2026-11-28): with it, smears at the end of every turn (framescan) and # blocky streaks on trees (runs mb, hz1); without it, mbo1/mbo2, no smear in any turn and no stale blocks. Leaving # out a later pass instead pastes stale tiles (PS_MotionBlurLowRes) or keeps old movement (ProcessNeighborhood). # As voidopcode/vilocity a0aa988 (GPL-3.0) found: clean in 670 frames. if (-not $MotionBlur) { $mb = '51e19585b4753814,aaabcd7a8ec90db8,9f3ecb8d133084bf,2a00e6082220d9a5' $settings.LEONIDA_SKIP_PIPELINES = if ($settings.LEONIDA_SKIP_PIPELINES) { "$($settings.LEONIDA_SKIP_PIPELINES),$mb" } else { $mb } } if ($Adapter) { $settings.LEONIDA_ADAPTER = $Adapter } if ($PSBoundParameters.ContainsKey('WindowsBarMB')) { $settings.LEONIDA_WINDOWS_BAR_MB = $WindowsBarMB.ToString([Globalization.CultureInfo]::InvariantCulture) } else { # Without -WindowsBarMB, PCs with under 48 GB of RAM get 3072 (under 24 GB at first, PR #6). Windows lets a card share at most half # the RAM, and the windows filled that on a 16 GB PC (RTX 3060) about a minute into the world (0x8007000E, then # a driver fault). 32 GB and more never got there, so they keep the runtime default (0, off). # Under 48 GB since 2026-11-27: on a 32 GB PC the layer held 28 GB (19 of it in memory), the PC had 745 MB # free and read 100-200 pages a second from the page file; with the windows in the card's memory it held 24.7 # GB and the PC had 3 GB free. The frame took as long either way. $ram = try { (Get-CimInstance Win32_ComputerSystem -ErrorAction Stop).TotalPhysicalMemory } catch { 0 } if ($ram -gt 0 -and $ram -lt 48GB -and -not $smallCard) { $settings.LEONIDA_WINDOWS_BAR_MB = '3072' # Only a card with GPU upload heaps (resizable BAR, and a Windows and driver that offer it) has that memory; # without them the runtime says so once and the cap does nothing. Write-Host "$([math]::Round($ram / 1GB)) GB of RAM: title memory windows in the card's memory the CPU maps, up to 3 GB, if the card has resizable BAR (-WindowsBarMB 0 turns this off)" } } # What the F1 menu saved (leonida-settings.txt, git-ignored) and the command line: the user's last choice wins, one # setting at a time. A setting a switch typed for this start makes (-Resolution, -SeriesS, -Fullscreen ...: $Typed, # which scripts\play-d3d12.ps1 passes, else this start's own switches) was chosen now: it wins over the menu's, and # the menu file drops that value, so F1 shows and saves the command line's. Every other setting keeps the menu's, which # was chosen after the defaults. A start that the menu's SAVE AND RESTART made (-MenuRestart) replays the switches of # the start before, so there the menu's values win: they were chosen after them. An empty value unsets a setting. # -More wins over the menu like a typed switch. function Read-SettingsFile([string]$path) { $read = [ordered]@{} if (Test-Path $path) { foreach ($line in Get-Content $path) { if ($line -match '^\s*(LEONIDA_[A-Z0-9_]+)\s*=(.*)$') { $read[$Matches[1]] = $Matches[2].Trim() } } } $read } # The settings each switch makes; a switch not listed makes none the menu holds. $switchSettings = @{ SeriesX = 'LEONIDA_MENU_CONSOLE' NoSmoothMotion = 'LEONIDA_MENU_SMOOTH_MOTION' Resolution = 'LEONIDA_RENDER_SCALE', 'LEONIDA_RENDER_SCALE_MIN', 'LEONIDA_OWN_UPSCALER', 'LEONIDA_UPSCALE', 'LEONIDA_FSR_UPSCALER', 'LEONIDA_OUTPUT' Lowest = 'LEONIDA_RENDER_SCALE', 'LEONIDA_RENDER_SCALE_MIN', 'LEONIDA_OWN_UPSCALER', 'LEONIDA_UPSCALE', 'LEONIDA_FSR_UPSCALER', 'LEONIDA_OUTPUT' Dlss = 'LEONIDA_RENDER_SCALE', 'LEONIDA_RENDER_SCALE_MIN', 'LEONIDA_UPSCALE', 'LEONIDA_OWN_UPSCALER', 'LEONIDA_FSR_UPSCALER', 'LEONIDA_OUTPUT' NoDlss = 'LEONIDA_UPSCALE' # DLSS's and FSR 3's frame generation are one choice (never both, below): a typed one replaces the menu's other. FrameGen = 'LEONIDA_FRAME_GEN', 'LEONIDA_FSR_FRAMEGEN' NoFrameGen = 'LEONIDA_FRAME_GEN' FsrFrameGen = 'LEONIDA_FSR_FRAMEGEN', 'LEONIDA_FRAME_GEN' Fullscreen = 'LEONIDA_FULLSCREEN' Aspect = 'LEONIDA_ASPECT' PresentScale = 'LEONIDA_PRESENT_SCALE' Adapter = 'LEONIDA_ADAPTER' RayTracing = 'LEONIDA_BVH_BUILDER', 'LEONIDA_AMBIENT' Quality = 'LEONIDA_RELAY', 'LEONIDA_CARD_STEPS' } $typedNames = if ($PSBoundParameters.ContainsKey('Typed')) { @($Typed) } else { @($PSBoundParameters.Keys) } $chosenNow = @{} if (-not $MenuRestart) { foreach ($name in $typedNames) { # -SeriesS reaches this script as the console's switch, SeriesX. # play-d3d12.ps1's -SeriesS and -SmoothMotion reach this script as SeriesX and NoSmoothMotion. $said = switch ($name) { 'SeriesX' { '-SeriesS/-SeriesX' } 'NoSmoothMotion' { '-SmoothMotion/-NoSmoothMotion' } default { "-$name" } } foreach ($k in @($switchSettings[$name])) { if ($k) { $chosenNow[$k] = $said } } } foreach ($k in $More.Keys) { $chosenNow[$k] = '-More' } } $menuFile = Join-Path $root 'leonida-settings.txt' $smooth = -not $NoSmoothMotion # The menu's console and Smooth Motion lines stand for $console and $smooth here. $fromLine = @{} + $settings $fromLine.LEONIDA_MENU_CONSOLE = $console $fromLine.LEONIDA_MENU_SMOOTH_MOTION = if ($smooth) { '1' } else { '0' } # -More is applied over the settings below; its values are what replaces the menu's. foreach ($k in $More.Keys) { $fromLine[$k] = "$($More[$k])" } $menu = Read-SettingsFile $menuFile $menuRead = $menu.Count $fromMenu = @(); $replaced = @() foreach ($k in @($menu.Keys)) { $v = $menu[$k] if ($chosenNow.ContainsKey($k)) { $now = "$($fromLine[$k])" if ($now -ne $v) { $replaced += "$k $(if ($v) { $v } else { '(unset)' }) -> $(if ($now) { $now } else { '(unset)' }) ($($chosenNow[$k]))" } $menu.Remove($k) continue } $fromMenu += "$k=$(if ($v) { $v } else { '(unset)' })" if ($k -eq 'LEONIDA_MENU_SMOOTH_MOTION') { $smooth = $v -ne '0'; continue } if ($k -eq 'LEONIDA_MENU_CONSOLE') { if ($v) { $console = $v }; continue } if ($v) { $settings[$k] = $v } else { $settings.Remove($k) } } if ($fromMenu) { Write-Host "F1 menu settings (leonida-settings.txt, for what the command line did not set): $($fromMenu -join ', ')" } if ($replaced) { Write-Host "Command line over the F1 menu's saved values: $($replaced -join ', ')" } # The menu file keeps the rest as it was; a value the command line set leaves it. If the file cannot be written, this # start still runs with the command line's values and the file stays whole, so nothing saved is lost. if (-not $DryRun -and $menu.Count -ne $menuRead) { $tmp = "$menuFile.tmp" $wrote = $false try { # CRLF, as the menu writes the file (host/menu.rs). $text = "# Saved by the F1 menu; play.ps1 applies these after its own settings (an empty value: unset).`r`n" + (($menu.Keys | ForEach-Object { "$_=$($menu[$_])`r`n" }) -join '') [IO.File]::WriteAllText($tmp, $text, [Text.UTF8Encoding]::new($false)) $wrote = $true Move-Item -LiteralPath $tmp -Destination $menuFile -Force -ErrorAction Stop } catch { # Only the file this start wrote goes: whatever stood at that name before is left alone. if ($wrote) { Remove-Item -LiteralPath $tmp -ErrorAction SilentlyContinue } Write-Host "The F1 menu file was not updated ($($_.Exception.Message)): this start runs with the command line's values, and the file keeps the menu's." } } # Leonida: the runs write down the pipelines the title creates (pipeline/known.rs), for the precompile below. if (-not $NoPrecompile) { $settings.LEONIDA_PIPELINE_BOOK = '1' } foreach ($k in $More.Keys) { $settings[$k] = $More[$k] } # DLSS only where it can be: a menu choice of it without the files or the build falls back to the stretch # (Series X: to the title's own upscaler, which is sharper than a stretch to 3840x2160). if ($settings.LEONIDA_UPSCALE -eq 'dlss' -and -not $dlssCan) { if ($console -eq 'series-x') { $settings.Remove('LEONIDA_UPSCALE') } else { $settings.LEONIDA_UPSCALE = 'stretch' } } # A saved DLSS choice can replace the game upscaler implied by a fixed resolution on Series S. # Use the stock 720p-to-1080p path, which needs neither the explicit scale nor its FidelityFX size patch. # Leave an explicitly overridden scale alone, even when it equals the stock ratio. if ($console -eq 'series-s' -and $menu['LEONIDA_UPSCALE'] -eq 'dlss' -and $settings.LEONIDA_UPSCALE -eq 'dlss' -and $settings.LEONIDA_OWN_UPSCALER -eq '1' -and $settings.LEONIDA_RENDER_SCALE -eq $dlssScale.quality -and -not $settings.LEONIDA_RENDER_SCALE_MIN -and -not $More.ContainsKey('LEONIDA_RENDER_SCALE') -and (-not $settings.LEONIDA_OUTPUT -or $settings.LEONIDA_OUTPUT -eq '1920x1080') -and -not $menu.Contains('LEONIDA_OWN_UPSCALER') -and -not $More.ContainsKey('LEONIDA_OWN_UPSCALER')) { $settings.Remove('LEONIDA_OWN_UPSCALER') $settings.Remove('LEONIDA_RENDER_SCALE') } # DLSS frame generation and real ray tracing do not work together yet (0.1 frames a second): with ray tracing # on, frame generation is left off and Smooth Motion can do the extra frames. if (($settings.LEONIDA_BVH_BUILDER -eq '1' -or $settings.LEONIDA_HW_RT -eq '1') -and $settings.LEONIDA_FRAME_GEN -and $settings.LEONIDA_FG_WITH_RT -ne '1') { Write-Host 'Ray tracing is on: DLSS frame generation is left off (the two together do not work yet).' $settings.Remove('LEONIDA_FRAME_GEN') } if ($settings.LEONIDA_FRAME_GEN -and -not $StreamlineDir) { Write-Host 'Frame generation needs the Streamline files (Get-NVIDIA-DLSS.cmd): left off.' $settings.Remove('LEONIDA_FRAME_GEN') } # Leonida: AMD's FSR 3 frame generation (-FsrFrameGen, or the F1 menu's FSR 3 FRAME GEN), in place of DLSS's: never # both, and not with ray tracing (as DLSS's). Its DLLs are checked for here; the layer checks their signatures. if ($settings.LEONIDA_FSR_FRAMEGEN -eq '1') { if (-not $FidelityFxDir) { $FidelityFxDir = $env:LEONIDA_FIDELITYFX_DIR } if (-not $FidelityFxDir) { $FidelityFxDir = Join-Path $root 'amd-sdk\FidelityFX\bin' } $fsrFiles = 'amd_fidelityfx_loader_dx12.dll', 'amd_fidelityfx_framegeneration_dx12.dll' | ForEach-Object { Join-Path $FidelityFxDir $_ } if ($fsrFiles | Where-Object { -not (Test-Path $_) }) { Write-Host "FSR 3 frame generation needs AMD's amd_fidelityfx_loader_dx12.dll and amd_fidelityfx_framegeneration_dx12.dll" Write-Host "in $FidelityFxDir (the FidelityFX SDK's bin folder, from AMD's GitHub): left off." $settings.Remove('LEONIDA_FSR_FRAMEGEN') } elseif ($settings.LEONIDA_BVH_BUILDER -eq '1' -and $settings.LEONIDA_FG_WITH_RT -ne '1') { Write-Host 'Ray tracing is on: FSR 3 frame generation is left off (as DLSS frame generation is).' $settings.Remove('LEONIDA_FSR_FRAMEGEN') } else { $settings.LEONIDA_FIDELITYFX_DIR = $FidelityFxDir if ($settings.LEONIDA_FRAME_GEN) { Write-Host 'FSR 3 frame generation asked for: DLSS frame generation is left off (one or the other).' $settings.Remove('LEONIDA_FRAME_GEN') } # Generation's own buffers take 1.5 to 2 GB of the card, which the layer otherwise fills with textures: they # are left a fifth of its budget (VIctory-NVIDIA's play.rs does the same for it), unless a share is set. if (-not $settings.LEONIDA_TEXTURE_ROOM_PERCENT) { $settings.LEONIDA_TEXTURE_ROOM_PERCENT = '80' } } } # Series X: the title upscales with its own upscaler, as passes that hand nothing over. DLSS (or the stretch) # can stand in for its FidelityFX upscale instead, which the title is then made to use (LEONIDA_FSR_UPSCALER, the # loader's hooks.rs): only when -Dlss asks for it, because that path lights nothing yet (the world is black with # the HUD over it, 2026-11-27). Frame generation alone keeps the title's own upscaler: its depth and motion # vectors are the G-buffer pass's (leonida-gpu's fg.rs, LEONIDA_FG_GBUFFER). if ($console -eq 'series-x') { if ($settings.LEONIDA_UPSCALE -eq 'dlss' -and -not $Dlss -and -not $More.ContainsKey('LEONIDA_UPSCALE')) { # Asked for by -FrameGen alone ($wantDlss above), not by -Dlss: the title's own upscaler stays. $settings.Remove('LEONIDA_UPSCALE') if (-not $settings.LEONIDA_RENDER_SCALE) { $settings.LEONIDA_RENDER_SCALE = $dlssScale.quality } $settings.LEONIDA_OWN_UPSCALER = '1' } if ($settings.LEONIDA_UPSCALE -in 'dlss', 'stretch') { Write-Host 'Series X with DLSS: experimental, the world is not lit on this path yet (leave -Dlss out for the picture).' $settings.LEONIDA_FSR_UPSCALER = '1'; $settings.Remove('LEONIDA_OWN_UPSCALER') # Through FidelityFX the title renders 1.0 of its output there: 1440 lines (quality) unless a scale is set. if (-not $settings.LEONIDA_RENDER_SCALE) { $settings.LEONIDA_RENDER_SCALE = $dlssScale.quality } } else { $settings.Remove('LEONIDA_FSR_UPSCALER') } } # Smooth Motion is a second frame generator: off while DLSS frame generation is on. if ($settings.LEONIDA_FRAME_GEN -and $settings.LEONIDA_FRAME_GEN -ne '1') { $smooth = $false } if ($settings.LEONIDA_FSR_FRAMEGEN -eq '1') { $smooth = $false } # For the menu: what it shows as the current values, where it saves, and how it starts the game again. $settings.LEONIDA_MENU_SMOOTH_MOTION = if ($smooth) { '1' } else { '0' } $settings.LEONIDA_MENU_CONSOLE = $console $settings.LEONIDA_MENU_FILE = $menuFile $settings.LEONIDA_MENU_PLAY = $MyInvocation.MyCommand.Path $again = @("-Exe '$($Exe -replace "'", "''")'", "-Build $Build") foreach ($s in 'NoSmoothMotion', 'MotionBlur', 'NoDlss', 'NoFrameGen', 'SeriesX', 'Quality', 'RayTracing', 'HardwareRT', 'FsrFrameGen', 'NoPrecompile', 'PrecompileAll', 'Log', 'Capture', 'Fullscreen') { if ($PSBoundParameters[$s]) { $again += "-$s" } } foreach ($s in 'Resolution', 'Lowest', 'Dlss', 'FrameGen', 'Aspect', 'PresentScale', 'Adapter', 'DlssDir', 'StreamlineDir', 'FidelityFxDir') { if ($PSBoundParameters[$s]) { $again += "-$s '$($PSBoundParameters[$s] -replace "'", "''")'" } } if ($PSBoundParameters.ContainsKey('WindowsBarMB')) { $again += "-WindowsBarMB $WindowsBarMB" } # The menu's SAVE AND RESTART starts this script again with these switches, the ones this start was given (not the # settings they made), and -MenuRestart: the menu's values, saved after these switches were typed, win over them there # (see "What the F1 menu saved" above). Without it a typed -Resolution would undo the scale the menu had just saved. $again += '-MenuRestart' $settings.LEONIDA_MENU_ARGS = $again -join ' ' $scaled = if ($settings.LEONIDA_RENDER_SCALE) { " from render scale $($settings.LEONIDA_RENDER_SCALE)" } else { '' } # With the title's own upscaler forced, DLSS and the stretch are never asked: the title upscales by itself. $own = $settings.LEONIDA_OWN_UPSCALER -and $settings.LEONIDA_OWN_UPSCALER -ne '0' $picture = if ($own -and $settings.LEONIDA_RENDER_SCALE) { "render scale $($settings.LEONIDA_RENDER_SCALE), the title's upscaler" } elseif ($own -and $settings.LEONIDA_RENDER_SCALE_MIN) { "the title's dynamic resolution from render scale $($settings.LEONIDA_RENDER_SCALE_MIN) up, its upscaler" } elseif ($own) { "the title's upscaler" } elseif ($settings.LEONIDA_UPSCALE -eq 'dlss') { "DLSS$scaled" } elseif ($settings.LEONIDA_UPSCALE -eq 'stretch') { "stretched$scaled (no DLSS)" } elseif ($settings.LEONIDA_RENDER_SCALE) { "render scale $($settings.LEONIDA_RENDER_SCALE), the title's upscaler" } else { "the title's upscaler" } $extras = '' if ($settings.LEONIDA_ASPECT) { $extras += ", window $($settings.LEONIDA_ASPECT)" } if ($settings.LEONIDA_FRAME_GEN) { $extras += ", frame generation $($settings.LEONIDA_FRAME_GEN)x" } if ($settings.LEONIDA_FSR_FRAMEGEN -eq '1') { $extras += ', FSR 3 frame generation 2x' } if ($settings.LEONIDA_BVH_BUILDER -eq '1') { $extras += ', ray tracing' } if ($settings.LEONIDA_HW_RT -eq '1') { $extras += ', hardware ray tracing (trial)' } Write-Host "Series $(if ($console -eq 'series-x') { 'X' } else { 'S' }), $picture$extras. F1 in the game: settings." if ($DryRun) { $settings.GetEnumerator() | Sort-Object Name | ForEach-Object { Write-Output "$($_.Name)=$($_.Value)" } return } if ($smooth) { # A copy under the name the NVIDIA App's Smooth Motion profile is set for, refreshed when the build changes. $sm = Join-Path (Split-Path $leonida) 'leonida_sm.exe' if (-not (Test-Path $sm) -or (Get-Item $sm).LastWriteTime -lt (Get-Item $leonida).LastWriteTime) { try { Copy-Item $leonida $sm -Force -ErrorAction Stop } catch { # Still held by a game that has not quite gone: Windows lets it be renamed out of the way. Rename-Item $sm "leonida_sm.exe.old-$(Get-Date -Format HHmmss)" -ErrorAction SilentlyContinue Copy-Item $leonida $sm -Force } } $leonida = $sm } Get-ChildItem (Join-Path (Split-Path $leonida) '*.old-*') -ErrorAction SilentlyContinue | Remove-Item -ErrorAction SilentlyContinue # (Other settings left over in this window go; where your files are stays.) $paths = 'LEONIDA_CONFIG', 'LEONIDA_GAME_DIR', 'LEONIDA_CACHE_DIR', 'LEONIDA_DATA_DIR' Get-ChildItem Env:LEONIDA_* | Where-Object { $_.Name -notin $paths } | ForEach-Object { Remove-Item "Env:$($_.Name)" } foreach ($k in $settings.Keys) { Set-Item "Env:$k" $settings[$k] } # Leonida: the keyboard-and-mouse and PlayStation button prompts. The title has only Xbox glyphs; the layer serves # pc_prompt_glyphs.gfx and ps_prompt_glyphs.gfx in their place (docs/prompt_glyphs.md), or ps_live_prompt_glyphs.gfx # that follows a switch during play, and this builds them into # target\ from the built-in key caps (or -PcGlyphs) over the title's own glyph movie, read from the copy's # data.rpf. Seconds, and only when one is missing or its tool changed; a movie of yours (anywhere the layer looks, # or LEONIDA_PC_GLYPHS / LEONIDA_PS_GLYPHS in -More) is left alone. Needs Python; without it the Xbox glyphs stay. $glyphTool = Join-Path (Split-Path $root) 'tools\prompt_glyph_movies.py' # python before py, and two minutes at most: where py is the Python install manager's alias, its first run waits for # an answer, and a start from a window nobody types in stood still there (10 minutes and 0 s of the processor's # time, 2026-11-30); python, the same manager's, ran the tool. $python = Get-Command python, py -CommandType Application -ErrorAction SilentlyContinue | Select-Object -First 1 if ((Test-Path $glyphTool) -and $python) { $glyphArgs = @('-I', $glyphTool, '--game', (Split-Path $Exe)) if ($python.Name -eq 'py.exe') { $glyphArgs = @('-3') + $glyphArgs } if ($PcGlyphs) { $glyphArgs += @('--pc-glyphs', $PcGlyphs) } $quoted = $glyphArgs | ForEach-Object { if ($_ -match '[\s"]') { '"' + ($_ -replace '"', '\"') + '"' } else { $_ } } try { $glyphRun = Start-Process -FilePath $python.Source -ArgumentList $quoted -NoNewWindow -PassThru -ErrorAction Stop if (-not $glyphRun.WaitForExit(120000)) { & taskkill.exe /T /F /PID $glyphRun.Id 2>&1 | Out-Null Write-Host 'Button prompts: not built (the tool had not finished after two minutes); the title shows its Xbox glyphs.' } } catch { Write-Host "Button prompts: not built ($_); the title shows its Xbox glyphs." } } # The title's own graphics settings (storage\settings\settings.xml in the data folder). It writes the file with its # console defaults whenever it exits by itself: ray-traced dynamic shadows on, two samples of screen-space # occlusion, motion blur, full detail and grass distances. -More @{LEONIDA_TITLE_GRAPHICS='performance'} writes the # lighter set aki-runtime uses (Aki-Developer, Apply-LowVramSettings.ps1 and docs/session-2026-11-26.md of # aki-gta6/aki-runtime: on its Series S profile the card's wait went from 50-69 ms to about 10) and keeps the first # file beside it as settings.xml.original. Off by default: on the Series X profile here it changed nothing that # could be measured at the save (three minutes of the idle camera each, 2026-11-27: 92.5 ms a frame and 6,353 # draws with the console's settings, 90.9-101.7 ms and 6,636-7,079 draws with the lighter set) and 338-350 draws a # frame were dropped for want of a pipeline against 191. # With another output size than the console's (LEONIDA_OUTPUT), the title's settings file is told that size as its # UI and fullscreen resolution: left at 0x0 ("as the console") it lays the UI out for 3840x2160 and the weapon wheel # and menus come out half again too big in a 2560x1440 picture (2026-11-27). # The data folder the title's settings file is in: the variable, else `data_dir` of leonida.toml beside the layer # (with only the file naming it, neither of the two writers below ran: 2026-11-27). $dataDir = $env:LEONIDA_DATA_DIR if (-not $dataDir) { $tomlHere = Join-Path $root 'leonida.toml' if ((Test-Path $tomlHere) -and ((Get-Content $tomlHere -Raw) -match "(?m)^\s*data_dir\s*=\s*['""]([^'""]+)['""]")) { # (In a double-quoted TOML string a backslash is written twice.) $dataDir = $Matches[1] -replace '\\\\', '\' } } if (-not $DryRun -and $dataDir -and "$($settings.LEONIDA_OUTPUT)" -match '^(\d+)x(\d+)$') { $outW = $Matches[1]; $outH = $Matches[2] Get-ChildItem (Join-Path $dataDir '*\storage\settings\settings.xml') -ErrorAction SilentlyContinue | ForEach-Object { $file = $_.FullName $text = [IO.File]::ReadAllText($file) $new = $text foreach ($block in 'uiResolution', 'resolutionFullscreen') { $new = [regex]::Replace($new, "(<$block>\s*\s*)", "`${1}$outW`${2}$outH`${3}") } if ($new -ne $text) { if (-not (Test-Path "$file.original")) { Copy-Item $file "$file.original" } [IO.File]::WriteAllText($file, $new, (New-Object Text.UTF8Encoding $false)) Write-Host "The title's UI and fullscreen resolution: ${outW}x$outH written to its settings (the first file is $file.original)." } } } $titleGraphics = if ($settings.LEONIDA_TITLE_GRAPHICS) { "$($settings.LEONIDA_TITLE_GRAPHICS)" } else { 'keep' } if (-not $DryRun -and $titleGraphics -eq 'performance' -and $dataDir) { $lighter = [ordered]@{ rtDynamicShadows = 'false'; rtLODLightShadows = 'false'; ssroSampleCount = '0'; motionBlur = 'false' shadowParticleShadows = 'false'; sharpenEnabled = 'false'; grassLod = '0.300000'; lodScale = '0.600000' vehicleHDCount = '0'; directionalScreenSpaceShadowQuality = '0.000000'; worldHeightShadowQuality = '0.000000' anisotropicFiltering = '16'; vSync = '0' } Get-ChildItem (Join-Path $dataDir '*\storage\settings\settings.xml') -ErrorAction SilentlyContinue | ForEach-Object { $file = $_.FullName $text = [IO.File]::ReadAllText($file) $new = $text foreach ($name in $lighter.Keys) { $new = [regex]::Replace($new, "(<$name value=`")[^`"]*(`" />)", "`${1}$($lighter[$name])`${2}") } if ($new -ne $text) { if (-not (Test-Path "$file.original")) { Copy-Item $file "$file.original" } [IO.File]::WriteAllText($file, $new, (New-Object Text.UTF8Encoding $false)) Write-Host "The title's graphics settings: the lighter set written (the first file is $file.original)." } } } # A shader cache of its own: one an earlier version of this fork filled does not fit this renderer's pipelines. $toml = Join-Path $root 'leonida.toml' if (-not $env:LEONIDA_CACHE_DIR -and -not ((Test-Path $toml) -and (Select-String -Path $toml -Pattern '^\s*cache_dir\s*=' -Quiet))) { $env:LEONIDA_CACHE_DIR = Join-Path $env:LOCALAPPDATA 'Leonida\cache-nvidia-2' } # Leonida: shaders and pipelines are made before the title starts, not while it plays (as Hookshot's release # builds do). Every shader of the title's shader archive is translated into the cache with the settings of this # start: once per change of the translator or of a setting a translation depends on; a later start finds them all # there. Then the host pipelines earlier runs drew with are made in processes of their own, so that the driver's # cache on disk has them: after a change of the layer or of the driver, and for places first seen in the last run. if (-not $NoPrecompile) { $archive = Join-Path (Split-Path $Exe) 'shaders.rpf' $from = if (Test-Path $archive) { $archive } else { Split-Path $Exe } Push-Location $root # Only what the two commands print themselves (their log goes to the error stream: quiet for these, and no # redirection of it, which Windows PowerShell 5.1 turns into errors). $logWas = $env:LEONIDA_LOG; $env:LEONIDA_LOG = 'error' $stopWas = $ErrorActionPreference; $ErrorActionPreference = 'Continue' try { Write-Host 'Precompiling shaders (minutes the first time, seconds after; -NoPrecompile skips it) ...' & $leonida shaders $from | Where-Object { $_ -match 'shaders in the cache|do not translate' } | ForEach-Object { Write-Host " $_" } Write-Host 'Precompiling the pipelines earlier runs drew with ...' # The driver keeps what these processes compile in its own files, of at most its "Shader Cache Size" each # (4 GB unless raised). A full one keeps nothing new: every start then compiles in the game again, at a # frame every few seconds and with draws missing (2026-11-27, twice in a day of translator changes). # Which files are this game's is told by which ones the precompile touches. $dxCache = Join-Path $env:LOCALAPPDATA 'NVIDIA\DXCache' $dxBefore = @{} Get-ChildItem $dxCache -Filter '*.nvph' -ErrorAction SilentlyContinue | ForEach-Object { $dxBefore[$_.Name] = $_.LastWriteTimeUtc } # Leonida: the pipelines made before are not made again (warm-done.txt), so a driver cache emptied since (by # hand, or a full one moved aside) left them all to be compiled in the game: a tour at 8.6 frames a second # against 11, up to 480 ms a frame waiting for pipelines (runs d76, d96, 2026-11-29). The files the last # precompile wrote are noted with their sizes; if one of them is gone, or smaller than it was, every pipeline # is made again. (Gone alone did not tell it: the driver makes a file of that name anew, small, before the # precompile looks, and run d256 compiled in the game, frames of up to 5.9 s, 2026-11-30.) # (The cache folder: the variable, else `cache_dir` of leonida.toml beside the layer, as the layer reads it.) $cacheRoot = $env:LEONIDA_CACHE_DIR if (-not $cacheRoot -and (Test-Path $toml) -and ((Get-Content $toml -Raw) -match "(?m)^\s*cache_dir\s*=\s*['""]([^'""]+)['""]")) { $cacheRoot = $Matches[1] -replace '\\\\', '\' } $pipelineDir = if ($cacheRoot) { Join-Path $cacheRoot 'pipelines' } else { $null } $dxNoted = if ($pipelineDir) { Join-Path $pipelineDir 'driver-cache-files.txt' } else { $null } # Leonida: -PrecompileAll makes every pipeline the title has created in any earlier run # (known-pipelines.bin), as foxhound's launcher does, not only those drawn with: places and effects not yet # drawn in then find theirs in the driver's cache instead of compiling while the game waits. Those never drawn # with go into the driver's cache only, not the pipeline library (warm.rs). Some 88,000 against 4,000: an hour # or more the first time, and more than the driver's default 4 GB cache (the warning below). $warmArgs = @('warm') if (-not $PrecompileAll) { $warmArgs += '--used' } else { Write-Host ' -PrecompileAll: every pipeline the title has created, into the driver''s cache. An hour or more the' Write-Host ' first time; set NVIDIA''s Shader Cache Size to Unlimited, or what does not fit is compiled in the game.' } $gone = @() if ($dxNoted -and (Test-Path $dxNoted)) { # Lines are "" (older launchers) or " ". $gone = @(Get-Content $dxNoted | Where-Object { $_ } | Where-Object { $name, $bytes = $_ -split ' ', 2 $file = Get-Item -LiteralPath (Join-Path $dxCache $name) -ErrorAction SilentlyContinue -not $file -or ($bytes -and $file.Length -lt [int64]$bytes) } | ForEach-Object { ($_ -split ' ', 2)[0] }) if ($gone.Count) { Write-Host " NVIDIA's shader cache for this game was emptied ($($gone -join ', ')): its pipelines are made again (minutes)." $warmArgs += '--again' } } & $leonida @warmArgs | Where-Object { $_ -match 'pipelines known|^\d+ of |made in|pipeline library' } | ForEach-Object { Write-Host " $_" } if ($dxNoted -and (Test-Path $pipelineDir)) { # Leonida: the files this precompile wrote, at their sizes now, and those noted before that it left # alone. A precompile with nothing to make writes few of them: with the note replaced by those, a # set of the cache's files moved aside since was no longer looked for, and the next start compiled # every pipeline in the game (run d278, 2026-12-01). After pipelines made again, the old note goes. $noted = [ordered]@{} if (-not $gone.Count -and (Test-Path $dxNoted)) { Get-Content $dxNoted | Where-Object { $_ } | ForEach-Object { $name, $bytes = $_ -split ' ', 2; $noted[$name] = $bytes } } Get-ChildItem $dxCache -Filter '*.nvph' -ErrorAction SilentlyContinue | Where-Object { $dxBefore[$_.Name] -ne $_.LastWriteTimeUtc } | ForEach-Object { $noted[$_.Name] = $_.Length } if ($noted.Count) { $noted.GetEnumerator() | ForEach-Object { "$($_.Key) $($_.Value)".TrimEnd() } | Set-Content -Path $dxNoted -Encoding ascii } } $dxFull = @(Get-ChildItem $dxCache -Filter '*.nvph' -ErrorAction SilentlyContinue | Where-Object { $_.Length -ge 4GB -and $dxBefore[$_.Name] -ne $_.LastWriteTimeUtc }) if ($dxFull.Count) { Write-Warning ("NVIDIA's shader cache for this game is full ($($dxFull[0].FullName), 4 GB): what was compiled just now " + "is not kept, and the game will compile it again while it runs. Set 'Shader Cache Size' to Unlimited in the " + "NVIDIA Control Panel (Manage 3D settings), or delete that file while the game is closed.") } } finally { $ErrorActionPreference = $stopWas if ($null -eq $logWas) { Remove-Item Env:LEONIDA_LOG -ErrorAction SilentlyContinue } else { $env:LEONIDA_LOG = $logWas } Pop-Location } } $stamp = Get-Date -Format 'MMdd-HHmmss' if ($Capture) { $env:LEONIDA_CAPTURE = Join-Path $env:LOCALAPPDATA "Leonida\captures\$stamp" $env:LEONIDA_DUMP_TARGETS = '1' New-Item -ItemType Directory -Force $env:LEONIDA_CAPTURE | Out-Null Write-Host "F9 saves a frame to $env:LEONIDA_CAPTURE" } $runArgs = @('run', "`"$Exe`"", '--execute', '--console', $console) Push-Location $root # leonida.toml is looked for here try { if ($Log) { $logs = Join-Path $env:LOCALAPPDATA 'Leonida\logs' New-Item -ItemType Directory -Force $logs | Out-Null Get-ChildItem $logs -Filter 'play-*.log' | Sort-Object LastWriteTime -Descending | Select-Object -Skip 4 | Remove-Item -ErrorAction SilentlyContinue Write-Host "log: $logs\play-$stamp.log" Start-Process -FilePath $leonida -ArgumentList $runArgs -NoNewWindow -Wait -RedirectStandardError "$logs\play-$stamp.log" } else { Start-Process -FilePath $leonida -ArgumentList $runArgs -NoNewWindow -Wait } } finally { Pop-Location }