From 2ac782d0c3d495a2fd2d871e5ce252cc143b1330 Mon Sep 17 00:00:00 2001 From: louisdibiasi <59670693+louisdibiasi@users.noreply.github.com> Date: Sun, 29 Nov 2026 16:33:01 -0500 Subject: [PATCH] launcher: honor -NoFrameGen across settings and restart Keep the DLSS frame generation opt-out after loading settings and in the F1 restart command. Verify the opt-out alongside the FSR 3 launcher option using synthetic PowerShell dry runs. --- d3d12/scripts/play-nvidia.ps1 | 2 + tests/test_play_nvidia_no_frame_gen.py | 124 +++++++++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 tests/test_play_nvidia_no_frame_gen.py diff --git a/d3d12/scripts/play-nvidia.ps1 b/d3d12/scripts/play-nvidia.ps1 index ec63f6eb88..5762567260 100644 --- a/d3d12/scripts/play-nvidia.ps1 +++ b/d3d12/scripts/play-nvidia.ps1 @@ -459,6 +459,7 @@ if (Test-Path $menuFile) { # 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] } +if ($NoFrameGen) { $settings.Remove('LEONIDA_FRAME_GEN') } # 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) { @@ -535,6 +536,7 @@ foreach ($s in 'Resolution', 'Lowest', 'Dlss', 'FrameGen', 'Aspect', 'PresentSca if ($PSBoundParameters[$s]) { $again += "-$s '$($PSBoundParameters[$s] -replace "'", "''")'" } } if ($PSBoundParameters.ContainsKey('WindowsBarMB')) { $again += "-WindowsBarMB $WindowsBarMB" } +if ($NoFrameGen) { $again += '-NoFrameGen' } $settings.LEONIDA_MENU_ARGS = $again -join ' ' $scaled = if ($settings.LEONIDA_RENDER_SCALE) { " from render scale $($settings.LEONIDA_RENDER_SCALE)" } else { '' } diff --git a/tests/test_play_nvidia_no_frame_gen.py b/tests/test_play_nvidia_no_frame_gen.py new file mode 100644 index 0000000000..c07842b2e3 --- /dev/null +++ b/tests/test_play_nvidia_no_frame_gen.py @@ -0,0 +1,124 @@ +"""Exercise the Windows launcher's DLSS frame generation opt-out with -DryRun.""" + +import json +import os +from pathlib import Path +import shutil +import subprocess +import tempfile +import unittest + + +LAUNCHER = Path(__file__).resolve().parents[1] / "d3d12/scripts/play-nvidia.ps1" +DRY_RUN = r""" +$ErrorActionPreference = 'Stop' +function Get-CimInstance { + [CmdletBinding()] param([string]$ClassName) + switch ($ClassName) { + 'Win32_OperatingSystem' { [pscustomobject]@{ BuildNumber = '26300' } } + 'Win32_ComputerSystem' { [pscustomobject]@{ TotalPhysicalMemory = 64GB } } + 'Win32_VideoController' { [pscustomobject]@{ Name = 'NVIDIA GeForce RTX 4060 Ti' } } + default { throw "Unexpected WMI query: $ClassName" } + } +} +function Get-ChildItem { + [CmdletBinding()] param([string]$Path) + if ($Path -notlike 'HKLM:*') { throw "Unexpected directory query: $Path" } +} +$common = @{ + Exe = $env:LEONIDA_TEST_EXE + StreamlineDir = $env:LEONIDA_TEST_STREAMLINE + SeriesX = $true + Resolution = '1080' + NoDlss = $true + NoSmoothMotion = $true + DryRun = $true +} +function Read-Launch([hashtable]$options) { + $lines = @(& $env:LEONIDA_TEST_LAUNCHER @common @options 6>$null) + $restart = @($lines -match '^LEONIDA_MENU_ARGS=') + if ($restart.Count -ne 1) { throw 'Launcher dry run did not emit restart arguments' } + @{ + frame_gen = @($lines -match '^LEONIDA_FRAME_GEN=') + fsr_frame_gen = @($lines -match '^LEONIDA_FSR_FRAMEGEN=') + restart_opt_out = $restart[0] -match '\s-NoFrameGen(?:\s|$)' + restart_fsr = $restart[0] -match '\s-FsrFrameGen(?:\s|$)' + } +} +$result = @{} +$result.default = Read-Launch @{} +$result.clean_opt_out = Read-Launch @{ NoFrameGen = $true } +Set-Content -LiteralPath $env:LEONIDA_TEST_MENU_FILE -Value 'LEONIDA_FRAME_GEN=3' -Encoding Ascii +$result.saved = Read-Launch @{} +$result.saved_opt_out = Read-Launch @{ NoFrameGen = $true } +$result.extra = Read-Launch @{ More = @{ LEONIDA_FRAME_GEN = '4' } } +$result.extra_opt_out = Read-Launch @{ More = @{ LEONIDA_FRAME_GEN = '4' }; NoFrameGen = $true } +$result.fsr_opt_out = Read-Launch @{ + FsrFrameGen = $true + FidelityFxDir = $env:LEONIDA_TEST_FIDELITYFX + NoFrameGen = $true +} +ConvertTo-Json -InputObject $result -Depth 5 -Compress +""" + + +@unittest.skipUnless(os.name == "nt", "requires Windows PowerShell") +class PlayNvidiaNoFrameGenTest(unittest.TestCase): + def test_opt_out_overrides_saved_settings_and_survives_restart(self) -> None: + shells = [path for name in ("powershell.exe", "pwsh.exe") if (path := shutil.which(name))] + if not shells: + self.skipTest("PowerShell is unavailable") + expected = { + "default": (["LEONIDA_FRAME_GEN=2"], False), + "clean_opt_out": ([], True), + "saved": (["LEONIDA_FRAME_GEN=3"], False), + "saved_opt_out": ([], True), + "extra": (["LEONIDA_FRAME_GEN=4"], False), + "extra_opt_out": ([], True), + "fsr_opt_out": ([], True), + } + with tempfile.TemporaryDirectory() as temp: + root = Path(temp) + launcher = root / "scripts" / LAUNCHER.name + launcher.parent.mkdir() + shutil.copyfile(LAUNCHER, launcher) + exe = root / "placeholder.exe" + exe.touch() + streamline = root / "streamline" + streamline.mkdir() + fidelityfx = root / "fidelityfx" + fidelityfx.mkdir() + for name in ("amd_fidelityfx_loader_dx12.dll", "amd_fidelityfx_framegeneration_dx12.dll"): + (fidelityfx / name).touch() + menu = root / "leonida-settings.txt" + env = {key: value for key, value in os.environ.items() if not key.upper().startswith("LEONIDA_")} + env.update( + LEONIDA_TEST_EXE=str(exe), + LEONIDA_TEST_FIDELITYFX=str(fidelityfx), + LEONIDA_TEST_LAUNCHER=str(launcher), + LEONIDA_TEST_MENU_FILE=str(menu), + LEONIDA_TEST_STREAMLINE=str(streamline), + ) + for shell in shells: + menu.unlink(missing_ok=True) + run = subprocess.run( + [shell, "-NoProfile", "-NonInteractive", "-Command", DRY_RUN], + env=env, + capture_output=True, + text=True, + timeout=60, + ) + with self.subTest(shell=shell): + self.assertEqual(run.returncode, 0, run.stdout + run.stderr) + results = json.loads(run.stdout) + for case, expected_result in expected.items(): + with self.subTest(case=case): + result = results[case] + self.assertEqual((result["frame_gen"], result["restart_opt_out"]), expected_result) + fsr = results["fsr_opt_out"] + self.assertEqual(fsr["fsr_frame_gen"], ["LEONIDA_FSR_FRAMEGEN=1"]) + self.assertTrue(fsr["restart_fsr"]) + + +if __name__ == "__main__": + unittest.main()