diff --git a/README.md b/README.md index 168e94fc2..63fc0c409 100644 --- a/README.md +++ b/README.md @@ -57,8 +57,8 @@ Discord: https://discord.gg/ETf4qj5acN · Telegram: https://t.me/mandyport | | | |---|---| | PC | Ryzen 5 7600X (6 cores), GeForce RTX 4060 Ti 16 GB (driver 616.64), 32 GB of RAM, Windows 11 | -| Settings | the defaults: Series X profile, 2560x1440 rendered, the game's own upscaler | -| Rendered frame rate | **12 to 14 frames a second** standing at the test save's spot (median frame 72 to 81 ms in four starts, 9,500 to 11,600 draws a frame). The graphics card is the limit, at about 60 ms of work a frame. Rendering 1920x1080 (`-Resolution 1080`) is about 15% faster | +| Settings | the defaults: Series X profile, 2560x1440 output, the game's own dynamic resolution (1080 to 1440 lines rendered) and its own upscaler | +| Rendered frame rate | **16 to 18 frames a second** standing at the test save's spot on 2026-11-29 (median frame 57 to 60 ms in two series, about 10,500 draws a frame): the game's own dynamic resolution sits at its 1080-line floor there. Held at 1440 lines (`-Resolution 1440`) the same series took 66 to 68 ms (about 15 frames a second). The graphics card is busy about 92% of the frame, and the thread that hands the game's work to it about 56 ms: both have to fall for 30 | | With frame generation | on by default on RTX 40 and 50 cards: twice the frames are shown, held to 28 a second by NVIDIA Reflex and paced evenly. It looks smoother; the game still reacts at the rendered rate | | Goal | a steady 30 rendered frames a second at Series X settings. **Not reached yet**: the frame rate is what most of the work goes into | | What works | loading a save into the open world; walking, driving, the phone, the HUD, the map, the weapon wheel and the pause menu; sound; Xbox and PlayStation pads (with matching button prompts) and keyboard and mouse; saving | @@ -102,7 +102,8 @@ Useful switches of `scripts\play-d3d12.ps1` (the launcher's Settings page has th | Switch | Does | |---|---| -| `-Resolution 1080` | render 1920x1080 instead of 2560x1440: faster, softer | +| `-Resolution 1440` | hold the rendered height at 1440 lines (or 1080) instead of letting the game pick between 1080 and 1440: sharper, slower | +| `-Lowest 720` | the lowest height the game's own dynamic resolution may pick (1080 by default) | | `-NoFrameGen` | no frame generation: only the frames the game renders | | `-MotionBlur` | the game's own motion blur (off by default: at this frame rate it smears in blocks on camera turns) | | `-FrameGen 2`…`6` with `-Dlss quality\|balanced\|performance\|ultra` | DLSS makes the output and frame generation shows 2 to 6 times the frames | @@ -196,8 +197,9 @@ own checkout ([notes](docs/progress_dashboard.md)). The biggest open pieces: -- **The frame rate** of the `d3d12/` runtime: 12 to 14 rendered frames a second at Series X 1440p on an RTX 4060 Ti, - where the goal is a steady 30. The graphics card is the limit. +- **The frame rate** of the `d3d12/` runtime: 16 to 18 rendered frames a second at Series X settings (dynamic + resolution at its 1080-line floor) on an RTX 4060 Ti, where the goal is a steady 30. The graphics card (mostly the + translated mesh and compute shaders) and the one thread that hands the game's work to it both take about 56 ms. - **The picture faults** listed under [Known problems](#known-problems). - **A first world frame on the recompiled runtime** ([where it stops](docs/linux_proton.md#where-it-stops)), and the wave64 cross-half code of vertex, pixel and geometry shaders on 32-wide subgroups. diff --git a/d3d12/README.md b/d3d12/README.md index 955662050..bdb208439 100644 --- a/d3d12/README.md +++ b/d3d12/README.md @@ -9,12 +9,14 @@ It grew from the VIctory runtime: Marvisak/VIctory, through trustno1-coder/VIcto its own work on top; everything below this section is trustno1-coder/VIctory-NVIDIA's README as it came, with the project name changed where it named the program. -## Where it stands (2026-11-28) +## Where it stands (2026-11-29) -On a Ryzen 5 7600X with a GeForce RTX 4060 Ti 16 GB, the Series X profile rendering 2560x1440 (the default of -`scripts/play-d3d12.ps1`) runs **12 to 14 frames a second** standing at the test save's spot (median frame 72 to -81 ms in four starts). The graphics card is the limit; `-Resolution 1080` is about 15% faster. A steady 30 rendered -frames a second is not reached yet. On RTX 40 and 50 cards, DLSS frame generation is on by default when NVIDIA's +On a Ryzen 5 7600X with a GeForce RTX 4060 Ti 16 GB, the Series X profile with a 2560x1440 output and the title's own +dynamic resolution between 1080 and 1440 lines (`-Lowest 1080`, the default of `scripts/play-d3d12.ps1`; +`LEONIDA_RENDER_SCALE_MIN`, the loader's `hooks.rs`) runs **16 to 18 frames a second** standing at the test save's +spot (median frame 57.0 and 59.6 ms in two series, against 66.0 and 67.9 held at 1440 with `-Resolution 1440`); the +title's choice sits at its 1080 floor there. The card is busy about 92% of the frame and the submit thread about +56 ms: both limit it. A steady 30 rendered frames a second is not reached yet. On RTX 40 and 50 cards, DLSS frame generation is on by default when NVIDIA's files are there (`Get-NVIDIA-DLSS.cmd`): it shows twice the frames, held to 28 a second by Reflex (`LEONIDA_FG_LIMIT_FPS`) with presents paced evenly (`LEONIDA_PRESENT_SMOOTH`); `-NoFrameGen` turns it off. The measurements and what is still wrong in the picture are in the [top-level README](../README.md#project-status). diff --git a/d3d12/crates/leonida-loader/src/hooks.rs b/d3d12/crates/leonida-loader/src/hooks.rs index def7742ad..6fbbbc7f1 100644 --- a/d3d12/crates/leonida-loader/src/hooks.rs +++ b/d3d12/crates/leonida-loader/src/hooks.rs @@ -75,6 +75,12 @@ pub(crate) const RENDER_SCALE_ENV: &str = "LEONIDA_RENDER_SCALE"; /// Environment variable that makes the title use its own temporal upscaler /// on every console profile (Series S otherwise picks FSR). pub(crate) const OWN_UPSCALER_ENV: &str = "LEONIDA_OWN_UPSCALER"; +/// Leonida: environment variable for the title's own dynamic resolution (`0.2..=1.0` of the output size). The own +/// upscaler takes the larger of a minimum (2/3 as shipped) and the scale the title picks frame by frame; +/// [`RENDER_SCALE_ENV`] pins both to one value. This sets the minimum alone and leaves the title's choice above it, +/// so the title can render less in a heavy scene, as the console does (0.75 with a 2560x1440 output: 1080 to 1440 +/// lines). A valid [`RENDER_SCALE_ENV`] wins over it. +pub(crate) const RENDER_SCALE_MIN_ENV: &str = "LEONIDA_RENDER_SCALE_MIN"; /// Leonida: environment variable that tops the title's output modes at 2560x1440 (Series X: the 3840x2160 row /// of its mode table becomes 2560x1440, so it never finds a 4K mode and presents 1440p): [`OUTPUT_ENV`] with @@ -272,13 +278,15 @@ fn parse_scale(text: &str) -> Option { /// # Safety /// As `disarm_watchdog`. pub(crate) unsafe fn resolution_levers(base: usize, hash: &blake3::Hash) -> usize { - let scale = std::env::var(RENDER_SCALE_ENV).ok(); + let scale = std::env::var(RENDER_SCALE_ENV).ok().filter(|v| !v.trim().is_empty()); + let min = std::env::var(RENDER_SCALE_MIN_ENV).ok().filter(|v| !v.trim().is_empty()); + let pinned = scale.as_deref().and_then(parse_scale).is_some(); let own = std::env::var_os(OWN_UPSCALER_ENV).is_some_and(|v| v != "0"); let fsr = std::env::var_os(FSR_UPSCALER_ENV).is_some_and(|v| v == "1"); let output = std::env::var(OUTPUT_ENV).ok().filter(|v| !v.trim().is_empty()).or_else(|| { std::env::var_os(OUTPUT_1440_ENV).is_some_and(|v| v == "1").then(|| "2560x1440".to_owned()) }); - if scale.is_none() && !own && !fsr && output.is_none() { + if scale.is_none() && min.is_none() && !own && !fsr && output.is_none() { return 0; } // Every image the loader maps comes here (the title's DLLs too); only @@ -322,6 +330,20 @@ pub(crate) unsafe fn resolution_levers(base: usize, hash: &blake3::Hash) -> usiz None => tracing::warn!(text, "{RENDER_SCALE_ENV} wants a number in 0.2..=1.0"), } } + if let Some(text) = min.filter(|_| !pinned) { + match parse_scale(&text) { + Some(min) => { + // The minimum alone (the first of the render-scale patches); the title's own choice stays above it. + if let Some(p) = render_scale_patches(base, min, false).into_iter().next() { + // SAFETY: forwarded from this function's contract. + let done = unsafe { apply(base, &p.borrowed()) }; + applied += usize::from(done); + tracing::info!(min, applied = done, "the title's own dynamic resolution: its lowest render scale set, the scale above it left to the title ({RENDER_SCALE_MIN_ENV})"); + } + } + None => tracing::warn!(text, "{RENDER_SCALE_MIN_ENV} wants a number in 0.2..=1.0"), + } + } applied } diff --git a/d3d12/scripts/play-nvidia.ps1 b/d3d12/scripts/play-nvidia.ps1 index 8d9d81748..34ee17775 100644 --- a/d3d12/scripts/play-nvidia.ps1 +++ b/d3d12/scripts/play-nvidia.ps1 @@ -30,6 +30,11 @@ # first time, and DLSS frame generation is left off with it (the two together do not work yet). # -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 @@ -55,6 +60,7 @@ param( [switch]$Quality, [switch]$RayTracing, [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, @@ -74,7 +80,8 @@ param( ) $root = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path if (-not (Test-Path $Exe)) { Write-Host "No $Exe."; return } -if ($Dlss -and $Resolution) { Write-Host '-Dlss sets the render height by its mode: leave -Resolution out with it.'; 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 @@ -85,7 +92,7 @@ $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 $SeriesX -or $Dlss -or $FrameGen) +$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) { @@ -271,19 +278,22 @@ $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) { - # The older path: a render scale and the title's own upscaler (rendered height over output height). +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]$Resolution -le 1440 -and -not $More.ContainsKey('LEONIDA_OUTPUT')) { + if ($SeriesX -and [int]$height -le 1440 -and -not $More.ContainsKey('LEONIDA_OUTPUT')) { $settings.LEONIDA_OUTPUT = '2560x1440' $outHeight = 1440 } - if ([int]$Resolution -gt $outHeight) { Write-Host "That console outputs ${outHeight}p: ${Resolution}p is above it."; return } - $settings.LEONIDA_RENDER_SCALE = ([int]$Resolution / $outHeight).ToString('0.####', [Globalization.CultureInfo]::InvariantCulture) + 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' @@ -300,7 +310,7 @@ if ($FrameGen) { $settings.LEONIDA_FRAME_GEN = "$FrameGen" } # 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 -and -not $RayTracing -and $StreamlineDir) { +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' @@ -452,7 +462,7 @@ $again = @("-Exe '$($Exe -replace "'", "''")'", "-Build $Build") foreach ($s in 'NoSmoothMotion', 'NoDlss', 'SeriesX', 'Quality', 'RayTracing', 'NoPrecompile', 'Log', 'Capture') { if ($PSBoundParameters[$s]) { $again += "-$s" } } -foreach ($s in 'Resolution', 'Dlss', 'FrameGen', 'Aspect', 'PresentScale', 'Adapter', 'DlssDir', 'StreamlineDir') { +foreach ($s in 'Resolution', 'Lowest', 'Dlss', 'FrameGen', 'Aspect', 'PresentScale', 'Adapter', 'DlssDir', 'StreamlineDir') { if ($PSBoundParameters[$s]) { $again += "-$s '$($PSBoundParameters[$s] -replace "'", "''")'" } } if ($PSBoundParameters.ContainsKey('WindowsBarMB')) { $again += "-WindowsBarMB $WindowsBarMB" } @@ -462,6 +472,7 @@ $scaled = if ($settings.LEONIDA_RENDER_SCALE) { " from render scale $($settings. # 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)" } diff --git a/scripts/play-d3d12.ps1 b/scripts/play-d3d12.ps1 index 01192a5d6..aed36ce25 100644 --- a/scripts/play-d3d12.ps1 +++ b/scripts/play-d3d12.ps1 @@ -3,9 +3,10 @@ # # powershell -ExecutionPolicy Bypass -File scripts\play-d3d12.ps1 -Game # -# By default the game runs as on an Xbox Series X, rendering 2560x1440 (render scale 2/3 of its 3840x2160 output) -# with its own temporal upscaler; -SeriesS runs the lighter Series S profile instead, where the game renders its own -# 720p picture and DLSS takes it to 1080p. -Resolution sets the rendered height (Series X: 1080 or 1440). DLSS and DLSS +# By default the game runs as on an Xbox Series X with a 2560x1440 output and its own dynamic resolution and temporal +# upscaler: it renders between 1080 and 1440 lines by how long its frames take (-Lowest 1080); -SeriesS runs the +# lighter Series S profile instead, where the game renders its own 720p picture and DLSS takes it to 1080p. +# -Resolution holds one rendered height instead (Series X: 1080 or 1440), -Lowest sets the lowest one. DLSS and DLSS # frame generation need a few of NVIDIA's own files that no repository may carry: d3d12\Get-NVIDIA-DLSS.cmd fetches # them from NVIDIA's GitHub once (about 70 MB). Without them the picture is stretched to the screen instead. # In the game: F1 = settings (frame generation, frame-rate cap, DLSS preset ...), F3 = the numbers panel. @@ -26,6 +27,9 @@ # -Aspect the window's shape: 21:9, 32:9, 16:9, W:H or auto (the screen's). The game still draws 16:9, shown # centred with black bars (-PresentScale fit, the default with -Aspect) or stretched (stretch). # -Resolution the older path: the game renders at this height and the title's own upscaler does the rest +# -Lowest the lowest height of the title's own dynamic resolution (1080 by default on Series X): it renders +# between this and 1440 lines. Same save, RTX 4060 Ti (2026-11-29): 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 there. # -RayTracing the title's real ray tracing (slower; shaders build for minutes the first time) # -Capture F9 in the game saves that frame and the pictures it drew # -NoPrecompile start at once: by default every shader is translated and the pipelines earlier runs drew with are @@ -43,6 +47,7 @@ param( [switch]$SeriesS, [switch]$Quality, [ValidateSet('', '2160', '1440', '1080', '720', '540', '480')][string]$Resolution = '', + [ValidateSet('', '1440', '1080', '720', '540', '480')][string]$Lowest = '', [ValidateSet('', 'quality', 'balanced', 'performance', 'ultra')][string]$Dlss = '', [ValidateSet(0, 2, 3, 4, 5, 6)][int]$FrameGen = 0, [switch]$NoFrameGen, @@ -84,8 +89,9 @@ $launch = @{ Exe = $title; Build = 'diag'; NoSmoothMotion = (-not $SmoothMotion) # Leonida: the Series X profile is the default (the user's call: 1080p-1440p as on the bigger consoles). if (-not $SeriesS) { $launch.SeriesX = $true - # 1440 lines and the title's own upscaler, unless DLSS (which frame generation brings with it) makes the output. - if (-not $Resolution -and -not $Dlss -and -not $FrameGen) { $Resolution = '1440' } + # 1080 to 1440 lines by the title's own dynamic resolution and its own upscaler, unless a height is held + # (-Resolution) or DLSS (which -FrameGen brings with it) makes the output. + if (-not $Resolution -and -not $Lowest -and -not $Dlss -and -not $FrameGen) { $Lowest = '1080' } } if ($Dlss) { $launch.Dlss = $Dlss } if ($FrameGen) { $launch.FrameGen = $FrameGen } @@ -95,5 +101,6 @@ foreach ($switch in 'Quality', 'NoDlss', 'NoFrameGen', 'MotionBlur', 'RayTracing if ($PSBoundParameters[$switch]) { $launch[$switch] = $true } } if ($Resolution) { $launch.Resolution = $Resolution } +if ($Lowest) { $launch.Lowest = $Lowest } if ($Adapter) { $launch.Adapter = $Adapter } & (Join-Path $runtime "scripts\play-nvidia.ps1") @launch