diff --git a/d3d12/README.md b/d3d12/README.md index 90a2b98fe1..8d5d100f8b 100644 --- a/d3d12/README.md +++ b/d3d12/README.md @@ -479,9 +479,9 @@ details, the mouse settings and the other switches are in [docs/gameinput.md](.. ### Picking a resolution -There is one script per console and resolution in `scripts\`. Each one runs -`play-nvidia.ps1` with `-Resolution` set, and takes the same `-Exe` path and -other switches: +There is one script per console and resolution in `scripts\`. Each runs +`play-nvidia.ps1` and takes the same `-Exe` path. Fixed presets pass +`-Resolution`. The dynamic preset passes `-Lowest`. ```powershell scripts\play-S-720p.ps1 -Exe @@ -490,8 +490,10 @@ scripts\play-X-1080p.ps1 -Exe -Quality The resolution is the height the 3D world is drawn at. The title's own upscaler then stretches it to the console's output, and menus, the HUD and -subtitles stay sharp either way. Series S outputs 1920x1080 and Series X -3840x2160, so the same height is a different render scale on each: +subtitles stay sharp either way. Series S outputs 1920x1080. The Series X +presets up to 1440p output 2560x1440 by default, and the 2160p preset +outputs 3840x2160. The render scale is the world height divided by that +preset's output height. | Script | Console | World drawn at | Render scale | Tested on the RTX 5070 | |---|---|---|---|---| @@ -500,12 +502,12 @@ subtitles stay sharp either way. Series S outputs 1920x1080 and Series X | `play-S-540p.ps1` | Series S | 960x540 | 0.5 | yes: the default, about 18-22 fps | | `play-S-480p.ps1` | Series S | 853x480 | 0.444 | not yet | | `play-X-2160p.ps1` | Series X | 3840x2160 | 1.0 | yes, about 6 fps | -| `play-X-1440p.ps1` | Series X | 2560x1440 | 0.667 | not yet | -| `play-X-1080-1440p.ps1` | Series X | 1920x1080 to 2560x1440, picked by the title's own dynamic resolution (`-Lowest 1080`) | 0.5 to 0.667 | not yet (on an RTX 4060 Ti about 13% shorter frames than 1440p: 57.0 and 59.6 ms against 66.0 and 67.9) | -| `play-X-1080p.ps1` | Series X | 1920x1080 | 0.5 | yes: the `-SeriesX` default, about 7 fps | -| `play-X-720p.ps1` | Series X | 1280x720 | 0.333 | not yet | -| `play-X-540p.ps1` | Series X | 960x540 | 0.25 | not yet | -| `play-X-480p.ps1` | Series X | 853x480 | 0.222 | not yet | +| `play-X-1440p.ps1` | Series X | 2560x1440 | 1.0 | not yet | +| `play-X-1080-1440p.ps1` | Series X | 1920x1080 to 2560x1440, picked by the title's own dynamic resolution (`-Lowest 1080`) | 0.75 to 1.0 | not yet (on an RTX 4060 Ti about 13% shorter frames than 1440p: 57.0 and 59.6 ms against 66.0 and 67.9) | +| `play-X-1080p.ps1` | Series X | 1920x1080 | 0.75 | about 7 fps in the Series X baseline | +| `play-X-720p.ps1` | Series X | 1280x720 | 0.5 | not yet | +| `play-X-540p.ps1` | Series X | 960x540 | 0.375 | not yet | +| `play-X-480p.ps1` | Series X | 853x480 | 0.3333 | not yet | What to expect: diff --git a/d3d12/scripts/play-X-1080-1440p.ps1 b/d3d12/scripts/play-X-1080-1440p.ps1 index 5c03c751c9..e008febbad 100644 --- a/d3d12/scripts/play-X-1080-1440p.ps1 +++ b/d3d12/scripts/play-X-1080-1440p.ps1 @@ -1,4 +1,6 @@ # Series X, the title's own dynamic resolution between 1080p and 1440p (output 1440p, then the title's own upscaler). # About 13% shorter frames than play-X-1440p.ps1 on an RTX 4060 Ti (57.0 and 59.6 ms against 66.0 and 67.9). # scripts\play-X-1080-1440p.ps1 -Exe [other play-nvidia.ps1 switches] -& "$PSScriptRoot\play-nvidia.ps1" -SeriesX -Lowest 1080 @args +# Bind the switch here so an explicit false value stays with its name. +param([switch]$MotionBlur) +& "$PSScriptRoot\play-nvidia.ps1" -SeriesX -Lowest 1080 @PSBoundParameters @args diff --git a/tests/test_win_launchers.py b/tests/test_win_launchers.py index 6dd78303dd..9e9b6f3486 100644 --- a/tests/test_win_launchers.py +++ b/tests/test_win_launchers.py @@ -176,6 +176,97 @@ def test_per_user_python_discovery_with_ampersand_and_exit_propagation(self) -> self.assertEqual(r_missing.returncode, 1, r_missing.stdout + r_missing.stderr) self.assertIn("Python 3.12 or newer is needed", r_missing.stdout + r_missing.stderr) + @unittest.skipUnless(POWERSHELL, "requires PowerShell") + def test_dynamic_resolution_preset_forwards_explicit_motion_blur_values(self) -> None: + preset_source = NVIDIA_LAUNCHER.with_name("play-X-1080-1440p.ps1") + stub = r""" +param([switch]$SeriesX, [string]$Lowest, [switch]$MotionBlur) +$motionBlurArgument = if ($PSBoundParameters.ContainsKey('MotionBlur')) { + $MotionBlur.IsPresent.ToString() +} else { + 'omitted' +} +"$($SeriesX.IsPresent) $Lowest $motionBlurArgument" +""" + command = r""" +$ErrorActionPreference = 'Stop' +& $env:TEST_LAUNCHER_PRESET +& $env:TEST_LAUNCHER_PRESET -MotionBlur:$false +& $env:TEST_LAUNCHER_PRESET -MotionBlur +& $env:TEST_LAUNCHER_PRESET -MotionBlur:$true +""" + with tempfile.TemporaryDirectory() as td: + root = Path(td) + preset = root / preset_source.name + shutil.copyfile(preset_source, preset) + (root / NVIDIA_LAUNCHER.name).write_text(stub, encoding="utf-8", newline="\n") + result = subprocess.run( + [POWERSHELL, "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", command], + env={**os.environ, "TEST_LAUNCHER_PRESET": str(preset)}, + capture_output=True, + text=True, + timeout=30, + ) + self.assertEqual(result.returncode, 0, result.stdout + result.stderr) + self.assertEqual(result.stdout.splitlines(), + ["True 1080 omitted", "True 1080 False", "True 1080 True", "True 1080 True"]) + + def test_dynamic_resolution_preset_binds_motion_blur_switch(self) -> None: + powershell = shutil.which("pwsh") or shutil.which("powershell.exe") + if not powershell: + self.skipTest("requires PowerShell") + + command = r""" +$ErrorActionPreference = 'Stop' +function Get-CimInstance { + param([string]$ClassName) + if ($ClassName -ne 'Win32_OperatingSystem') { throw "Unexpected CIM query: $ClassName" } + [pscustomobject]@{ BuildNumber = '26100' } +} +function Show-Preset([string[]]$Lines) { + $Lines -like 'LEONIDA_OUTPUT=*' + $Lines -like 'LEONIDA_RENDER_SCALE_MIN=*' + 'PRESET_SKIPS=' + ($Lines -like 'LEONIDA_SKIP_PIPELINES=*') +} +$preset = $env:TEST_LAUNCHER_PRESET +$exe = $env:TEST_LAUNCHER_EXE +Show-Preset (& $preset -Exe $exe -NoDlss -NoPrecompile -WindowsBarMB 0 -DryRun) +Show-Preset (& $preset -Exe $exe -NoDlss -NoPrecompile -WindowsBarMB 0 -DryRun -MotionBlur:$false) +Show-Preset (& $preset -Exe $exe -NoDlss -NoPrecompile -WindowsBarMB 0 -DryRun -MotionBlur) +Show-Preset (& $preset -Exe $exe -NoDlss -NoPrecompile -WindowsBarMB 0 -DryRun -MotionBlur:$true) +""" + with tempfile.TemporaryDirectory() as td: + root = Path(td) + scripts = root / "scripts" + scripts.mkdir() + source = ROOT / "d3d12" / "scripts" + preset = scripts / "play-X-1080-1440p.ps1" + shutil.copyfile(source / preset.name, preset) + shutil.copyfile(source / "play-nvidia.ps1", scripts / "play-nvidia.ps1") + executable = root / "synthetic title.exe" + executable.touch() + env = {name: value for name, value in os.environ.items() if not name.upper().startswith("LEONIDA_")} + env.update(TEST_LAUNCHER_PRESET=str(preset), TEST_LAUNCHER_EXE=str(executable)) + result = subprocess.run( + [powershell, "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", command], + env=env, + capture_output=True, + encoding="utf-8", + errors="replace", + timeout=30, + ) + self.assertEqual(result.returncode, 0, result.stdout + result.stderr) + lines = result.stdout.splitlines() + self.assertEqual([line for line in lines if line.startswith("LEONIDA_OUTPUT=")], + ["LEONIDA_OUTPUT=2560x1440"] * 4) + self.assertEqual([line for line in lines if line.startswith("LEONIDA_RENDER_SCALE_MIN=")], + ["LEONIDA_RENDER_SCALE_MIN=0.75"] * 4) + skips = [line for line in lines if line.startswith("PRESET_SKIPS=")] + self.assertEqual(len(skips), 4, result.stdout) + self.assertEqual(skips[0], skips[1]) + self.assertEqual(skips[2], skips[3]) + self.assertNotEqual(skips[0], skips[2]) + if __name__ == "__main__": unittest.main()